Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-10-19 23:47:15 +0400
committerCorinna Vinschen <corinna@vinschen.de>2009-10-19 23:47:15 +0400
commit8d648dc5559eb0b9a35c8e064c674cfc720f88cb (patch)
tree94652e1d157aa33bd2094cbfda76e3b3f0701fa2 /winsup/cygwin/syscalls.cc
parent9d52f5c21cfc39edba3f0b4ba841710838bb913e (diff)
* syscalls.cc (internal_setlocale): Only convert $PATH if there is a
$PATH.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index aa112c493..d9c9d596f 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -4242,13 +4242,17 @@ internal_setlocale ()
/* FIXME: It could be necessary to convert the entire environment,
not just PATH. */
tmp_pathbuf tp;
- wchar_t *w_path, *w_cwd;
+ char *path = getenv ("PATH");
+ wchar_t *w_path = NULL, *w_cwd;
debug_printf ("Cygwin charset changed from %s to %s",
cygheap->locale.charset, __locale_charset ());
- /* Fetch CWD and PATH and convert to wchar_t in previous charset. */
- w_path = tp.w_get ();
- sys_mbstowcs (w_path, 32768, getenv ("PATH"));
+ /* Fetch PATH and CWD and convert to wchar_t in previous charset. */
+ if (path && *path) /* $PATH can be potentially unset. */
+ {
+ w_path = tp.w_get ();
+ sys_mbstowcs (w_path, 32768, path);
+ }
w_cwd = tp.w_get ();
cwdstuff::cwd_lock.acquire ();
sys_mbstowcs (w_cwd, 32768, cygheap->cwd.get_posix ());
@@ -4259,9 +4263,12 @@ internal_setlocale ()
/* Restore CWD and PATH in new charset. */
cygheap->cwd.reset_posix (w_cwd);
cwdstuff::cwd_lock.release ();
- char *c_path = tp.c_get ();
- sys_wcstombs (c_path, 32768, w_path);
- setenv ("PATH", c_path, 1);
+ if (w_path)
+ {
+ char *c_path = tp.c_get ();
+ sys_wcstombs (c_path, 32768, w_path);
+ setenv ("PATH", c_path, 1);
+ }
}
/* Called from dll_crt0_1, before calling the application's main().