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:
authorChristopher Faylor <me@cgf.cx>2000-07-17 00:06:11 +0400
committerChristopher Faylor <me@cgf.cx>2000-07-17 00:06:11 +0400
commit0763ee9d8324d1a0c1a26057e90719f21a13e826 (patch)
tree07a632e5bb42d0861cb409860f8014246229836f
parentb4e59f5f1419800d7a2248d3721a9db88e80d4d8 (diff)
* environ.cc: Use new definition of "environ" throughout.
(environ_init): Explicitly initialize __cygwin_environ. (cur_environ): New function. Detects when user has updated their environment. * exec.cc: Use 'environ' define throughout rather than __cygwin_environ. * spawn.cc: Ditto. * winsup.h: Declare cur_environ, main_environ, environ.
-rw-r--r--winsup/cygwin/ChangeLog10
-rw-r--r--winsup/cygwin/environ.cc22
-rw-r--r--winsup/cygwin/exec.cc12
-rw-r--r--winsup/cygwin/spawn.cc11
-rw-r--r--winsup/cygwin/winsup.h4
5 files changed, 42 insertions, 17 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index b1d158221..3a81a51ac 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,13 @@
+Sun Jul 16 16:03:00 2000 Christopher Faylor <cgf@cygnus.com>
+
+ * environ.cc: Use new definition of "environ" throughout.
+ (environ_init): Explicitly initialize __cygwin_environ.
+ (cur_environ): New function. Detects when user has updated
+ their environment.
+ * exec.cc: Use 'environ' define throughout rather than __cygwin_environ.
+ * spawn.cc: Ditto.
+ * winsup.h: Declare cur_environ, main_environ, environ.
+
Sun Jul 16 13:23:04 2000 Christopher Faylor <cgf@cygnus.com>
* acconfig.h: Add support for NEWVFORK.
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;
+}
diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc
index 0ba3ead6f..d54937850 100644
--- a/winsup/cygwin/exec.cc
+++ b/winsup/cygwin/exec.cc
@@ -44,7 +44,7 @@ execl (const char *path, const char *arg0, ...)
while (argv[i++] != NULL);
va_end (args);
MALLOC_CHECK;
- return _execve (path, (char * const *) argv, __cygwin_environ);
+ return _execve (path, (char * const *) argv, environ);
}
extern "C"
@@ -52,7 +52,7 @@ int
execv (const char *path, char * const *argv)
{
MALLOC_CHECK;
- return _execve (path, (char * const *) argv, __cygwin_environ);
+ return _execve (path, (char * const *) argv, environ);
}
/* the same as a standard exec() calls family, but with NT security support */
@@ -85,7 +85,7 @@ sexecl (HANDLE hToken, const char *path, const char *arg0, ...)
va_end (args);
MALLOC_CHECK;
- return sexecve (hToken, path, (char * const *) argv, __cygwin_environ);
+ return sexecve (hToken, path, (char * const *) argv, environ);
}
extern "C"
@@ -131,7 +131,7 @@ sexeclp (HANDLE hToken, const char *path, const char *arg0, ...)
va_end (args);
MALLOC_CHECK;
- return sexecvpe (hToken, path, (const char * const *) argv, __cygwin_environ);
+ return sexecvpe (hToken, path, (const char * const *) argv, environ);
}
extern "C"
@@ -163,7 +163,7 @@ int
sexecv (HANDLE hToken, const char *path, const char * const *argv)
{
MALLOC_CHECK;
- return sexecve (hToken, path, argv, __cygwin_environ);
+ return sexecve (hToken, path, argv, environ);
}
extern "C"
@@ -171,7 +171,7 @@ int
sexecp (HANDLE hToken, const char *path, const char * const *argv)
{
MALLOC_CHECK;
- return sexecvpe (hToken, path, argv, __cygwin_environ);
+ return sexecvpe (hToken, path, argv, environ);
}
/*
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index af284f8ee..ca22436fd 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -412,7 +412,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
else
{
one_line.add ("\"", 1);
- for (0; p = strpbrk (a, "\"\\"); a = ++p)
+ for (; (p = strpbrk (a, "\"\\")); a = ++p)
{
one_line.add (a, p - a);
if (*p == '\\' || *p == '"')
@@ -894,8 +894,7 @@ spawnl (int mode, const char *path, const char *arg0, ...)
va_end (args);
- return _spawnve (NULL, mode, path, (char * const *) argv,
- __cygwin_environ);
+ return _spawnve (NULL, mode, path, (char * const *) argv, environ);
}
extern "C"
@@ -940,7 +939,7 @@ spawnlp (int mode, const char *path, const char *arg0, ...)
va_end (args);
- return spawnvpe (mode, path, (char * const *) argv, __cygwin_environ);
+ return spawnvpe (mode, path, (char * const *) argv, environ);
}
extern "C"
@@ -970,7 +969,7 @@ extern "C"
int
spawnv (int mode, const char *path, const char * const *argv)
{
- return _spawnve (NULL, mode, path, argv, __cygwin_environ);
+ return _spawnve (NULL, mode, path, argv, environ);
}
extern "C"
@@ -985,7 +984,7 @@ extern "C"
int
spawnvp (int mode, const char *path, const char * const *argv)
{
- return spawnvpe (mode, path, argv, __cygwin_environ);
+ return spawnvpe (mode, path, argv, environ);
}
extern "C"
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 5a1ff2ff1..4141aa74c 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -477,7 +477,9 @@ win_env * __stdcall getwinenv (const char *name, const char *posix = NULL);
void __stdcall update_envptrs ();
char * __stdcall winenv (const char * const *, int);
-extern char **__cygwin_environ;
+extern char **__cygwin_environ, ***main_environ;
+extern char __stdcall **cur_environ ();
+#define environ (cur_environ ())
/* The title on program start. */
extern char *old_title;