2 * slow simplistic reimplementation of strcasestr for systems that
3 * don't include it in their library
5 * based on a GPL implementation in OpenTTD found under GPL v2
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation, version 2.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 /* Imported into notmuch by Dirk Hohndel - original author unknown. */
27 char *strcasestr(const char *haystack, const char *needle)
29 size_t hay_len = strlen(haystack);
30 size_t needle_len = strlen(needle);
31 while (hay_len >= needle_len) {
32 if (strncasecmp(haystack, needle, needle_len) == 0)
33 return (char *) haystack;