mirror of git://sourceware.org/git/glibc.git
Update.
2004-03-15 Ulrich Drepper <drepper@redhat.com> * sysdeps/generic/strcasestr.c (__strcasestr): Optimize use of tolower function.
This commit is contained in:
parent
58101473df
commit
4f514b6bf2
|
|
@ -1,3 +1,8 @@
|
||||||
|
2004-03-15 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/generic/strcasestr.c (__strcasestr): Optimize use of
|
||||||
|
tolower function.
|
||||||
|
|
||||||
2004-03-13 Jakub Jelinek <jakub@redhat.com>
|
2004-03-13 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/i386/sysconf.c (intel_02_known): Add const.
|
* sysdeps/unix/sysv/linux/i386/sysconf.c (intel_02_known): Add const.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* Return the offset of one string within another.
|
/* Return the offset of one string within another.
|
||||||
Copyright (C) 1994,1996,1997,1998,1999,2000 Free Software Foundation, Inc.
|
Copyright (C) 1994, 1996-2000, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
|
@ -36,6 +36,13 @@
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include <locale/localeinfo.h>
|
||||||
|
# define TOLOWER(c) __tolower_l (c, loc)
|
||||||
|
#else
|
||||||
|
# define TOLOWER(c) _tolower (c)
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef unsigned chartype;
|
typedef unsigned chartype;
|
||||||
|
|
||||||
#undef strcasestr
|
#undef strcasestr
|
||||||
|
|
@ -48,11 +55,14 @@ __strcasestr (phaystack, pneedle)
|
||||||
{
|
{
|
||||||
register const unsigned char *haystack, *needle;
|
register const unsigned char *haystack, *needle;
|
||||||
register chartype b, c;
|
register chartype b, c;
|
||||||
|
#ifdef _LIBC
|
||||||
|
__locale_t loc = _NL_CURRENT_LOCALE;
|
||||||
|
#endif
|
||||||
|
|
||||||
haystack = (const unsigned char *) phaystack;
|
haystack = (const unsigned char *) phaystack;
|
||||||
needle = (const unsigned char *) pneedle;
|
needle = (const unsigned char *) pneedle;
|
||||||
|
|
||||||
b = _tolower (*needle);
|
b = TOLOWER (*needle);
|
||||||
if (b != '\0')
|
if (b != '\0')
|
||||||
{
|
{
|
||||||
haystack--; /* possible ANSI violation */
|
haystack--; /* possible ANSI violation */
|
||||||
|
|
@ -62,9 +72,9 @@ __strcasestr (phaystack, pneedle)
|
||||||
if (c == '\0')
|
if (c == '\0')
|
||||||
goto ret0;
|
goto ret0;
|
||||||
}
|
}
|
||||||
while (_tolower (c) != (int) b);
|
while (TOLOWER (c) != (int) b);
|
||||||
|
|
||||||
c = _tolower (*++needle);
|
c = TOLOWER (*++needle);
|
||||||
if (c == '\0')
|
if (c == '\0')
|
||||||
goto foundneedle;
|
goto foundneedle;
|
||||||
++needle;
|
++needle;
|
||||||
|
|
@ -80,7 +90,7 @@ __strcasestr (phaystack, pneedle)
|
||||||
a = *++haystack;
|
a = *++haystack;
|
||||||
if (a == '\0')
|
if (a == '\0')
|
||||||
goto ret0;
|
goto ret0;
|
||||||
if (_tolower (a) == (int) b)
|
if (TOLOWER (a) == (int) b)
|
||||||
break;
|
break;
|
||||||
a = *++haystack;
|
a = *++haystack;
|
||||||
if (a == '\0')
|
if (a == '\0')
|
||||||
|
|
@ -88,34 +98,34 @@ __strcasestr (phaystack, pneedle)
|
||||||
shloop:
|
shloop:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
while (_tolower (a) != (int) b);
|
while (TOLOWER (a) != (int) b);
|
||||||
|
|
||||||
jin: a = *++haystack;
|
jin: a = *++haystack;
|
||||||
if (a == '\0')
|
if (a == '\0')
|
||||||
goto ret0;
|
goto ret0;
|
||||||
|
|
||||||
if (_tolower (a) != (int) c)
|
if (TOLOWER (a) != (int) c)
|
||||||
goto shloop;
|
goto shloop;
|
||||||
|
|
||||||
rhaystack = haystack-- + 1;
|
rhaystack = haystack-- + 1;
|
||||||
rneedle = needle;
|
rneedle = needle;
|
||||||
a = _tolower (*rneedle);
|
a = TOLOWER (*rneedle);
|
||||||
|
|
||||||
if (_tolower (*rhaystack) == (int) a)
|
if (TOLOWER (*rhaystack) == (int) a)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (a == '\0')
|
if (a == '\0')
|
||||||
goto foundneedle;
|
goto foundneedle;
|
||||||
++rhaystack;
|
++rhaystack;
|
||||||
a = _tolower (*++needle);
|
a = TOLOWER (*++needle);
|
||||||
if (_tolower (*rhaystack) != (int) a)
|
if (TOLOWER (*rhaystack) != (int) a)
|
||||||
break;
|
break;
|
||||||
if (a == '\0')
|
if (a == '\0')
|
||||||
goto foundneedle;
|
goto foundneedle;
|
||||||
++rhaystack;
|
++rhaystack;
|
||||||
a = _tolower (*++needle);
|
a = TOLOWER (*++needle);
|
||||||
}
|
}
|
||||||
while (_tolower (*rhaystack) == (int) a);
|
while (TOLOWER (*rhaystack) == (int) a);
|
||||||
|
|
||||||
needle = rneedle; /* took the register-poor approach */
|
needle = rneedle; /* took the register-poor approach */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue