diff options
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r-- | winsup/cygwin/environ.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 716af8547..4aa5ad75b 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -13,8 +13,6 @@ details. */ #include <ctype.h> #include <fcntl.h> -#define environ __cygwin_environ - extern BOOL allow_glob; extern BOOL allow_ntea; extern BOOL strip_title_path; @@ -228,7 +226,7 @@ setenv (const char *name, const char *value, int rewrite) for (P = environ, cnt = 0; *P; ++P, ++cnt) ; - environ = (char **) realloc ((char *) environ, + __cygwin_environ = (char **) realloc ((char *) environ, (size_t) (sizeof (char *) * (cnt + 2))); if (!environ) return -1; @@ -503,7 +501,7 @@ environ_init (int already_posix) if (!sawTERM) envp[i++] = strdup ("TERM=cygwin"); envp[i] = NULL; - environ = envp; + __cygwin_environ = envp; update_envptrs (); FreeEnvironmentStringsA ((char *) rawenv); parse_options (NULL); @@ -580,3 +578,19 @@ winenv (const char * const *envp, int keep_posix) return envblock; } + +/* This idiocy is necessary because the early implementers of cygwin + did not seem to know about importing data variables from the DLL. + So, we have to synchronize cygwin's idea of the environment with the + main program's with each reference to the environment. */ +char ** __stdcall +cur_environ () +{ + if (*main_environ != __cygwin_environ) + { + __cygwin_environ = *main_environ; + update_envptrs (); + } + + return __cygwin_environ; +} |