Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
code-style: rm newline (oops)
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
98507d9
..
d95e6c6
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-103,13
+103,20
@@
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;
+
+ if (!n[0])
+ return (char *)h;
- for (len = strlen(sub); *s; s++)
- if (!strncasecmp(s, sub, len))
- return (char *)s;
+ 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;
}