cwm duplicate path names

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

cwm duplicate path names

Andres Perera-4
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 */;
  }
 }
 

Reply | Threaded
Open this post in threaded view
|

Re: cwm duplicate path names

Todd T. Fries-2
Given that cwm has origins in 9wm, wouldn't it be appropriate to
have firefox and firefox:0 and firefox:1 ?

Otherwise, your diff makes much sense as if you typed 'firefox'
from the command line, the shell would do what your diff does.

Thanks,

Penned by [hidden email] on 20130226  7:07.23, we have:
| 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 */;
|   }
|  }
|  

--
Todd Fries .. [hidden email]

 ____________________________________________
|                                            \  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC                \  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com            \  1.866.792.3418 (FAX)
| PO Box 16169, Oklahoma City, OK 73113      \  sip:[hidden email]
| "..in support of free software solutions." \  sip:[hidden email]
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                                                 
              37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
                        http://todd.fries.net/pgp.txt