1
/* strcasestr.c - Find if one string appears as a substring of another string,
2
without regard to case. */
4
/* Copyright (C) 2000 Free Software Foundation, Inc.
6
This file is part of GNU Bash, the Bourne Again SHell.
8
Bash is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
13
Bash is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with Bash. If not, see <http://www.gnu.org/licenses/>.
25
#include <chartypes.h>
29
/* Determine if s2 occurs in s1. If so, return a pointer to the
30
match in s1. The compare is case insensitive. This is a
31
case-insensitive strstr(3). */
37
register int i, l, len, c;
39
c = TOLOWER ((unsigned char)s2[0]);
42
for (i = 0; (len - i) >= l; i++)
43
if ((TOLOWER ((unsigned char)s1[i]) == c) && (strncasecmp (s1 + i, s2, l) == 0))
44
return ((char *)s1 + i);