+
+ if (! try->name)
+ continue;
+
+ if (strncmp (arg, try->name, strlen (try->name)) != 0)
+ continue;
+
+ char next = arg[strlen (try->name)];
+ const char *value = arg + strlen(try->name) + 1;
+
+ /*
+ * If we have not reached the end of the argument (i.e. the
+ * next character is not a space or delimiter) then the
+ * argument could still match a longer option name later in
+ * the option table.
+ */
+ if (next != '=' && next != ':' && next != '\0')
+ continue;
+
+ if (next == '\0' && next_arg != NULL && ! try->opt_bool) {
+ next = ' ';
+ value = next_arg;
+ opt_index ++;
+ }
+
+ bool opt_status = false;
+ if (try->opt_keyword || try->opt_flags)
+ opt_status = _process_keyword_arg (try, next, value);
+ else if (try->opt_bool)
+ opt_status = _process_boolean_arg (try, next, value);
+ else if (try->opt_int)
+ opt_status = _process_int_arg (try, next, value);
+ else if (try->opt_string)
+ opt_status = _process_string_arg (try, next, value);
+ else
+ INTERNAL_ERROR ("unknown or unhandled option \"%s\"", try->name);
+
+ if (! opt_status)
+ return -1;
+
+ if (try->present)
+ *try->present = true;
+
+ return opt_index+1;