summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2013-03-09 21:55:57 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2013-03-09 21:55:57 +0000
commit45758ed2b122552a024be9a2347bcd0824ede2cc (patch)
treea88344f5fd8a37e04fc65765ad9d889c3ad2ee98
parentc455941f706a80b8099bea41744fa8e0a59978a0 (diff)
replace handrolled for loop with TAILQ_FOREACH; from andres.p@zoho.com
-rw-r--r--app/cwm/search.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/cwm/search.c b/app/cwm/search.c
index 9e22329d5..f7abb8414 100644
--- a/app/cwm/search.c
+++ b/app/cwm/search.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: search.c,v 1.26 2012/11/09 03:52:02 okan Exp $
+ * $OpenBSD: search.c,v 1.27 2013/03/09 21:55:56 okan Exp $
*/
#include <sys/param.h>
@@ -223,9 +223,8 @@ search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
TAILQ_FOREACH(mi, menuq, entry) {
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)) {
+ continue;
+ TAILQ_FOREACH(mj, resultq, resultentry) {
if (strcasecmp(mi->text, mj->text) < 0) {
TAILQ_INSERT_BEFORE(mj, mi, resultentry);
break;