All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 2/4] perf tools: Allow '--inherit' as the negation of '--no-inherit'
Date: Mon, 18 Nov 2013 11:55:55 +0200	[thread overview]
Message-ID: <1384768557-23331-3-git-send-email-adrian.hunter@intel.com> (raw)
In-Reply-To: <1384768557-23331-1-git-send-email-adrian.hunter@intel.com>

Long options can be negated by prefixing them
with 'no-'.  However options that already start
with 'no-', such as '--no-inherit' result in ugly
double 'no's.  Avoid that by accepting that the
removal of 'no-' also negates the long option.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/util/parse-options.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 31f404a..b6b39ff 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -224,6 +224,24 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
 			return 0;
 		}
 		if (!rest) {
+			if (!prefixcmp(options->long_name, "no-")) {
+				/*
+				 * The long name itself starts with "no-", so
+				 * accept the option without "no-" so that users
+				 * do not have to enter "no-no-" to get the
+				 * negation.
+				 */
+				rest = skip_prefix(arg, options->long_name + 3);
+				if (rest) {
+					flags |= OPT_UNSET;
+					goto match;
+				}
+				/* Abbreviated case */
+				if (!prefixcmp(options->long_name + 3, arg)) {
+					flags |= OPT_UNSET;
+					goto is_abbreviated;
+				}
+			}
 			/* abbreviated? */
 			if (!strncmp(options->long_name, arg, arg_end - arg)) {
 is_abbreviated:
@@ -259,6 +277,7 @@ is_abbreviated:
 			if (!rest)
 				continue;
 		}
+match:
 		if (*rest) {
 			if (*rest != '=')
 				continue;
-- 
1.7.11.7


  parent reply	other threads:[~2013-11-18  9:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-18  9:55 [PATCH 0/4] perf record: Make per-cpu mmaps the default Adrian Hunter
2013-11-18  9:55 ` [PATCH 1/4] " Adrian Hunter
2013-11-18  9:55 ` Adrian Hunter [this message]
2013-11-18 21:15   ` [PATCH 2/4] perf tools: Allow '--inherit' as the negation of '--no-inherit' David Ahern
2013-11-19  8:12     ` Adrian Hunter
2013-11-19 16:20       ` David Ahern
2013-11-20  7:16         ` Adrian Hunter
2013-11-30 12:50   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-11-18  9:55 ` [PATCH 3/4] perf tools: Add option macro OPT_BOOLEAN_SET Adrian Hunter
2013-11-30 12:50   ` [tip:perf/core] " tip-bot for Adrian Hunter
2013-11-18  9:55 ` [PATCH 4/4] perf record: Default -t option to no inheritance Adrian Hunter
2013-11-30 12:51   ` [tip:perf/core] " tip-bot for Adrian Hunter

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=1384768557-23331-3-git-send-email-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.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.