Fixed bug in stristr()

SVN revision: 955
This commit is contained in:
Stefan Ritt 2004-07-14 10:09:47 +00:00
parent 02ab221961
commit 3577cdab84

View File

@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG Contents: Web server program for Electronic Logbook ELOG
$Log$ $Log$
Revision 1.381 2004/07/14 10:09:47 midas
Fixed bug in stristr()
Revision 1.380 2004/07/13 21:04:37 midas Revision 1.380 2004/07/13 21:04:37 midas
Implemented synchronizing during cloning Implemented synchronizing during cloning
@ -593,25 +596,26 @@ BOOL strieq(const char *str1, const char *str2)
char *stristr(const char *str, const char *pattern) char *stristr(const char *str, const char *pattern)
{ {
char c1, c2, *ps; char c1, c2, *ps, *pp;
if (str == NULL || pattern == NULL) if (str == NULL || pattern == NULL)
return NULL; return NULL;
while (*str) { while (*str) {
ps = (char *) str; ps = (char *) str;
c1 = *str; pp = (char *) pattern;
c2 = *pattern; c1 = *ps;
c2 = *pp;
if (my_toupper(c1) == my_toupper(c2)) { if (my_toupper(c1) == my_toupper(c2)) {
while (*pattern) { while (*pp) {
c1 = *ps++; c1 = *ps++;
c2 = *pattern++; c2 = *pp++;
if (my_toupper(c1) != my_toupper(c2)) if (my_toupper(c1) != my_toupper(c2))
break; break;
} }
if (!*pattern) if (!*pp)
return (char *) str; return (char *) str;
} }
str++; str++;