diff options
| -rw-r--r-- | dmenu.c | 26 |
1 files changed, 25 insertions, 1 deletions
| @@ -58,6 +58,7 @@ void readstdin(void); | |||
| 58 | void run(void); | 58 | void run(void); |
| 59 | void setup(Bool bottom); | 59 | void setup(Bool bottom); |
| 60 | int strcaseido(const char *text, const char *pattern); | 60 | int strcaseido(const char *text, const char *pattern); |
| 61 | char *cistrstr(const char *s, const char *sub); | ||
| 61 | unsigned int textnw(const char *text, unsigned int len); | 62 | unsigned int textnw(const char *text, unsigned int len); |
| 62 | unsigned int textw(const char *text); | 63 | unsigned int textw(const char *text); |
| 63 | 64 | ||
| @@ -511,7 +512,7 @@ match(char *pattern) { | |||
| 511 | if(!i->matched && !strncasecmp(pattern, i->text, plen)) | 512 | if(!i->matched && !strncasecmp(pattern, i->text, plen)) |
| 512 | j = appenditem(i, j); | 513 | j = appenditem(i, j); |
| 513 | for(i = allitems; i; i = i->next) | 514 | for(i = allitems; i; i = i->next) |
| 514 | if(!i->matched && strcasestr(i->text, pattern)) | 515 | if(!i->matched && cistrstr(i->text, pattern)) |
| 515 | j = appenditem(i, j); | 516 | j = appenditem(i, j); |
| 516 | if(idomatch) | 517 | if(idomatch) |
| 517 | for(i = allitems; i; i = i->next) | 518 | for(i = allitems; i; i = i->next) |
| @@ -629,6 +630,29 @@ strcaseido(const char *text, const char *pattern) { | |||
| 629 | return !*pattern; | 630 | return !*pattern; |
| 630 | } | 631 | } |
| 631 | 632 | ||
| 633 | char * | ||
| 634 | cistrstr(const char *s, const char *sub) { | ||
| 635 | int c, csub; | ||
| 636 | unsigned int len; | ||
| 637 | |||
| 638 | if(!sub) | ||
| 639 | return (char *)s; | ||
| 640 | if((c = *sub++) != 0) { | ||
| 641 | c = tolower(c); | ||
| 642 | len = strlen(sub); | ||
| 643 | do { | ||
| 644 | do { | ||
| 645 | if((csub = *s++) == 0) | ||
| 646 | return (NULL); | ||
| 647 | } | ||
| 648 | while(tolower(csub) != c); | ||
| 649 | } | ||
| 650 | while(strncasecmp(s, sub, len) != 0); | ||
| 651 | s--; | ||
| 652 | } | ||
| 653 | return (char *)s; | ||
| 654 | } | ||
| 655 | |||
| 632 | unsigned int | 656 | unsigned int |
| 633 | textnw(const char *text, unsigned int len) { | 657 | textnw(const char *text, unsigned int len) { |
| 634 | XRectangle r; | 658 | XRectangle r; |
