move locale change to be global for perf
This commit is contained in:
22
json_util.c
22
json_util.c
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user