Skip to content

Commit 1236744

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

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
@@ -2226,6 +2226,22 @@ int handle_long_path(wchar_t *path, int len, int max_path, int expand)
22262226
}
22272227
}
22282228

2229+
static void setup_windows_environment()
2230+
{
2231+
/* on Windows it is TMP and TEMP */
2232+
if (!getenv("TMPDIR")) {
2233+
const char *tmp = getenv("TMP");
2234+
if (!tmp)
2235+
tmp = getenv("TEMP");
2236+
if (tmp)
2237+
setenv("TMPDIR", tmp, 1);
2238+
}
2239+
2240+
/* simulate TERM to enable auto-color (see color.c) */
2241+
if (!getenv("TERM"))
2242+
setenv("TERM", "cygwin", 1);
2243+
}
2244+
22292245
/*
22302246
* Disable MSVCRT command line wildcard expansion (__getmainargs called from
22312247
* mingw startup code, see init.c in mingw runtime).
@@ -2322,19 +2338,7 @@ void mingw_startup()
23222338
qsort(environ, i, sizeof(char*), compareenv);
23232339

23242340
/* fix Windows specific environment settings */
2325-
2326-
/* on Windows it is TMP and TEMP */
2327-
if (!mingw_getenv("TMPDIR")) {
2328-
const char *tmp = mingw_getenv("TMP");
2329-
if (!tmp)
2330-
tmp = mingw_getenv("TEMP");
2331-
if (tmp)
2332-
setenv("TMPDIR", tmp, 1);
2333-
}
2334-
2335-
/* simulate TERM to enable auto-color (see color.c) */
2336-
if (!getenv("TERM"))
2337-
setenv("TERM", "cygwin", 1);
2341+
setup_windows_environment();
23382342

23392343
/*
23402344
* Avoid a segmentation fault when cURL tries to set the CHARSET

0 commit comments

Comments
 (0)