Win32: Unicode environment (incoming)
commitb71bd0720a95fad59f3d5d7694d993a8a3f62b3f
authorKarsten Blees <blees@dcon.de>
Mon, 25 Apr 2011 22:32:27 +0000 (25 23:32 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Thu, 5 Dec 2013 23:19:39 +0000 (5 23:19 +0000)
treed8c24fe3bbaf26df364f5fee5d9577c3411e0c39
parent0202e4e2c778f329f9dedf687f7e4669e1fdfad1
Win32: Unicode environment (incoming)

Convert environment from UTF-16 to UTF-8 on startup.

No changes to getenv() are necessary, as the MSVCRT version is implemented
on top of char **environ.

However, putenv / _wputenv from MSVCRT no longer work, for two reasons:
1. they try to keep environ, _wenviron and the Win32 process environment
in sync, using the default system encoding instead of UTF-8 to convert
between charsets
2. msysgit and MSVCRT use different allocators, memory allocated in git
cannot be freed by the CRT and vice versa

Implement mingw_putenv using the env_setenv helper function from the
environment merge code.

Note that in case of memory allocation failure, putenv now dies with error
message (due to xrealloc) instead of failing with ENOMEM. As git assumes
setenv / putenv to always succeed, this prevents it from continuing with
incorrect settings.

Signed-off-by: Karsten Blees <blees@dcon.de>
compat/mingw.c
compat/mingw.h