One more thought... Markus Armbruster <arm...@redhat.com> writes:
> Paolo Bonzini <pbonz...@redhat.com> writes: [...] >> diff --git a/util/qemu-option.c b/util/qemu-option.c [...] >> @@ -767,16 +763,18 @@ void qemu_opts_print(QemuOpts *opts, const char >> *separator) >> >> static const char *get_opt_name_value(const char *params, >> const char *firstname, >> + bool *help_wanted, >> char **name, char **value) >> { >> - const char *p, *pe, *pc; >> - >> - pe = strchr(params, '='); >> - pc = strchr(params, ','); >> + const char *p; >> + size_t len; >> >> - if (!pe || (pc && pc < pe)) { >> + len = strcspn(params, "=,"); >> + if (params[len] != '=') { >> /* found "foo,more" */ >> - if (firstname) { >> + if (help_wanted && starts_with_help_option(params) == len) { >> + *help_wanted = true; >> + } else if (firstname) { >> /* implicitly named first option */ >> *name = g_strdup(firstname); >> p = get_opt_value(params, value); > > This function parses one parameter from @params into @name, @value, and > returns a pointer to the next parameter, or else to the terminating > '\0'. Like opt_validate() before, this sets *help_wanted only to true. Callers must pass a pointer to false. Perhaps having it set *help_wanted always could simplify things overall. Up to you. [...]