diff options
author | Christopher Faylor <me@cgf.cx> | 2006-02-10 20:22:34 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2006-02-10 20:22:34 +0300 |
commit | 9a08fd5a50ae8a34abe8db0b8983d86d74491665 (patch) | |
tree | fe2c6e75e31b670d1e740fd2d7f502dae0e0b2f7 /winsup/cygwin/external.cc | |
parent | 2bf61bfe9b48cedfa558483f08891ede634b4dce (diff) |
* external.cc (sync_winenv): Rename from "setup_winenv". Use same mechanism as
spawn to determine environment variables which should be converted back to
windows form.
(cygwin_internal): Reflect setup_winenv -> sync_winenv name change.
* include/sys/cygwin.h: Ditto.
Diffstat (limited to 'winsup/cygwin/external.cc')
-rw-r--r-- | winsup/cygwin/external.cc | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 3e593e418..71b790c50 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -137,21 +137,33 @@ check_ntsec (const char *filename) /* Copy cygwin environment variables to the Windows environment. */ static void -setup_winenv () +sync_winenv () { - char **envp = __cygwin_environ; - char *var, *val; - char dummy; + int unused_envc; + char *envblock = NULL; + char **envp = build_env (__cygwin_environ, envblock, unused_envc, false); + char *p = envblock; - while (envp && *envp) + if (envp) { - var = strdup (*envp++); - val = strchr (var, '='); - *val++ = '\0'; - if (!GetEnvironmentVariable (var, &dummy, 1)) - SetEnvironmentVariable (var, val); - free (var); + for (char **e = envp; *e; e++) + cfree (*e); + cfree (envp); } + if (!p) + return; + while (*p) + { + char *eq = strchr (p, '='); + if (eq) + { + *eq = '\0'; + SetEnvironmentVariable (p, ++eq); + p = eq; + } + p = strchr (p, '\0') + 1; + } + free (envblock); } extern "C" unsigned long @@ -333,8 +345,8 @@ cygwin_internal (cygwin_getinfo_types t, ...) error_start_init (va_arg (arg, const char *)); try_to_debug (); break; - case CW_SETUP_WINENV: - setup_winenv (); + case CW_SYNC_WINENV: + sync_winenv (); return 0; default: break; |