X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=5f81d253d4c50f3e9ab2891055278f1edd3b45c4;hb=301b4e55912dc611bd941002b27c72f17fcc5b39;hp=864c8f0aa7e9488dbb9854a13b4e35f14eb069a2;hpb=540a78761b26b2af4f47e46d27ad6406548c8a1c;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index 864c8f0..5f81d25 100644 --- a/dmenu.c +++ b/dmenu.c @@ -37,7 +37,6 @@ struct Item { Item *next; /* traverses all items */ Item *left, *right; /* traverses items matching current search pattern */ char *text; - Bool matched; }; /* forward declarations */ @@ -89,6 +88,7 @@ Item *next = NULL; Item *prev = NULL; Item *curr = NULL; Window root, win; +int (*fstrncmp)(const char *, const char *, size_t n) = strncmp; char *(*fstrstr)(const char *, const char *) = strstr; Item * @@ -97,7 +97,6 @@ appenditem(Item *i, Item *last) { item = i; else last->right = i; - i->matched = True; i->left = last; i->right = NULL; last = i; @@ -505,13 +504,9 @@ match(char *pattern) { plen = strlen(pattern); item = j = NULL; nitem = 0; - for(i = allitems; i; i=i->next) - i->matched = False; for(i = allitems; i; i = i->next) - if(!i->matched && !strncasecmp(pattern, i->text, plen)) - j = appenditem(i, j); - for(i = allitems; i; i = i->next) - if(!i->matched && fstrstr(i->text, pattern)) + if(!fstrncmp(pattern, i->text, plen) + || fstrstr(i->text, pattern)) j = appenditem(i, j); curr = prev = next = sel = item; calcoffsets(); @@ -662,8 +657,10 @@ main(int argc, char *argv[]) { /* command line args */ for(i = 1; i < argc; i++) - if(!strcmp(argv[i], "-i")) + if(!strcmp(argv[i], "-i")) { + fstrncmp = strncasecmp; fstrstr = cistrstr; + } else if(!strcmp(argv[i], "-fn")) { if(++i < argc) font = argv[i]; }