* 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.
This commit is contained in:
parent
b4e59f5f14
commit
0763ee9d83
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user