* environ.cc (create_upcaseenv): Delete.

(ucenv): Don't honor create_upcaseenv.
(environ_init): Remove early retrieval of CYGWIN environment variable.  Change
comment to reflect new behavior.
This commit is contained in:
Christopher Faylor 2011-06-10 15:06:13 +00:00
parent b6510ccdcd
commit 1516a0b4d7
2 changed files with 23 additions and 44 deletions

View File

@ -1,3 +1,10 @@
2011-06-10 Christopher Faylor <me.cygwin2011@cgf.cx>
* environ.cc (create_upcaseenv): Delete.
(ucenv): Don't honor create_upcaseenv.
(environ_init): Remove early retrieval of CYGWIN environment variable.
Change comment to reflect new behavior.
2011-06-09 Christopher Faylor <me.cygwin2011@cgf.cx> 2011-06-09 Christopher Faylor <me.cygwin2011@cgf.cx>
* child_info.h (CURR_CHILD_INFO_MAGIC): Reset. * child_info.h (CURR_CHILD_INFO_MAGIC): Reset.

View File

@ -36,7 +36,6 @@ extern bool dos_file_warning;
extern bool ignore_case_with_glob; extern bool ignore_case_with_glob;
extern bool allow_winsymlinks; extern bool allow_winsymlinks;
bool reset_com = false; bool reset_com = false;
static bool create_upcaseenv = false;
static char **lastenviron; static char **lastenviron;
@ -124,7 +123,6 @@ static struct parse_thing
{"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}}, {"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}},
{"reset_com", {&reset_com}, justset, NULL, {{false}, {true}}}, {"reset_com", {&reset_com}, justset, NULL, {{false}, {true}}},
{"tty", {func: tty_is_gone}, isfunc, NULL, {{0}, {0}}}, {"tty", {func: tty_is_gone}, isfunc, NULL, {{0}, {0}}},
{"upcaseenv", {&create_upcaseenv}, justset, NULL, {{false}, {true}}},
{"winsymlinks", {&allow_winsymlinks}, justset, NULL, {{false}, {true}}}, {"winsymlinks", {&allow_winsymlinks}, justset, NULL, {{false}, {true}}},
{NULL, {0}, justset, 0, {{0}, {0}}} {NULL, {0}, justset, 0, {{0}, {0}}}
}; };
@ -661,41 +659,24 @@ static const char idx_arr[] = "ACHNOPSTW";
starts. */ starts. */
static const int start_at[] = { 0, 1, 4, 7, 8, 9, 16, 18, 22 }; static const int start_at[] = { 0, 1, 4, 7, 8, 9, 16, 18, 22 };
/* Turn environment variable part of a=b string into uppercase. /* Turn environment variable part of a=b string into uppercase - for some
Conditionally controlled by upcaseenv CYGWIN setting. */ environment variables only. */
static __inline__ void static __inline__ void
ucenv (char *p, const char *eq) ucenv (char *p, const char *eq)
{ {
if (create_upcaseenv) /* Hopefully as quickly as possible - only upper case specific set of important
{ Windows variables. */
/* Amazingly, NT has a case sensitive environment name list, char first = cyg_toupper (*p);
but only sometimes. const char *idx = strchr (idx_arr, first);
It's normal to have NT set your "Path" to something. if (idx)
Later, you set "PATH" to something else. This alters "Path". for (size_t i = start_at[idx - idx_arr];
But if you try and do a naive getenv on "PATH" you'll get nothing. i < RENV_SIZE && renv_arr[i].name[0] == first;
++i)
So we upper case the labels here to prevent confusion later but if (strncasematch (p, renv_arr[i].name, renv_arr[i].namelen))
we only do it for processes that are started by non-Cygwin programs. */ {
for (; p < eq; p++) strncpy (p, renv_arr[i].name, renv_arr[i].namelen);
if (islower (*p)) break;
*p = cyg_toupper (*p); }
}
else
{
/* Hopefully as quickly as possible - only upcase specific set of important
Windows variables. */
char first = cyg_toupper (*p);
const char *idx = strchr (idx_arr, first);
if (idx)
for (size_t i = start_at[idx - idx_arr];
i < RENV_SIZE && renv_arr[i].name[0] == first;
++i)
if (strncasematch (p, renv_arr[i].name, renv_arr[i].namelen))
{
strncpy (p, renv_arr[i].name, renv_arr[i].namelen);
break;
}
}
} }
/* Set options from the registry. */ /* Set options from the registry. */
@ -788,15 +769,6 @@ environ_init (char **envp, int envc)
/* Allocate space for environment + trailing NULL + CYGWIN env. */ /* Allocate space for environment + trailing NULL + CYGWIN env. */
lastenviron = envp = (char **) malloc ((4 + (envc = 100)) * sizeof (char *)); lastenviron = envp = (char **) malloc ((4 + (envc = 100)) * sizeof (char *));
/* We also need the CYGWIN variable early to know the value of the
CYGWIN=upcaseenv setting for the below loop. */
if ((i = GetEnvironmentVariableA ("CYGWIN", NULL, 0)))
{
char *buf = (char *) alloca (i);
GetEnvironmentVariableA ("CYGWIN", buf, i);
parse_options (buf);
}
rawenv = GetEnvironmentStringsW (); rawenv = GetEnvironmentStringsW ();
if (!rawenv) if (!rawenv)
{ {
@ -818,7 +790,7 @@ environ_init (char **envp, int envc)
if (*newp == '=') if (*newp == '=')
*newp = '!'; *newp = '!';
char *eq = strechr (newp, '='); char *eq = strechr (newp, '=');
ucenv (newp, eq); /* (possibly conditionally) uppercase env vars. */ ucenv (newp, eq); /* uppercase env vars which need it */
if (*newp == 'T' && strncmp (newp, "TERM=", 5) == 0) if (*newp == 'T' && strncmp (newp, "TERM=", 5) == 0)
sawTERM = 1; sawTERM = 1;
if (*eq && conv_start_chars[(unsigned char) envp[i][0]]) if (*eq && conv_start_chars[(unsigned char) envp[i][0]])