mirror of
https://github.com/json-c/json-c.git
synced 2026-04-09 07:19:06 +08:00
Do not use duplocale if building for libnix because it isnt supported yet
This commit is contained in:
@@ -345,6 +345,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
|
||||
|
||||
#ifdef HAVE_USELOCALE
|
||||
{
|
||||
#ifdef HAVE_DUPLOCALE
|
||||
locale_t duploc = duplocale(oldlocale);
|
||||
if (duploc == NULL && errno == ENOMEM)
|
||||
{
|
||||
@@ -352,16 +353,23 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
|
||||
return NULL;
|
||||
}
|
||||
newloc = newlocale(LC_NUMERIC_MASK, "C", duploc);
|
||||
#else
|
||||
newloc = newlocale(LC_NUMERIC_MASK, "C", oldlocale);
|
||||
#endif
|
||||
if (newloc == NULL)
|
||||
{
|
||||
tok->err = json_tokener_error_memory;
|
||||
#ifdef HAVE_DUPLOCALE
|
||||
freelocale(duploc);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
#ifdef NEWLOCALE_NEEDS_FREELOCALE
|
||||
#ifdef HAVE_DUPLOCALE
|
||||
// Older versions of FreeBSD (<12.4) don't free the locale
|
||||
// passed to newlocale(), so do it here
|
||||
freelocale(duploc);
|
||||
#endif
|
||||
#endif
|
||||
uselocale(newloc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user