diff options
author | Davidson Francis <davidsondfgl@gmail.com> | 2020-07-05 15:50:13 -0300 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-05 22:58:45 +0200 |
commit | 8fce3d7a27fafa24d381f65cc9b90a169bf91e87 (patch) | |
tree | 08b81db2c596b216df3b16dc1671f8169dac7329 | |
parent | a424976e16455fab6a22d539c2f77301dea72230 (diff) | |
download | sparse-8fce3d7a27fafa24d381f65cc9b90a169bf91e87.tar.gz |
test-inspect: reset locale after gtk_init()
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@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | test-inspect.c | 2 |
1 files changed, 2 insertions, 0 deletions
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); |