From: Laurent Vivier <lvivier@redhat.com>
To: qemu-devel@nongnu.org, marcandre.lureau@gmail.com, eblake@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 1/2] vl: Allow to define optional parameter with -arg[=params]
Date: Thu, 24 Sep 2015 18:14:35 +0200 [thread overview]
Message-ID: <5604216B.6020601@redhat.com> (raw)
In-Reply-To: <1442253680-8657-2-git-send-email-lvivier@redhat.com>
ping ?
On 14/09/2015 20:01, Laurent Vivier wrote:
> The goal is to be able to use '-help' alone, or with
> a sub-section, i.e. '-help=network,usb'.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> vl.c | 31 ++++++++++++++++++++-----------
> 1 file changed, 20 insertions(+), 11 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 1c8b28d..586ce55 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2703,19 +2703,28 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
> error_report("invalid option");
> exit(1);
> }
> - if (!strcmp(popt->name, r + 1))
> - break;
> - popt++;
> - }
> - if (popt->flags & HAS_ARG) {
> - if (optind >= argc) {
> - error_report("requires an argument");
> - exit(1);
> + /* manage arg type: -arg[=param] */
> + optarg = strchr(r + 1, '=');
> + if (optarg) {
> + if (!strncmp(popt->name, r + 1, optarg - (r + 1))) {
> + optarg++; /* skip '=' */
> + break;
> + }
> + } else {
> + if (!strcmp(popt->name, r + 1)) {
> + if (popt->flags & HAS_ARG) {
> + if (optind >= argc) {
> + error_report("requires an argument");
> + exit(1);
> + }
> + optarg = argv[optind++];
> + loc_set_cmdline(argv, optind - 2, 2);
> + }
> + break;
> + }
> }
> - optarg = argv[optind++];
> - loc_set_cmdline(argv, optind - 2, 2);
> - } else {
> optarg = NULL;
> + popt++;
> }
>
> *poptarg = optarg;
>
next prev parent reply other threads:[~2015-09-24 16:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-14 18:01 [Qemu-devel] [PATCH v5 0/2] Improve -help Laurent Vivier
2015-09-14 18:01 ` [Qemu-devel] [PATCH v5 1/2] vl: Allow to define optional parameter with -arg[=params] Laurent Vivier
2015-09-24 16:14 ` Laurent Vivier [this message]
2015-09-14 18:01 ` [Qemu-devel] [PATCH v5 2/2] Use help sub-sections to create sub-help options Laurent Vivier
2015-09-24 16:14 ` Laurent Vivier
2015-10-05 21:00 ` Michael S. Tsirkin
2015-10-05 13:20 ` [Qemu-devel] [PATCH v5 0/2] Improve -help Laurent Vivier
2015-10-05 15:08 ` Marc-André Lureau
2015-10-05 15:17 ` Daniel P. Berrange
2015-10-05 21:08 ` Michael S. Tsirkin
2015-10-05 22:04 ` Laurent Vivier
2015-10-05 22:50 ` Michael S. Tsirkin
2015-10-05 15:32 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5604216B.6020601@redhat.com \
--to=lvivier@redhat.com \
--cc=eblake@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.