[PATCH] test-inspect: reset locale after gtk_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The test-inspect tool uses GTK to visualize symbol nodes. It turns
out that gtk_init() implicitly sets the locale to the system locale,
and since Sparse uses strtod()/strtold() for parsing floating-point
numbers in expressions, parsing becomes locale-dependent.

Since the system's locale may be different from "C", test-inspect
may be unable to parse float numbers.

Steps to reproduce:
    $ echo "int main(void){3.14;}" > test.c
    $ LC_ALL="fr_FR.UTF-8" test-inspect test.c
Output:
    test.c:1:16: error: constant 3.14 is not a valid number

Fix this by resetting the locale right after gtk_init().

Signed-off-by: Davidson Francis <davidsondfgl@xxxxxxxxx>
---
 test-inspect.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test-inspect.c b/test-inspect.c
index 63754cb3..a59cd902 100644
--- a/test-inspect.c
+++ b/test-inspect.c
@@ -6,6 +6,7 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <locale.h>
 
 #include "lib.h"
 #include "allocate.h"
@@ -31,6 +32,7 @@ int main(int argc, char **argv)
 	struct symbol_list *view_syms = NULL;
 
 	gtk_init(&argc,&argv);
+	setlocale(LC_ALL, "C");
 	expand_symbols(sparse_initialize(argc, argv, &filelist));
 	FOR_EACH_PTR(filelist, file) {
 		struct symbol_list *syms = sparse(file);
-- 
2.11.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux