i have both ~/bin/firefox and /usr/local/bin/firefox in PATH
cwm will display both in preliminary results. this isn't useful
because both have the same basename, so it's not possible to
differentiate. not that i would want to distinguish anyway
patch below uniqs them, preferring programs first in PATH
Index: xenocara/app/cwm/search.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/search.c,v
retrieving revision 1.26
diff -p -u -r1.26 search.c
--- xenocara/app/cwm/search.c 9 Nov 2012 03:52:02 -0000 1.26
+++ xenocara/app/cwm/search.c 26 Feb 2013 13:00:57 -0000
@@ -217,6 +217,7 @@ void
search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
{
struct menu *mi, *mj;
+ int r;
TAILQ_INIT(resultq);
@@ -224,15 +225,16 @@ search_match_exec(struct menu_q *menuq,
if (strsubmatch(search, mi->text, 1) == 0 &&
fnmatch(search, mi->text, 0) == FNM_NOMATCH)
continue;
- for (mj = TAILQ_FIRST(resultq); mj != NULL;
- mj = TAILQ_NEXT(mj, resultentry)) {
- if (strcasecmp(mi->text, mj->text) < 0) {
+ TAILQ_FOREACH(mj, resultq, resultentry) {
+ r = strcasecmp(mi->text, mj->text);
+ if (r < 0)
TAILQ_INSERT_BEFORE(mj, mi, resultentry);
- break;
- }
+ if (r <= 0)
+ goto a;
}
- if (mj == NULL)
- TAILQ_INSERT_TAIL(resultq, mi, resultentry);
+ TAILQ_INSERT_TAIL(resultq, mi, resultentry);
+a:
+ /* nil */;
}
}