Skip to content

Commit cfa3a1b

Browse files
kbleesdscho
authored andcommitted
mingw: factor out Windows specific environment setup
Signed-off-by: Karsten Blees <[email protected]>
1 parent b8a1e01 commit cfa3a1b

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

compat/mingw.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,22 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen)
20932093
return -1;
20942094
}
20952095

2096+
static void setup_windows_environment()
2097+
{
2098+
/* on Windows it is TMP and TEMP */
2099+
if (!getenv("TMPDIR")) {
2100+
const char *tmp = getenv("TMP");
2101+
if (!tmp)
2102+
tmp = getenv("TEMP");
2103+
if (tmp)
2104+
setenv("TMPDIR", tmp, 1);
2105+
}
2106+
2107+
/* simulate TERM to enable auto-color (see color.c) */
2108+
if (!getenv("TERM"))
2109+
setenv("TERM", "cygwin", 1);
2110+
}
2111+
20962112
/*
20972113
* Disable MSVCRT command line wildcard expansion (__getmainargs called from
20982114
* mingw startup code, see init.c in mingw runtime).
@@ -2189,19 +2205,7 @@ void mingw_startup()
21892205
qsort(environ, i, sizeof(char*), compareenv);
21902206

21912207
/* fix Windows specific environment settings */
2192-
2193-
/* on Windows it is TMP and TEMP */
2194-
if (!mingw_getenv("TMPDIR")) {
2195-
const char *tmp = mingw_getenv("TMP");
2196-
if (!tmp)
2197-
tmp = mingw_getenv("TEMP");
2198-
if (tmp)
2199-
setenv("TMPDIR", tmp, 1);
2200-
}
2201-
2202-
/* simulate TERM to enable auto-color (see color.c) */
2203-
if (!getenv("TERM"))
2204-
setenv("TERM", "cygwin", 1);
2208+
setup_windows_environment();
22052209

22062210
/*
22072211
* Avoid a segmentation fault when cURL tries to set the CHARSET

0 commit comments

Comments
 (0)