From 921a4acc22eaf61a1c8c5e386a5a9cbb3a690a1c Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Fri, 21 Oct 2016 14:52:04 +0200 Subject: [PATCH] Fix #128: Use decimal point for FP values in JSON output This patch sets LC_NUMERIC variable to "C" to make sure JSON output (as displayed by sadf -j) is locale-independent and floating-point values use a decimal point. This should make JSON output compliant with RFC7159. Reported-by: @andy-maier Signed-off-by: Sebastien GODARD --- sadf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sadf.c b/sadf.c index fc7a975..4b05a8b 100644 --- a/sadf.c +++ b/sadf.c @@ -949,6 +949,11 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file, long cnt = 1; off_t fpos; + if (format == F_JSON_OUTPUT) { + /* Use a decimal point to make JSON code compliant with RFC7159 */ + setlocale(LC_NUMERIC, "C"); + } + /* Save current file position */ if ((fpos = lseek(ifd, 0, SEEK_CUR)) < 0) { perror("lseek"); -- 2.40.0