mingw: factor out Windows specific environment setup

Signed-off-by: Karsten Blees <blees@dcon.de>
This commit is contained in:
Karsten Blees
2015-04-02 19:37:08 +02:00
committed by Johannes Schindelin
parent 16891aa495
commit 7fe262b99e

View File

@@ -2209,6 +2209,22 @@ int handle_long_path(wchar_t *path, int len, int max_path, int expand)
}
}
static void setup_windows_environment()
{
/* on Windows it is TMP and TEMP */
if (!getenv("TMPDIR")) {
const char *tmp = getenv("TMP");
if (!tmp)
tmp = getenv("TEMP");
if (tmp)
setenv("TMPDIR", tmp, 1);
}
/* simulate TERM to enable auto-color (see color.c) */
if (!getenv("TERM"))
setenv("TERM", "cygwin", 1);
}
/*
* Disable MSVCRT command line wildcard expansion (__getmainargs called from
* mingw startup code, see init.c in mingw runtime).
@@ -2305,19 +2321,7 @@ void mingw_startup()
qsort(environ, i, sizeof(char*), compareenv);
/* fix Windows specific environment settings */
/* on Windows it is TMP and TEMP */
if (!mingw_getenv("TMPDIR")) {
const char *tmp = mingw_getenv("TMP");
if (!tmp)
tmp = mingw_getenv("TEMP");
if (tmp)
setenv("TMPDIR", tmp, 1);
}
/* simulate TERM to enable auto-color (see color.c) */
if (!getenv("TERM"))
setenv("TERM", "cygwin", 1);
setup_windows_environment();
/*
* Avoid a segmentation fault when cURL tries to set the CHARSET