* string.h: Re-enable inline strcasematch and strncasematch

implementations and rename to ascii_strcasematch/ascii_strncasematch.
	* dcrt0.cc: Replace str[n]casematch with ascii_str[n]casematch where
	applicable.
	* environ.cc: Ditto.
	* fhandler_process.cc: Ditto.
	* hookapi.cc: Ditto.
	* path.cc: Ditto.
	* spawn.cc: Ditto.
	* strace.cc: Ditto.
	* syscalls.cc: Ditto.
	* uinfo.cc: Ditto.
	* winf.cc: Ditto.
This commit is contained in:
Corinna Vinschen 2008-02-01 12:37:51 +00:00
parent 1597484cb5
commit c69d873f31
12 changed files with 69 additions and 60 deletions

View File

@ -1,3 +1,19 @@
2008-02-01 Corinna Vinschen <corinna@vinschen.de>
* string.h: Re-enable inline strcasematch and strncasematch
implementations and rename to ascii_strcasematch/ascii_strncasematch.
* dcrt0.cc: Replace str[n]casematch with ascii_str[n]casematch where
applicable.
* environ.cc: Ditto.
* fhandler_process.cc: Ditto.
* hookapi.cc: Ditto.
* path.cc: Ditto.
* spawn.cc: Ditto.
* strace.cc: Ditto.
* syscalls.cc: Ditto.
* uinfo.cc: Ditto.
* winf.cc: Ditto.
2008-01-31 Corinna Vinschen <corinna@vinschen.de>
* dcrt0.cc (dll_crt0_1): Use GetCommandLineW and convert to current

View File

@ -892,7 +892,7 @@ dll_crt0_1 (void *)
if (__progname)
{
char *cp = strchr (__progname, '\0') - 4;
if (cp > __progname && strcasematch (cp, ".exe"))
if (cp > __progname && ascii_strcasematch (cp, ".exe"))
*cp = '\0';
}

View File

@ -459,7 +459,7 @@ glob_init (const char *buf)
allow_glob = false;
ignore_case_with_glob = false;
}
else if (strncasematch (buf, "ignorecase", 10))
else if (ascii_strncasematch (buf, "ignorecase", 10))
{
allow_glob = true;
ignore_case_with_glob = true;
@ -477,17 +477,17 @@ check_case_init (const char *buf)
if (!buf || !*buf)
return;
if (strncasematch (buf, "relax", 5))
if (ascii_strncasematch (buf, "relax", 5))
{
pcheck_case = PCHECK_RELAXED;
debug_printf ("File case checking set to RELAXED");
}
else if (strcasematch (buf, "adjust"))
else if (ascii_strcasematch (buf, "adjust"))
{
pcheck_case = PCHECK_ADJUST;
debug_printf ("File case checking set to ADJUST");
}
else if (strcasematch (buf, "strict"))
else if (ascii_strcasematch (buf, "strict"))
{
pcheck_case = PCHECK_STRICT;
debug_printf ("File case checking set to STRICT");
@ -519,11 +519,11 @@ codepage_init (const char *buf)
if (!buf || !*buf)
return;
if (strcasematch (buf, "oem"))
if (ascii_strcasematch (buf, "oem"))
current_codepage = oem_cp;
else if (strcasematch (buf, "ansi"))
else if (ascii_strcasematch (buf, "ansi"))
current_codepage = ansi_cp;
else if (strcasematch (buf, "utf8"))
else if (ascii_strcasematch (buf, "utf8"))
current_codepage = utf8_cp;
else
debug_printf ("Wrong codepage name: %s", buf);
@ -545,13 +545,13 @@ set_proc_retry (const char *buf)
static void
set_ntsec (const char *buf)
{
allow_ntsec = (buf && strcasematch (buf, "yes"));
allow_ntsec = (buf && ascii_strcasematch (buf, "yes"));
}
static void
set_smbntsec (const char *buf)
{
allow_smbntsec = (buf && strcasematch (buf, "yes"));
allow_smbntsec = (buf && ascii_strcasematch (buf, "yes"));
}
/* The structure below is used to set up an array which is used to
@ -636,7 +636,7 @@ parse_options (char *buf)
p = strtok_r (NULL, " \t", &lasts))
{
char *keyword_here = p;
if (!(istrue = !strncasematch (p, "no", 2)))
if (!(istrue = !ascii_strncasematch (p, "no", 2)))
p += 2;
else if (!(istrue = *p != '-'))
p++;
@ -648,7 +648,7 @@ parse_options (char *buf)
ch = 0;
for (parse_thing *k = known; k->name != NULL; k++)
if (strcasematch (p, k->name))
if (ascii_strcasematch (p, k->name))
{
switch (k->disposition)
{
@ -901,7 +901,7 @@ static NO_COPY spenv spenvs[] =
char *
spenv::retrieve (bool no_envblock, const char *const env)
{
if (env && !strncasematch (env, name, namelen))
if (env && !ascii_strncasematch (env, name, namelen))
return NULL;
debug_printf ("no_envblock %d", no_envblock);

View File

@ -456,7 +456,7 @@ fhandler_process::fill_filebuf ()
if (len > 4)
{
char *s = filebuf + len - 4;
if (strcasematch (s, ".exe"))
if (ascii_strcasematch (s, ".exe"))
*s = 0;
}
}
@ -618,7 +618,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
if (len > 4)
{
char *s = cmd + len - 4;
if (strcasematch (s, ".exe"))
if (ascii_strcasematch (s, ".exe"))
*s = 0;
}
}
@ -744,7 +744,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
if (len > 4)
{
char *s = cmd + len - 4;
if (strcasematch (s, ".exe"))
if (ascii_strcasematch (s, ".exe"))
*s = 0;
}
}

View File

@ -55,7 +55,7 @@ rvadelta (PIMAGE_NT_HEADERS pnt, DWORD import_rva)
for (int i = 0; i < pnt->FileHeader.NumberOfSections; i++)
if (section[i].VirtualAddress <= import_rva
&& (section[i].VirtualAddress + section[i].Misc.VirtualSize) > import_rva)
// if (strncasematch ((char *) section[i].Name, ".idata", IMAGE_SIZEOF_SHORT_NAME))
// if (ascii_strncasematch ((char *) section[i].Name, ".idata", IMAGE_SIZEOF_SHORT_NAME))
return section[i].VirtualAddress - section[i].PointerToRawData;
return -1;
}
@ -190,7 +190,7 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys)
// Iterate through each import descriptor, and redirect if appropriate
for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
{
if (!strcasematch (rva (PSTR, hm, pd->Name - delta), "cygwin1.dll"))
if (!ascii_strcasematch (rva (PSTR, hm, pd->Name - delta), "cygwin1.dll"))
continue;
if (!fn)
return (void *) "found it"; // just checking if executable used cygwin1.dll

View File

@ -1194,9 +1194,9 @@ out:
{
const char *p = strchr (path, '\0') - 4;
if (p >= path &&
(strcasematch (".exe", p) ||
strcasematch (".bat", p) ||
strcasematch (".com", p)))
(ascii_strcasematch (".exe", p) ||
ascii_strcasematch (".bat", p) ||
ascii_strcasematch (".com", p)))
path_flags |= PATH_EXEC;
}
@ -1562,20 +1562,21 @@ special_name (const char *s, int inc = 1)
int n;
const char *p = NULL;
if (strncasematch (s, "conin$", n = 5)
|| strncasematch (s, "conout$", n = 7)
|| strncasematch (s, "nul", n = 3)
|| strncasematch (s, "aux", 3)
|| strncasematch (s, "prn", 3)
|| strncasematch (s, "con", 3))
if (ascii_strncasematch (s, "conin$", n = 5)
|| ascii_strncasematch (s, "conout$", n = 7)
|| ascii_strncasematch (s, "nul", n = 3)
|| ascii_strncasematch (s, "aux", 3)
|| ascii_strncasematch (s, "prn", 3)
|| ascii_strncasematch (s, "con", 3))
p = s + n;
else if (strncasematch (s, "com", 3) || strncasematch (s, "lpt", 3))
else if (ascii_strncasematch (s, "com", 3)
|| ascii_strncasematch (s, "lpt", 3))
strtoul (s + 3, (char **) &p, 10);
if (p && (*p == '\0' || *p == '.'))
return -1;
return (strchr (s, '\0')[-1] == '.')
|| (strpbrk (s, special_chars) && !strncasematch (s, "%2f", 3));
|| (strpbrk (s, special_chars) && !ascii_strncasematch (s, "%2f", 3));
}
bool
@ -2890,7 +2891,7 @@ is_floppy (const char *dos)
char dev[256];
if (!QueryDosDevice (dos, dev, 256))
return false;
return strncasematch (dev, "\\Device\\Floppy", 14);
return ascii_strncasematch (dev, "\\Device\\Floppy", 14);
}
extern "C" FILE *
@ -3468,7 +3469,7 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes)
{
/* Check if the extension matches a known extension */
for (const suffix_info *ex = in_suffixes; ex->name != NULL; ex++)
if (strcasematch (ext_here, ex->name))
if (ascii_strcasematch (ext_here, ex->name))
{
nextstate = SCAN_JUSTCHECK;
suffixes = NULL; /* Has an extension so don't scan for one. */
@ -3477,7 +3478,7 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes)
}
/* Didn't match. Use last resort -- .lnk. */
if (strcasematch (ext_here, ".lnk"))
if (ascii_strcasematch (ext_here, ".lnk"))
{
nextstate = SCAN_HASLNK;
suffixes = NULL;
@ -4173,7 +4174,7 @@ realpath (const char *path, char *resolved)
if (!transparent_exe && real_path.known_suffix)
{
char *c = strrchr (real_path.normalized_path, '.');
if (!c || !strcasematch (c, real_path.known_suffix))
if (!c || !ascii_strcasematch (c, real_path.known_suffix))
tack_on = strlen (real_path.known_suffix);
}

View File

@ -528,7 +528,7 @@ loop:
risk, but we don't want to disable this behaviour for older
OSes because it's still heavily used by some users. They have
been warned. */
if (!strcasematch (wstname, "WinSta0"))
if (!ascii_strcasematch (wstname, "WinSta0"))
{
char sid[128];
@ -942,12 +942,12 @@ int
av::fixup (const char *prog_arg, path_conv& real_path, const char *ext)
{
const char *p;
bool exeext = strcasematch (ext, ".exe");
if (exeext && real_path.iscygexec () || strcasematch (ext, ".bat"))
bool exeext = ascii_strcasematch (ext, ".exe");
if (exeext && real_path.iscygexec () || ascii_strcasematch (ext, ".bat"))
return 0;
if (!*ext && ((p = ext - 4) > real_path.get_win32 ())
&& (strcasematch (p, ".bat") || strcasematch (p, ".cmd")
|| strcasematch (p, ".btm")))
&& (ascii_strcasematch (p, ".bat") || ascii_strcasematch (p, ".cmd")
|| ascii_strcasematch (p, ".btm")))
return 0;
while (1)
{
@ -1034,7 +1034,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext)
just_shell:
if (!pgm)
{
if (strcasematch (ext, ".com"))
if (ascii_strcasematch (ext, ".com"))
break;
pgm = (char *) "/bin/sh";
arg1 = NULL;

View File

@ -167,7 +167,8 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap)
p = pn;
if (p != progname)
strcpy (progname, p);
if ((p = strrchr (progname, '.')) != NULL && strcasematch (p, ".exe"))
if ((p = strrchr (progname, '.')) != NULL
&& ascii_strcasematch (p, ".exe"))
*p = '\000';
p = progname;
char tmpbuf[20];

View File

@ -61,15 +61,10 @@ strechr (const char *s, int c)
#ifdef __INSIDE_CYGWIN__
/* Don't use. Not NLS aware. */
#if 0 // Not NLS aware
extern const char isalpha_array[];
#undef strcasematch
#define strcasematch cygwin_strcasematch
static inline int
cygwin_strcasematch (const char *cs, const char *ct)
ascii_strcasematch (const char *cs, const char *ct)
{
register int __res;
int d0, d1;
@ -95,11 +90,8 @@ cygwin_strcasematch (const char *cs, const char *ct)
return __res;
}
#undef strncasematch
#define strncasematch cygwin_strncasematch
static inline int
cygwin_strncasematch (const char *cs, const char *ct, size_t n)
ascii_strncasematch (const char *cs, const char *ct, size_t n)
{
register int __res;
int d0, d1, d2;
@ -126,7 +118,7 @@ cygwin_strncasematch (const char *cs, const char *ct, size_t n)
return __res;
}
#else
#undef strcasecmp
#define strcasecmp cygwin_strcasecmp
int __stdcall cygwin_strcasecmp (const char *, const char *);
@ -137,7 +129,6 @@ int __stdcall cygwin_strncasecmp (const char *, const char *, size_t);
#define strcasematch(s1,s2) (!cygwin_strcasecmp ((s1),(s2)))
#define strncasematch(s1,s2,n) (!cygwin_strncasecmp ((s1),(s2),(n)))
#endif
#undef strlwr
#define strlwr cygwin_strlwr

View File

@ -1459,8 +1459,8 @@ rename_append_suffix (path_conv &pc, const char *path, size_t len,
{
char buf[len + 5];
if (strcasematch (path + len - 4, ".lnk")
|| strcasematch (path + len - 4, ".exe"))
if (ascii_strcasematch (path + len - 4, ".lnk")
|| ascii_strcasematch (path + len - 4, ".exe"))
len -= 4;
stpcpy (stpncpy (buf, path, len), suffix);
pc.check (buf, PC_SYM_NOFOLLOW);
@ -1529,8 +1529,8 @@ rename (const char *oldpath, const char *newpath)
goto out;
}
if (oldpc.known_suffix
&& (strcasematch (oldpath + olen - 4, ".lnk")
|| strcasematch (oldpath + olen - 4, ".exe")))
&& (ascii_strcasematch (oldpath + olen - 4, ".lnk")
|| ascii_strcasematch (oldpath + olen - 4, ".exe")))
old_explicit_suffix = true;
nlen = strlen (newpath);
@ -1559,8 +1559,8 @@ rename (const char *oldpath, const char *newpath)
goto out;
}
if (newpc.known_suffix
&& (strcasematch (newpath + nlen - 4, ".lnk")
|| strcasematch (newpath + nlen - 4, ".exe")))
&& (ascii_strcasematch (newpath + nlen - 4, ".lnk")
|| ascii_strcasematch (newpath + nlen - 4, ".exe")))
new_explicit_suffix = true;
/* This test is necessary in almost every case, so just do it once here. */

View File

@ -367,7 +367,7 @@ cygheap_user::env_logsrv (const char *name, size_t namelen)
const char *mydomain = domain ();
const char *myname = winname ();
if (!mydomain || strcasematch (myname, "SYSTEM"))
if (!mydomain || ascii_strcasematch (myname, "SYSTEM"))
return almost_null;
char logsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];

View File

@ -141,7 +141,7 @@ av::unshift (const char *what, int conv)
{
cygwin_conv_to_posix_path (what, buf);
char *p = strchr (buf, '\0') - 4;
if (p > buf && strcasematch (p, ".exe"))
if (p > buf && ascii_strcasematch (p, ".exe"))
*p = '\0';
what = buf;
}