diff options
author | DJ Delorie <dj@redhat.com> | 2000-10-19 00:45:39 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2000-10-19 00:45:39 +0000 |
commit | 6e8f36bc43a54e6d6d21528acfe6f92d07781a9d (patch) | |
tree | 0fd61de3446c5bef3f82bed4c4663c9ec9f0e219 /winsup | |
parent | b8cb783f28eedbc327ca0d9bc4ebde6227d9d9e1 (diff) | |
download | newlib-6e8f36bc43a54e6d6d21528acfe6f92d07781a9d.zip newlib-6e8f36bc43a54e6d6d21528acfe6f92d07781a9d.tar.gz newlib-6e8f36bc43a54e6d6d21528acfe6f92d07781a9d.tar.bz2 |
* dcrt0.cc (dll_crt0_1): init cygcwd before forkee branch
* environ.cc (conv_start_chars): Cache a table of "first
characters" for environment variables needing conversion.
(getwinenv): Use it.
(environ_init): Create it, also check first chars for TERM and
CYGWIN.
* path.cc: Use lookup table for case insensitive comparisons.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 12 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/environ.cc | 22 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 25 |
4 files changed, 57 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4214ab7..88bf7e8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2000-10-18 DJ Delorie <dj@redhat.com> + + * dcrt0.cc (dll_crt0_1): init cygcwd before forkee branch + + * environ.cc (conv_start_chars): Cache a table of "first + characters" for environment variables needing conversion. + (getwinenv): Use it. + (environ_init): Create it, also check first chars for TERM and + CYGWIN. + + * path.cc: Use lookup table for case insensitive comparisons. + Wed Oct 18 00:48:49 2000 Christopher Faylor <cgf@cygnus.com> * exceptions.cc (call_handler): Make signal pending if sigsave.sig is diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index bba2425..fa13cf1 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -739,6 +739,8 @@ dll_crt0_1 () instead of each time a file is opened. */ set_process_privileges (); + cygcwd.init (); + cygbench ("pre-forkee"); if (user_data->forkee) @@ -759,8 +761,6 @@ dll_crt0_1 () longjmp (fork_info->jmp, fork_info->cygpid); } - cygcwd.init (); - /* Initialize our process table entry. */ pinfo_init (envp, envc); diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 31f87ad..b93d7e6 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -61,6 +61,8 @@ static win_env conv_envvars[] = {NULL, 0, NULL, NULL, NULL, NULL, 0, 0} }; +static unsigned char conv_start_chars[256] = {0}; + void win_env::add_cache (const char *in_posix, const char *in_native) { @@ -91,6 +93,9 @@ win_env::add_cache (const char *in_posix, const char *in_native) win_env * __stdcall getwinenv (const char *env, const char *in_posix) { + if (!conv_start_chars[(unsigned char)*env]) + return NULL; + for (int i = 0; conv_envvars[i].name != NULL; i++) if (strncasematch (env, conv_envvars[i].name, conv_envvars[i].namelen)) { @@ -528,6 +533,17 @@ environ_init (char **envp, int envc) bool envp_passed_in; static char cygterm[] = "TERM=cygwin"; + static int initted = 0; + if (!initted) + { + for (int i = 0; conv_envvars[i].name != NULL; i++) + { + conv_start_chars[tolower(conv_envvars[i].name[0])] = 1; + conv_start_chars[toupper(conv_envvars[i].name[0])] = 1; + } + initted = 1; + } + regopt ("default"); if (myself->progname[0]) regopt (myself->progname); @@ -571,11 +587,11 @@ environ_init (char **envp, int envc) eq = strchr (newp, '\0'); if (!parent_alive) ucenv (newp, eq); - if (strncmp (newp, "TERM=", 5) == 0) + if (*newp == 'T' && strncmp (newp, "TERM=", 5) == 0) sawTERM = 1; - if (strncmp (newp, "CYGWIN=", sizeof("CYGWIN=") - 1) == 0) + if (*newp == 'C' && strncmp (newp, "CYGWIN=", sizeof("CYGWIN=") - 1) == 0) parse_options (newp + sizeof("CYGWIN=") - 1); - if (*eq) + if (*eq && conv_start_chars[(unsigned char)envp[i][0]]) posify (envp + i, *++eq ? eq : --eq); debug_printf ("%s", envp[i]); } diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 63a8efd..b490399 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2764,14 +2764,37 @@ cygwin_split_path (const char *path, char *dir, char *file) /********************** String Helper Functions ************************/ +static char case_folded[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, '!', '"', '#', '$', '%', '&', 39, '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', + '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', 92, ']', '^', '_', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 127, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 +}; + #define CHXOR ('a' ^ 'A') -#define ch_case_eq(ch1, ch2) \ +#define old_ch_case_eq(ch1, ch2) \ ({ \ unsigned char x; \ !((x = ((unsigned char)ch1 ^ (unsigned char)ch2)) && \ (x != CHXOR || !isalpha (ch1))); \ }) +// This is about 10% faster than the above logic, on average +#define ch_case_eq(ch1, ch2) (case_folded[(unsigned char)(ch1)] \ + == case_folded[(unsigned char)(ch2)]) + /* Return TRUE if two strings match up to length n */ extern "C" int __stdcall strncasematch (const char *s1, const char *s2, size_t n) |