Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1265563 > unrolled thread

[PATCH] perf tools: Correct typing errors about '-' or '_' in config variable.

Started byTaeung Song <treeze.taeung@gmail.com>
First post2015-11-09 12:00 +0100
Last post2015-11-09 15:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf tools: Correct typing errors about '-' or '_' in config variable. Taeung Song <treeze.taeung@gmail.com> - 2015-11-09 12:00 +0100
    Re: [PATCH] perf tools: Correct typing errors about '-' or '_' in  config variable. Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-09 15:20 +0100

#1265563 — [PATCH] perf tools: Correct typing errors about '-' or '_' in config variable.

FromTaeung Song <treeze.taeung@gmail.com>
Date2015-11-09 12:00 +0100
Subject[PATCH] perf tools: Correct typing errors about '-' or '_' in config variable.
Message-ID<qsSl4-5kw-23@gated-at.bofh.it>
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1265706 — Re: [PATCH] perf tools: Correct typing errors about '-' or '_' in config variable.

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-11-09 15:20 +0100
SubjectRe: [PATCH] perf tools: Correct typing errors about '-' or '_' in config variable.
Message-ID<qsVsC-7v9-11@gated-at.bofh.it>
In reply to#1265563
Em Mon, Nov 09, 2015 at 07:54:35PM +0900, Taeung Song escreveu:
> 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

There is no need to single our a section just because nowadays it
contains underscores so that we would convert them to dashes, do it for
all sections, so that if in the future we get underscores in them, then
it wild be dash/underscore "insensitive".

In fact, this would be a strcasecmp_() routine, i.e. one that would, in
addition to being case insensitive, also consider - and _ the same
character.

- Arnaldo
 
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web