aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dmenu.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/dmenu.c b/dmenu.c
index 509e566..c9fb38b 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -208,7 +208,7 @@ match(void)
208 208
209 char buf[sizeof text], *s; 209 char buf[sizeof text], *s;
210 int i, tokc = 0; 210 int i, tokc = 0;
211 size_t len; 211 size_t len, textsize;
212 struct item *item, *lprefix, *lsubstr, *prefixend, *substrend; 212 struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
213 213
214 strcpy(buf, text); 214 strcpy(buf, text);
@@ -219,6 +219,7 @@ match(void)
219 len = tokc ? strlen(tokv[0]) : 0; 219 len = tokc ? strlen(tokv[0]) : 0;
220 220
221 matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL; 221 matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
222 textsize = strlen(text) + 1;
222 for (item = items; item && item->text; item++) { 223 for (item = items; item && item->text; item++) {
223 for (i = 0; i < tokc; i++) 224 for (i = 0; i < tokc; i++)
224 if (!fstrstr(item->text, tokv[i])) 225 if (!fstrstr(item->text, tokv[i]))
@@ -226,7 +227,7 @@ match(void)
226 if (i != tokc) /* not all tokens match */ 227 if (i != tokc) /* not all tokens match */
227 continue; 228 continue;
228 /* exact matches go first, then prefixes, then substrings */ 229 /* exact matches go first, then prefixes, then substrings */
229 if (!tokc || !fstrncmp(tokv[0], item->text, len + 1)) 230 if (!tokc || !fstrncmp(text, item->text, textsize))
230 appenditem(item, &matches, &matchend); 231 appenditem(item, &matches, &matchend);
231 else if (!fstrncmp(tokv[0], item->text, len)) 232 else if (!fstrncmp(tokv[0], item->text, len))
232 appenditem(item, &lprefix, &prefixend); 233 appenditem(item, &lprefix, &prefixend);