diff options
Diffstat (limited to 'dmenu.c')
| -rw-r--r-- | dmenu.c | 21 |
1 files changed, 20 insertions, 1 deletions
| @@ -102,6 +102,25 @@ cleanup(void) | |||
| 102 | XCloseDisplay(dpy); | 102 | XCloseDisplay(dpy); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | static char * | ||
| 106 | cistrstr(const char *h, const char *n) | ||
| 107 | |||
| 108 | { | ||
| 109 | size_t i; | ||
| 110 | |||
| 111 | if (!n[0]) | ||
| 112 | return (char *)h; | ||
| 113 | |||
| 114 | for (; *h; ++h) { | ||
| 115 | for (i = 0; n[i] && tolower((unsigned char)n[i]) == | ||
| 116 | tolower((unsigned char)h[i]); ++i) | ||
| 117 | ; | ||
| 118 | if (n[i] == '\0') | ||
| 119 | return (char *)h; | ||
| 120 | } | ||
| 121 | return NULL; | ||
| 122 | } | ||
| 123 | |||
| 105 | static int | 124 | static int |
| 106 | drawitem(struct item *item, int x, int y, int w) | 125 | drawitem(struct item *item, int x, int y, int w) |
| 107 | { | 126 | { |
| @@ -711,7 +730,7 @@ main(int argc, char *argv[]) | |||
| 711 | fast = 1; | 730 | fast = 1; |
| 712 | else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ | 731 | else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ |
| 713 | fstrncmp = strncasecmp; | 732 | fstrncmp = strncasecmp; |
| 714 | fstrstr = strcasestr; | 733 | fstrstr = cistrstr; |
| 715 | } else if (i + 1 == argc) | 734 | } else if (i + 1 == argc) |
| 716 | usage(); | 735 | usage(); |
| 717 | /* these options take one argument */ | 736 | /* these options take one argument */ |
