From 5bb41d641c4658b44e9a8a7047498a028cdc8bb1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 8 Jan 2017 15:57:31 -0800 Subject: Remove env var translation; PATH semicolon separated. * winsup/cygwin/environ.cc (conv_envvars): Static array removed. (conv_start_chars): Likewise. (getwinenv): Function gutted to just return NULL. No environment vars require conversion. (match_first_char): Static function removed. (build_env): Removed logic for eliminating those variables that require donversion, since there are no such variables and the needed functions and arrays are gone. * winsup/cygwin/environ.cc (find_exec): Recognize semicolon as PATH separator. --- winsup/cygwin/environ.cc | 105 ++++------------------------------------------- winsup/cygwin/spawn.cc | 3 +- 2 files changed, 9 insertions(+), 99 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; - } - } } } diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 9ed211fac..a064c3cee 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -130,7 +130,8 @@ find_exec (const char *name, path_conv& buf, const char *search, tmp_path = tp.c_get (); do { - char *eotmp = strccpy (tmp_path, &path, ':'); + /* Cygnal: semicolon delim, not colon. */ + char *eotmp = strccpy (tmp_path, &path, ';'); /* An empty path or '.' means the current directory, but we've already tried that. */ if ((opt & FE_CWD) && (tmp_path[0] == '\0' -- cgit v1.2.3