cli: change while to for in keyword argument processing

Using a for loop makes it easier to use continue, in preparation for
future changes. No functional changes.
This commit is contained in:
Jani Nikula 2017-10-01 23:53:20 +03:00 committed by David Bremner
parent e704947855
commit 4dc3291199

View file

@ -13,14 +13,14 @@
static notmuch_bool_t static notmuch_bool_t
_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) { _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') { if (next == '\0') {
/* No keyword given */ /* No keyword given */
arg_str = ""; arg_str = "";
} }
while (keywords->name) { for (keywords = arg_desc->keywords; keywords->name; keywords++) {
if (strcmp (arg_str, keywords->name) == 0) { if (strcmp (arg_str, keywords->name) == 0) {
if (arg_desc->opt_flags) if (arg_desc->opt_flags)
*arg_desc->opt_flags |= keywords->value; *arg_desc->opt_flags |= keywords->value;
@ -28,7 +28,6 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
*arg_desc->opt_keyword = keywords->value; *arg_desc->opt_keyword = keywords->value;
return TRUE; return TRUE;
} }
keywords++;
} }
if (next != '\0') if (next != '\0')
fprintf (stderr, "Unknown keyword argument \"%s\" for option \"%s\".\n", arg_str, arg_desc->name); fprintf (stderr, "Unknown keyword argument \"%s\" for option \"%s\".\n", arg_str, arg_desc->name);