diff options
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r-- | winsup/cygwin/environ.cc | 105 |
1 files changed, 7 insertions, 98 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 7f7f9cb32..287114985 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -307,66 +307,8 @@ env_path_to_win32 (const void *posix, void *win32, size_t size) <= CYGWIN_VERSION_DLL_MALLOC_ENV) #define NL(x) x, (sizeof (x) - 1) -/* List of names which are converted from dos to unix - on the way in and back again on the way out. - - PATH needs to be here because CreateProcess uses it and gdb uses - CreateProcess. HOME is here because most shells use it and would be - confused by Windows style path names. */ -static win_env conv_envvars[] = - { - {NL ("PATH="), NULL, NULL, env_PATH_to_posix, env_plist_to_win32, true}, - {NL ("HOME="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, - {NL ("LD_LIBRARY_PATH="), NULL, NULL, - env_plist_to_posix, env_plist_to_win32, true}, - {NL ("TMPDIR="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, - {NL ("TMP="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, - {NL ("TEMP="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, - {NULL, 0, NULL, NULL, 0, 0} - }; #define WC ((unsigned char) 1) -/* Note: You *must* fill in this array setting the ordinal value of the first - character of the above environment variable names to 1. - This table is intended to speed up lookup of these variables. */ - -static const unsigned char conv_start_chars[256] = - { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -/* A B C D E F G */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 72 */ -/* H I J K L M N O */ - WC, 0, 0, 0, WC, 0, 0, 0, - /* 80 */ -/* P Q R S T U V W */ - WC, 0, 0, 0, WC, 0, 0, 0, - /* 88 */ -/* x Y Z */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 96 */ -/* a b c d e f g */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 104 */ -/* h i j k l m n o */ - WC, 0, 0, 0, WC, 0, 0, 0, - /* 112 */ -/* p q r s t u v w */ - WC, 0, 0, 0, WC, 0, 0, 0, - }; - -static inline char -match_first_char (const char *s, unsigned char m) -{ - return conv_start_chars[(unsigned) *s] & m; -} struct win_env& win_env::operator = (struct win_env& x) @@ -425,28 +367,10 @@ win_env::add_cache (const char *in_posix, const char *in_native) win_env * __reg3 getwinenv (const char *env, const char *in_posix, win_env *temp) { - if (!match_first_char (env, WC)) - return NULL; - - for (int i = 0; conv_envvars[i].name != NULL; i++) - if (strncmp (env, conv_envvars[i].name, conv_envvars[i].namelen) == 0) - { - win_env *we = conv_envvars + i; - const char *val; - if (!cur_environ () || !(val = in_posix ?: getenv (we->name))) - debug_printf ("can't set native for %s since no environ yet", - we->name); - else if (!we->posix || strcmp (val, we->posix) != 0) - { - if (temp) - { - *temp = *we; - we = temp; - } - we->add_cache (val); - } - return we; - } + /* in Cygnal, we don't do any of this. A native + * library should leave environment variables alone, + * passing them as-is to subordinate processes. + */ return NULL; } @@ -1049,10 +973,9 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, sys_wcstombs_alloc_no_path (&winenv[winnum], HEAP_NOTHEAP, var); } DestroyEnvironmentBlock (cwinenv); - /* Eliminate variables which are already available in envp, as well as - the small set of crucial variables needing POSIX conversion and - potentially collide. The windows env is sorted, so we can use - bsearch. We're doing this first step, so the following code doesn't + /* Eliminate variables which are already available in envp. + The windows env is sorted, so we can use bsearch. We're doing this + first step, so the following code doesn't allocate too much memory. */ if (winenv) { @@ -1071,20 +994,6 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, --winnum; } } - for (char **elem = winenv; *elem; elem++) - { - if (match_first_char (*elem, WC)) - for (int i = 0; conv_envvars[i].name != NULL; i++) - if (strncmp (*elem, conv_envvars[i].name, - conv_envvars[i].namelen) == 0) - { - free (*elem); - memmove (elem, elem + 1, - (winnum - (elem - winenv)) * sizeof *elem); - --winnum; - --elem; - } - } } } |