diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-11-13 22:37:21 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-13 22:37:21 +0900 |
commit | 0474cd19ef55c02d026e9a5b75c086bf8afbad40 (patch) | |
tree | 0bbf5012dcd7137175dcdb0396ba2837b07f87d1 /compat/mingw.h | |
parent | 6c268fdda9dcc421e2bee1ce76496d3e9f96397f (diff) | |
parent | fe21c6b285df4088f9685d5deed425064367ea24 (diff) | |
download | git-0474cd19ef55c02d026e9a5b75c086bf8afbad40.tar.gz |
Merge branch 'js/mingw-utf8-env'
Windows fix.
* js/mingw-utf8-env:
mingw: reencode environment variables on the fly (UTF-16 <-> UTF-8)
t7800: fix quoting
Diffstat (limited to 'compat/mingw.h')
-rw-r--r-- | compat/mingw.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/compat/mingw.h b/compat/mingw.h index 2f1f8e3e05..8c24ddaa3e 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -260,11 +260,35 @@ char *mingw_mktemp(char *template); char *mingw_getcwd(char *pointer, int len); #define getcwd mingw_getcwd +#ifdef NO_UNSETENV +#error "NO_UNSETENV is incompatible with the Windows-specific startup code!" +#endif + +/* + * We bind *env() routines (even the mingw_ ones) to private mingw_ versions. + * These talk to the CRT using UNICODE/wchar_t, but maintain the original + * narrow-char API. + * + * Note that the MSCRT maintains both ANSI (getenv()) and UNICODE (_wgetenv()) + * routines and stores both versions of each environment variable in parallel + * (and secretly updates both when you set one or the other), but it uses CP_ACP + * to do the conversion rather than CP_UTF8. + * + * Since everything in the git code base is UTF8, we define the mingw_ routines + * to access the CRT using the UNICODE routines and manually convert them to + * UTF8. This also avoids round-trip problems. + * + * This also helps with our linkage, since "_wenviron" is publicly exported + * from the CRT. But to access "_environ" we would have to statically link + * to the CRT (/MT). + * + * We require NO_SETENV (and let gitsetenv() call our mingw_putenv). + */ +#define getenv mingw_getenv +#define putenv mingw_putenv +#define unsetenv mingw_putenv char *mingw_getenv(const char *name); -#define getenv mingw_getenv -int mingw_putenv(const char *namevalue); -#define putenv mingw_putenv -#define unsetenv mingw_putenv +int mingw_putenv(const char *name); int mingw_gethostname(char *host, int namelen); #define gethostname mingw_gethostname |