diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-02-08 19:32:25 +0100 |
---|---|---|
committer | rafa_99 <raroma09@gmail.com> | 2022-02-17 19:04:03 +0000 |
commit | 54486d6633079b6d91677878914089727d759984 (patch) | |
tree | bc0f4bb46c17264859a9fc5be5193dfcb36010b4 /dmenu.c | |
parent | dee663045a9e21174da861ae91487f750149c43c (diff) |
revert using strcasestr and use a more optimized portable version
... compared to the old cistrstr().
Thanks for the feedback!
Diffstat (limited to 'dmenu.c')
-rw-r--r-- | dmenu.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -102,6 +102,25 @@ cleanup(void) XCloseDisplay(dpy); } +static char * +cistrstr(const char *h, const char *n) + +{ + size_t i; + + 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; +} + static int drawitem(struct item *item, int x, int y, int w) { @@ -722,7 +741,7 @@ main(int argc, char *argv[]) fast = 1; else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; - fstrstr = strcasestr; + fstrstr = cistrstr; } else if (!strcmp(argv[i], "-P")) /* is the input a password */ passwd = 1; else if (i + 1 == argc) |