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. */
28 strcasestr (const char *haystack, const char *needle)
30 size_t hay_len = strlen (haystack);
31 size_t needle_len = strlen (needle);
33 while (hay_len >= needle_len) {
34 if (strncasecmp (haystack, needle, needle_len) == 0)
35 return (char *) haystack;