]> git.llucax.com Git - software/mutt-debian.git/blob - strcasestr.c
renaming the unmailboxes patch
[software/mutt-debian.git] / strcasestr.c
1 /*
2  * Copyright (C) 2002     Manuel Novoa III
3  * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4  *
5  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6  */
7 #include <stdlib.h>
8 #include <ctype.h>
9
10 char *strcasestr(const char *s1, const char *s2)
11 {
12         register const char *s = s1;
13         register const char *p = s2;
14
15 #if 1
16         do {
17                 if (!*p) {
18                         return (char *) s1;;
19                 }
20                 if ((*p == *s)
21                         || (tolower(*((unsigned char *)p)) == tolower(*((unsigned char *)s)))
22                         ) {
23                         ++p;
24                         ++s;
25                 } else {
26                         p = s2;
27                         if (!*s) {
28                                 return NULL;
29                         }
30                         s = ++s1;
31                 }
32         } while (1);
33 #else
34         while (*p && *s) {
35                 if ((*p == *s)
36                         || (tolower(*((unsigned char *)p)) == tolower(*((unsigned char *)s)))
37                         ) {
38                         ++p;
39                         ++s;
40                 } else {
41                         p = s2;
42                         s = ++s1;
43                 }
44         }
45
46         return (*p) ? NULL : (char *) s1;
47 #endif
48 }