aboutsummaryrefslogtreecommitdiffstats
path: root/search.c
diff options
context:
space:
mode:
authorcanacar2008-09-03 04:39:12 +0000
committercanacar2008-09-03 04:39:12 +0000
commit0cac11a31570d71936c55c2244a78de34ea4c5a8 (patch)
treeb68696201a1f052f048297d318111eb9d772fbc0 /search.c
parentdd42db089ff9274876abed27db09073d2450fa29 (diff)
downloadcwm-0cac11a31570d71936c55c2244a78de34ea4c5a8.tar.gz
Keep the exec menu entries sorted.
Go for it okan@
Diffstat (limited to 'search.c')
-rw-r--r--search.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/search.c b/search.c
index 93d6019..62fa1c3 100644
--- a/search.c
+++ b/search.c
@@ -14,7 +14,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: search.c,v 1.12 2008/07/11 14:21:28 okan Exp $
+ * $Id: search.c,v 1.13 2008/09/03 04:39:12 canacar Exp $
*/
#include "headers.h"
@@ -175,13 +175,23 @@ search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search)
void
search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
{
- struct menu *mi;
+ struct menu *mi, *mj;
TAILQ_INIT(resultq);
- TAILQ_FOREACH(mi, menuq, entry)
- if (_strsubmatch(search, mi->text, 1))
+ TAILQ_FOREACH(mi, menuq, entry) {
+ if (_strsubmatch(search, mi->text, 1) == 0)
+ continue;
+ for (mj = TAILQ_FIRST(resultq); mj != NULL;
+ mj = TAILQ_NEXT(mj, resultentry)) {
+ if (strcasecmp(mi->text, mj->text) < 0) {
+ TAILQ_INSERT_BEFORE(mj, mi, resultentry);
+ break;
+ }
+ }
+ if (mj == NULL)
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
+ }
}
static int