static notmuch_bool_t
_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
-
- if (next == '\0') {
- *arg_desc->opt_bool = TRUE;
- return TRUE;
- }
- if (strcmp (arg_str, "false") == 0) {
- *arg_desc->opt_bool = FALSE;
- return TRUE;
- }
- if (strcmp (arg_str, "true") == 0) {
- *arg_desc->opt_bool = TRUE;
- return TRUE;
+ notmuch_bool_t value;
+
+ if (next == '\0' || strcmp (arg_str, "true") == 0) {
+ value = TRUE;
+ } else if (strcmp (arg_str, "false") == 0) {
+ value = FALSE;
+ } else {
+ fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
+ return FALSE;
}
- fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
- return FALSE;
+
+ *arg_desc->opt_bool = value;
+
+ return TRUE;
}
static notmuch_bool_t
if (arg_desc->opt_position) {
if (pos_arg_counter == pos_arg_index) {
*arg_desc->opt_position = arg_str;
+ if (arg_desc->present)
+ *arg_desc->present = TRUE;
return TRUE;
}
pos_arg_counter++;
else
INTERNAL_ERROR ("unknown or unhandled option \"%s\"", try->name);
- if (opt_status)
- return opt_index+1;
- else
+ if (! opt_status)
return -1;
+
+ if (try->present)
+ *try->present = TRUE;
+
+ return opt_index+1;
}
return -1;
}