mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Taeung Song <treeze.taeung@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Taeung Song <treeze.taeung@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH] perf tools: Correct typing errors about '-' or '_' in config variable.
Date: Mon,  9 Nov 2015 19:54:35 +0900	[thread overview]
Message-ID: <1447066475-25543-1-git-send-email-treeze.taeung@gmail.com> (raw)

To improve perf config usability, we should probably also recognize
underscores in perf config entries, i.e. the following variants
should both work: as suggested by Ingo Molnar

        print_percent = 1
        print-percent = 1

So, add functionality for it.
'annotate' section has variables that contain '_' underscores like:

        hide_src_code
        use_offset
        jump_arrows
        show_nr_jumps

However other sections has variables that contain a '-' dash
or neither it or underscore i.e.

        ui.show-headers
        call-graph.print-limit
        tui.report

So, convert the characters if typing errors about underscores
or a dash when parsing the config file.

Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
 tools/perf/util/config.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 2e452ac..69db606 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -129,7 +129,10 @@ static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
 {
 	int c;
 	char *value;
+	bool has_underscore = false;
 
+	if (prefixcmp(name, "annotate.") == 0)
+		has_underscore = true;
 	/* Get the full name */
 	for (;;) {
 		c = get_next_char();
@@ -137,6 +140,11 @@ static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
 			break;
 		if (!iskeychar(c))
 			break;
+		/* Correct typing errors about dash or underscore */
+		if (has_underscore && c == '-')
+			c = '_';
+		else if (!has_underscore && c == '_')
+			c = '-';
 		name[len++] = c;
 		if (len >= MAXNAME)
 			return -1;
-- 
1.9.1


             reply	other threads:[~2015-11-09 10:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09 10:54 Taeung Song [this message]
2015-11-09 14:16 ` Arnaldo Carvalho de Melo

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=1447066475-25543-1-git-send-email-treeze.taeung@gmail.com \
    --to=treeze.taeung@gmail.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®