mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: acme@kernel.org
Cc: jolsa@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: [PATCH] perf, tools, stat: Force C numeric locale for CSV mode
Date: Tue,  5 Jan 2016 11:17:45 -0800	[thread overview]
Message-ID: <1452021465-17831-1-git-send-email-andi@firstfloor.org> (raw)

From: Andi Kleen <ak@linux.intel.com>

Some locales print floating point numbers with a comma instead of a dot.
This causes problems with CSV mode because it causes extra false CSV
fields. Force the numeric locale to be always C in CSV mode.

Before:

$ LC_ALL=pl_PL.utf8  perf stat -x, true
0,399472,,task-clock,399472,100,00			<---- extra bogus field
...

After:
$ LC_ALL=pl_PL.utf8  ./obj-perf/perf stat -x, true
0.338422,,task-clock,338422,100.00

Originally reported in https://github.com/andikleen/pmu-tools/issues/43

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/builtin-stat.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 9805e03..4d5e504 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1826,6 +1826,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 		csv_output = true;
 		if (!strcmp(csv_sep, "\\t"))
 			csv_sep = "\t";
+		setlocale(LC_NUMERIC, "C");
 	} else
 		csv_sep = DEFAULT_SEPARATOR;
 
-- 
2.4.3


             reply	other threads:[~2016-01-05 19:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 19:17 Andi Kleen [this message]
2016-01-05 21:05 ` Jiri Olsa
2016-01-05 21:17   ` Arnaldo Carvalho de Melo
2016-01-05 21:28     ` Andi Kleen
2016-01-05 23:27       ` Arnaldo Carvalho de Melo
2016-01-06  1:37         ` Andi Kleen

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=1452021465-17831-1-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@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

Powered by JetHome