diff options
Diffstat (limited to 'json_tokener.c')
-rw-r--r-- | json_tokener.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/json_tokener.c b/json_tokener.c index 85c530b..63bb41b 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -31,6 +31,10 @@ #include "json_tokener.h" #include "json_util.h" +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif /* HAVE_LOCALE_H */ + #if !HAVE_STRDUP && defined(_MSC_VER) /* MSC has the version as _strdup */ # define strdup _strdup @@ -227,6 +231,13 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, { struct json_object *obj = NULL; char c = '\1'; +#ifdef HAVE_SETLOCALE + char *oldlocale=NULL, *tmplocale; + + tmplocale = setlocale(LC_NUMERIC, NULL); + if (tmplocale) oldlocale = strdup(tmplocale); + setlocale(LC_NUMERIC, "C"); +#endif tok->char_offset = 0; tok->err = json_tokener_success; @@ -724,6 +735,11 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, tok->err = json_tokener_error_parse_eof; } +#ifdef HAVE_SETLOCALE + setlocale(LC_NUMERIC, oldlocale); + if (oldlocale) free(oldlocale); +#endif + if (tok->err == json_tokener_success) { json_object *ret = json_object_get(current); |