mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Update strstr to the one in glibc 2.3.5.
This commit is contained in:
parent
818fbdf32a
commit
de5fd29373
@ -1,3 +1,7 @@
|
|||||||
|
2005-05-06 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* cmpt.c (strstr): Updated from glibc 2.3.5.
|
||||||
|
|
||||||
2005-05-05 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-05-05 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* http.c (http_atotm): Zero out the whole struct tm being passed
|
* http.c (http_atotm): Zero out the whole struct tm being passed
|
||||||
|
132
src/cmpt.c
132
src/cmpt.c
@ -1,5 +1,5 @@
|
|||||||
/* Replacements for routines missing on some systems.
|
/* Replacements for routines missing on some systems.
|
||||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
Copyright (C) 1995-2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Wget.
|
This file is part of GNU Wget.
|
||||||
|
|
||||||
@ -121,8 +121,8 @@ strncasecmp (const char *s1, const char *s2, size_t n)
|
|||||||
#endif /* not HAVE_STRNCASECMP */
|
#endif /* not HAVE_STRNCASECMP */
|
||||||
|
|
||||||
#ifndef HAVE_STRSTR
|
#ifndef HAVE_STRSTR
|
||||||
/* From GNU libc 2.0.6. */
|
/* From GNU libc 2.3.5. */
|
||||||
/* Return the first ocurrence of NEEDLE in HAYSTACK. */
|
|
||||||
/*
|
/*
|
||||||
* My personal strstr() implementation that beats most other algorithms.
|
* My personal strstr() implementation that beats most other algorithms.
|
||||||
* Until someone tells me otherwise, I assume that this is the
|
* Until someone tells me otherwise, I assume that this is the
|
||||||
@ -131,90 +131,88 @@ strncasecmp (const char *s1, const char *s2, size_t n)
|
|||||||
* as much fun trying to understand it, as I had to write it :-).
|
* as much fun trying to understand it, as I had to write it :-).
|
||||||
*
|
*
|
||||||
* Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
|
* Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
|
||||||
|
|
||||||
typedef unsigned chartype;
|
typedef unsigned chartype;
|
||||||
|
|
||||||
|
#undef strstr
|
||||||
|
|
||||||
char *
|
char *
|
||||||
strstr (phaystack, pneedle)
|
strstr (const char *phaystack, const char *pneedle)
|
||||||
const char *phaystack;
|
|
||||||
const char *pneedle;
|
|
||||||
{
|
{
|
||||||
register const unsigned char *haystack, *needle;
|
const unsigned char *haystack, *needle;
|
||||||
register chartype b, c;
|
chartype b;
|
||||||
|
const unsigned char *rneedle;
|
||||||
|
|
||||||
haystack = (const unsigned char *) phaystack;
|
haystack = (const unsigned char *) phaystack;
|
||||||
needle = (const unsigned char *) pneedle;
|
|
||||||
|
|
||||||
b = *needle;
|
if ((b = *(needle = (const unsigned char *) pneedle)))
|
||||||
if (b != '\0')
|
|
||||||
{
|
{
|
||||||
haystack--; /* possible ANSI violation */
|
chartype c;
|
||||||
do
|
haystack--; /* possible ANSI violation */
|
||||||
{
|
|
||||||
c = *++haystack;
|
|
||||||
if (c == '\0')
|
|
||||||
goto ret0;
|
|
||||||
}
|
|
||||||
while (c != b);
|
|
||||||
|
|
||||||
c = *++needle;
|
{
|
||||||
if (c == '\0')
|
chartype a;
|
||||||
|
do
|
||||||
|
if (!(a = *++haystack))
|
||||||
|
goto ret0;
|
||||||
|
while (a != b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(c = *++needle))
|
||||||
goto foundneedle;
|
goto foundneedle;
|
||||||
++needle;
|
++needle;
|
||||||
goto jin;
|
goto jin;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
register chartype a;
|
{
|
||||||
register const unsigned char *rhaystack, *rneedle;
|
chartype a;
|
||||||
|
if (0)
|
||||||
do
|
jin:{
|
||||||
{
|
if ((a = *++haystack) == c)
|
||||||
|
goto crest;
|
||||||
|
}
|
||||||
|
else
|
||||||
a = *++haystack;
|
a = *++haystack;
|
||||||
if (a == '\0')
|
|
||||||
goto ret0;
|
|
||||||
if (a == b)
|
|
||||||
break;
|
|
||||||
a = *++haystack;
|
|
||||||
if (a == '\0')
|
|
||||||
goto ret0;
|
|
||||||
shloop: }
|
|
||||||
while (a != b);
|
|
||||||
|
|
||||||
jin: a = *++haystack;
|
|
||||||
if (a == '\0')
|
|
||||||
goto ret0;
|
|
||||||
|
|
||||||
if (a != c)
|
|
||||||
goto shloop;
|
|
||||||
|
|
||||||
rhaystack = haystack-- + 1;
|
|
||||||
rneedle = needle;
|
|
||||||
a = *rneedle;
|
|
||||||
|
|
||||||
if (*rhaystack == a)
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (a == '\0')
|
for (; a != b; a = *++haystack)
|
||||||
goto foundneedle;
|
{
|
||||||
++rhaystack;
|
if (!a)
|
||||||
a = *++needle;
|
goto ret0;
|
||||||
if (*rhaystack != a)
|
if ((a = *++haystack) == b)
|
||||||
break;
|
break;
|
||||||
if (a == '\0')
|
if (!a)
|
||||||
goto foundneedle;
|
goto ret0;
|
||||||
++rhaystack;
|
}
|
||||||
a = *++needle;
|
|
||||||
}
|
}
|
||||||
while (*rhaystack == a);
|
while ((a = *++haystack) != c);
|
||||||
|
}
|
||||||
needle = rneedle; /* took the register-poor approach */
|
crest:
|
||||||
|
{
|
||||||
if (a == '\0')
|
chartype a;
|
||||||
break;
|
{
|
||||||
}
|
const unsigned char *rhaystack;
|
||||||
|
if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle)))
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!a)
|
||||||
|
goto foundneedle;
|
||||||
|
if (*++rhaystack != (a = *++needle))
|
||||||
|
break;
|
||||||
|
if (!a)
|
||||||
|
goto foundneedle;
|
||||||
|
}
|
||||||
|
while (*++rhaystack == (a = *++needle));
|
||||||
|
needle = rneedle; /* took the register-poor aproach */
|
||||||
|
}
|
||||||
|
if (!a)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foundneedle:
|
foundneedle:
|
||||||
return (char*) haystack;
|
return (char *) haystack;
|
||||||
ret0:
|
ret0:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user