move locale change to be global for perf

This commit is contained in:
Remi Collet
2012-12-13 09:47:33 +01:00
parent 16a4a32e29
commit a01b659ace
4 changed files with 50 additions and 21 deletions

View File

@@ -36,10 +36,6 @@
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif /* HAVE_LOCALE_H */
#ifdef WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@@ -148,23 +144,7 @@ int json_object_to_file(char *filename, struct json_object *obj)
int json_parse_double(const char *buf, double *retval)
{
int ret;
#ifdef HAVE_SETLOCALE
char *old=NULL, *tmp;
tmp = setlocale(LC_NUMERIC, NULL);
if (tmp) old = strdup(tmp);
setlocale(LC_NUMERIC, "C");
#endif
ret = sscanf(buf, "%lf", retval);
#ifdef HAVE_SETLOCALE
setlocale(LC_NUMERIC, old);
if (old) free(old);
#endif
return (ret==1 ? 0 : 1);
return (sscanf(buf, "%lf", retval)==1 ? 0 : 1);
}
int json_parse_int64(const char *buf, int64_t *retval)