[PATCH 4/9] cli: change while to for in keyword argument processing

Jani Nikula jani at nikula.org
Tue Sep 19 13:39:24 PDT 2017


Using a for loop makes it easier to use continue, in preparation for
future changes. No functional changes.
---
 command-line-arguments.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/command-line-arguments.c b/command-line-arguments.c
index 7fd58165278f..1373dbbb5225 100644
--- a/command-line-arguments.c
+++ b/command-line-arguments.c
@@ -13,14 +13,14 @@
 static notmuch_bool_t
 _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
 
-    const notmuch_keyword_t *keywords = arg_desc->keywords;
+    const notmuch_keyword_t *keywords;
 
     if (next == '\0') {
 	/* No keyword given */
 	arg_str = "";
     }
 
-    while (keywords->name) {
+    for (keywords = arg_desc->keywords; keywords->name; keywords++) {
 	if (strcmp (arg_str, keywords->name) == 0) {
 	    if (arg_desc->output_var) {
 		if (arg_desc->opt_type == NOTMUCH_OPT_KEYWORD_FLAGS)
@@ -30,7 +30,6 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
 	    }
 	    return TRUE;
 	}
-	keywords++;
     }
     if (next != '\0')
 	fprintf (stderr, "Unknown keyword argument \"%s\" for option \"%s\".\n", arg_str, arg_desc->name);
-- 
2.11.0



More information about the notmuch mailing list