Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752564AbbKIKzN (ORCPT ); Mon, 9 Nov 2015 05:55:13 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:33298 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751903AbbKIKzI (ORCPT ); Mon, 9 Nov 2015 05:55:08 -0500 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Taeung Song , Namhyung Kim , Jiri Olsa Subject: [PATCH] perf tools: Correct typing errors about '-' or '_' in config variable. Date: Mon, 9 Nov 2015 19:54:35 +0900 Message-Id: <1447066475-25543-1-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1953 Lines: 67 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 Cc: Jiri Olsa Signed-off-by: Taeung Song --- 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/