Skip to content

Commit 2a84cf5

Browse files
committed
#113 - putenv usage
1 parent e583126 commit 2a84cf5

File tree

15 files changed

+350
-110
lines changed

15 files changed

+350
-110
lines changed

mcsrc/src/main.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ main (int argc, char *argv[])
269269
int exit_code = EXIT_FAILURE;
270270
const char *tmpdir = NULL;
271271

272+
#if defined(WIN32)
273+
WIN32_HeapInit ();
274+
#endif
275+
272276
mc_global.run_from_parent_mc = !check_sid ();
273277

274278
/* We had LC_CTYPE before, LC_ALL includes LC_TYPE as well */
@@ -590,7 +594,12 @@ main (int argc, char *argv[])
590594
exit_code = EXIT_FAILURE;
591595
}
592596

593-
(void) putchar ('\n'); /* Hack to make shell's prompt start at left of screen */
597+
(void) putchar ('\n');
598+
/* Hack to make shell's prompt start at left of screen */
599+
600+
#if defined(WIN32)
601+
WIN32_HeapCheck ();
602+
#endif
594603

595604
return exit_code;
596605
}

mcsrc/src/subshell/common.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,11 @@ init_subshell_child (const char *pty_name)
315315
{
316316
char sid_str[BUF_SMALL];
317317

318-
g_snprintf (sid_str, sizeof (sid_str), "MC_SID=%ld", (long) mc_sid);
319-
putenv (g_strdup (sid_str));
318+
//WIN32,setenv
319+
//g_snprintf (sid_str, sizeof (sid_str), "MC_SID=%ld", (long) mc_sid);
320+
//putenv (g_strdup (sid_str));
321+
g_snprintf (sid_str, sizeof (sid_str), "%ld", (long) mc_sid);
322+
g_setenv ("MC_SID", sid_str);
320323
}
321324

322325
switch (mc_global.shell->type)
@@ -334,7 +337,9 @@ init_subshell_child (const char *pty_name)
334337

335338
/* Make MC's special commands not show up in bash's history and also suppress
336339
* consecutive identical commands*/
337-
putenv ((char *) "HISTCONTROL=ignoreboth");
340+
//WIN32,setenv
341+
//putenv ((char *) "HISTCONTROL=ignoreboth");
342+
g_setenv ("HISTCONTROL", "ignoreboth");
338343

339344
/* Allow alternative readline settings for MC */
340345
{
@@ -382,7 +387,9 @@ init_subshell_child (const char *pty_name)
382387
g_setenv ("ENV", init_file, FALSE);
383388

384389
/* Make MC's special commands not show up in history */
385-
putenv ((char *) "HISTCONTROL=ignorespace");
390+
//WIN32,setenv
391+
//putenv ((char *) "HISTCONTROL=ignorespace");
392+
g_setenv ("HISTCONTROL", "ignorespace");
386393

387394
break;
388395

mcsrc/src/vfs/shell/shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ shell_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, const char *remot
10151015

10161016
vfs_print_message (_("shell: Reading directory %s..."), remote_path);
10171017

1018-
dir->timestamp = g_get_monotonic_time () + shell_directory_timeout * G_USEC_PER_SEC;
1018+
dir->timestamp = g_get_monotonic_time () + ((gint64)shell_directory_timeout * G_USEC_PER_SEC);
10191019

10201020
quoted_path = str_shell_escape (remote_path);
10211021
(void) shell_command_v (me, super, NONE, SHELL_SUPER (super)->scr_ls, "SHELL_FILENAME=%s;\n",

mcwin32/config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,17 @@ const char * mc_EXTHELPERSDIR(void);
8181
#define EXTHELPERSDIR mc_EXTHELPERSDIR() /* ???, 4.8.7 */
8282

8383
extern void WIN32_Setup(void);
84+
extern void WIN32_HeapInit(void);
85+
extern int WIN32_HeapCheck(void);
8486

8587
extern FILE * win32_popen(const char *cmd, const char *mode);
8688
extern int win32_pclose(FILE *file);
8789
extern void win32_ptrace(void);
8890
extern int win32_perror(int error, const char *msg);
8991

92+
extern void mc_setenv(const char *name, const char *value, int overwrite);
93+
extern void mc_setpathenv(const char *name, const char *value, int overwrite, int quote_ws);
94+
9095
#if !defined(popen)
9196
#define popen(__cmd,__mode) win32_popen(__cmd, __mode)
9297
#define pclose(__file) win32_pclose(__file)
@@ -191,3 +196,4 @@ extern void tty_set_title(const char *title);
191196
#define PROMOTED_MODE_T int
192197

193198
#endif /*CONFIG_H_INCLUDED*/
199+

mcwin32/libglib/.cvsignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
glib-2.*
2-
*.org
2+
*.org*
33
.unpacked.*
44
Makefile
55
*.err

mcwin32/libglib/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
glib-2.*/
2-
*.org
2+
*.org*
33
.unpacked.*
44
Makefile
55
*.err

mcwin32/libglib/glib-2.54.3.tgz

270 Bytes
Binary file not shown.

mcwin32/libglib/glib-2.54.3.txt

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
Source: glib-2.54.3
3+
4+
o galloca.h
5+
6+
OWC:
7+
+ # if defined(__WATCOMC__)
8+
+ # include <malloc.h>
9+
| # elif defined(_MSC_VER) || defined(__DMC__)
10+
11+
o gtypes.h:
12+
13+
OWC:
14+
+ #if defined(__WATCOMC__)
15+
+ # define GLIB_VAR extern __declspec(dllexport) /* remove multiple definition warnings */
16+
+ #else
17+
# define GLIB_VAR __declspec(dllexport)
18+
+ #endif
19+
20+
o gatomic.c
21+
22+
OWC: ATOMIC_CAST()
23+
24+
o genviron.c
25+
26+
OWC: _wsetenv() replacement of _wputenv()
27+
28+
+ #if defined(__WATCOMC__)
29+
+ wchar_t *wname, *wvalue;
30+
+ #else
31+
wchar_t *wname, *wvalue, *wassignment;
32+
gchar *tem;
33+
+ #endif
34+
35+
and
36+
37+
+ #if defined(__WATCOMC__)
38+
+ _wsetenv (wname, wvalue, 1 /*overwrite*/);
39+
+ #else
40+
tem = g_strconcat (variable, "=", value, NULL);
41+
wassignment = g_utf8_to_utf16 (tem, -1, NULL, NULL, NULL);
42+
g_free (tem);
43+
44+
_wputenv (wassignment);
45+
g_free (wassignment);
46+
+ #endif
47+
48+
o gthread-deprecated.c:
49+
50+
OWC: structure initialisation
51+
52+
o grand.c:
53+
54+
OWC: #pragma message() replacement of #warning
55+
56+
o gstdio.c:
57+
58+
OWC:
59+
#if (defined (__MINGW64_VERSION_MAJOR) || defined (_MSC_VER)) && !defined(_WIN64) && \
60+
+ !defined(__WATCOMC__)
61+
#undef _wstat
62+
#define _wstat _wstat32
63+
64+
o gwin32.c:
65+
66+
OWC:
67+
+ #if defined(__WATCOMC__) /* missing from OCW 1.9 DSK */
68+
+ typedef struct _OSVERSIONINFOEXW *PRTL_OSVERSIONINFOEXW;
69+
+ #endif //__WATCOMC__
70+
71+
+ #if defined(__WATCOMC__) && !defined(WC_NO_BEST_FIT_CHARS)
72+
+ #define WC_NO_BEST_FIT_CHARS 0x00000400 // do not use best fit chars
73+
+ #endif
74+
75+
o win_iconv.c:
76+
77+
+ #if defined(__WATCOMC__)
78+
+ static int * _errno(void)
79+
+ {
80+
+ return __get_errno_ptr();
81+
+ }
82+
+ #endif
83+

mcwin32/libw32/w32_dir.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <edidentifier.h>
2-
__CIDENT_RCSID(gr_w32_dir_c, "$Id: w32_dir.c,v 1.27 2025/03/06 16:59:46 cvsuser Exp $")
2+
__CIDENT_RCSID(gr_w32_dir_c, "$Id: w32_dir.c,v 1.28 2025/03/20 17:22:45 cvsuser Exp $")
33

44
/* -*- mode: c; indent-width: 4; -*- */
55
/*
@@ -764,8 +764,8 @@ w32_expandlinkA(const char *name, char *buf, size_t buflen, unsigned flags)
764764
memcpy(t_name, name, length + 1 /*nul*/);
765765

766766
for (cursor = t_name + length, end = cursor; --cursor >= t_name;) {
767-
if ('.' == *cursor) { // extension
768-
if (1 == ++dots) { // last/trailing
767+
if ('.' == *cursor) { // extension
768+
if (1 == ++dots) { // last/trailing
769769
if (0 == w32_io_strnicmp(cursor, ".lnk", 4) && (cursor + 4) == end) {
770770
//
771771
// <shortcut>.lnk
@@ -779,13 +779,13 @@ w32_expandlinkA(const char *name, char *buf, size_t buflen, unsigned flags)
779779

780780
if (flags & (term ? SHORTCUT_COMPONENT : SHORTCUT_TRAILING)) {
781781

782-
*end = 0; // remove trailing component.
782+
*end = 0; // remove trailing component.
783783
if ((t_ret = w32_readlinkA(t_name, buf, buflen)) > 0) {
784784
if (buflen > (t_ret + trailing)) {
785785
if (trailing) { // appending trailing component(s).
786786
*end = term, memcpy(buf + t_ret, end, trailing + 1 /*nul*/);
787787
}
788-
ret = 1; // success.
788+
ret = 1; // success.
789789
}
790790
}
791791
}
@@ -794,7 +794,7 @@ w32_expandlinkA(const char *name, char *buf, size_t buflen, unsigned flags)
794794
}
795795

796796
} else if ('/' == *cursor || '\\' == *cursor) {
797-
end = cursor; // new component.
797+
end = cursor; // new component.
798798
dots = 0;
799799
}
800800
}
@@ -822,8 +822,8 @@ w32_expandlinkW(const wchar_t *name, wchar_t *buf, size_t buflen, unsigned flags
822822
wmemcpy(t_name, name, length + 1 /*nul*/);
823823

824824
for (cursor = t_name + length, end = cursor; --cursor >= t_name;) {
825-
if ('.' == *cursor) { // extension
826-
if (1 == ++dots) { // last/trailing
825+
if ('.' == *cursor) { // extension
826+
if (1 == ++dots) { // last/trailing
827827
if (0 == w32_io_wstrnicmp(cursor, ".lnk", 4) && (cursor + 4) == end) {
828828
//
829829
// <shortcut>.lnk
@@ -837,13 +837,13 @@ w32_expandlinkW(const wchar_t *name, wchar_t *buf, size_t buflen, unsigned flags
837837

838838
if (flags & (term ? SHORTCUT_COMPONENT : SHORTCUT_TRAILING)) {
839839

840-
*end = 0; // remove trailing component.
840+
*end = 0; // remove trailing component.
841841
if ((t_ret = w32_readlinkW(t_name, buf, buflen)) > 0) {
842842
if (buflen > (t_ret + trailing)) {
843843
if (trailing) { // appending trailing component(s).
844844
*end = term, wmemcpy(buf + t_ret, end, trailing + 1 /*nul*/);
845845
}
846-
ret = 1; // success.
846+
ret = 1; // success.
847847
}
848848
}
849849
}
@@ -852,7 +852,7 @@ w32_expandlinkW(const wchar_t *name, wchar_t *buf, size_t buflen, unsigned flags
852852
}
853853

854854
} else if ('/' == *cursor || '\\' == *cursor) {
855-
end = cursor; // new component.
855+
end = cursor; // new component.
856856
dots = 0;
857857
}
858858
}

mcwin32/libw32/w32_sysconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <edidentifier.h>
2-
__CIDENT_RCSID(gr_w32_sysconf_c,"$Id: w32_sysconf.c,v 1.4 2025/03/08 16:40:00 cvsuser Exp $")
2+
__CIDENT_RCSID(gr_w32_sysconf_c,"$Id: w32_sysconf.c,v 1.5 2025/03/20 17:23:09 cvsuser Exp $")
33

44
/* -*- mode: c; indent-width: 4; -*- */
55
/*

0 commit comments

Comments
 (0)