Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
revert using strcasestr and use a more optimized portable version
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
98507d9
..
88d2f12
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-103,13
+103,21
@@
cleanup(void)
}
static char *
}
static char *
-cistrstr(const char *s, const char *sub)
+cistrstr(const char *h, const char *n)
+
{
{
- size_t
len
;
+ size_t
i
;
- for (len = strlen(sub); *s; s++)
- if (!strncasecmp(s, sub, len))
- return (char *)s;
+ if (!n[0])
+ return (char *)h;
+
+ for (; *h; ++h) {
+ for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
+ tolower((unsigned char)h[i]); ++i)
+ ;
+ if (n[i] == '\0')
+ return (char *)h;
+ }
return NULL;
}
return NULL;
}