Browse Source

Issue #668: add the option to specify "cmake -DUSELOCALE_NEEDS_FREELOCALE=1" to work around a bug in older versions of FreeBSD (<12.4).

tags/json-c-0.17-20230812
Eric Hawicz 2 years ago
parent
commit
71d845e819
3 changed files with 9 additions and 0 deletions
  1. +1
    -0
      CMakeLists.txt
  2. +3
    -0
      cmake/config.h.in
  3. +5
    -0
      json_tokener.c

+ 1
- 0
CMakeLists.txt View File

@@ -89,6 +89,7 @@ option(ENABLE_THREADING "Enable partial threading support."
option(OVERRIDE_GET_RANDOM_SEED "Override json_c_get_random_seed() with custom code." OFF) option(OVERRIDE_GET_RANDOM_SEED "Override json_c_get_random_seed() with custom code." OFF)
option(DISABLE_EXTRA_LIBS "Avoid linking against extra libraries, such as libbsd." OFF) option(DISABLE_EXTRA_LIBS "Avoid linking against extra libraries, such as libbsd." OFF)
option(DISABLE_JSON_POINTER "Disable JSON pointer (RFC6901) support." OFF) option(DISABLE_JSON_POINTER "Disable JSON pointer (RFC6901) support." OFF)
option(NEWLOCALE_NEEDS_FREELOCALE "Work around newlocale bugs in old FreeBSD by calling freelocale" OFF)




if (UNIX OR MINGW OR CYGWIN) if (UNIX OR MINGW OR CYGWIN)


+ 3
- 0
cmake/config.h.in View File

@@ -137,6 +137,9 @@
/* Define to 1 if you have the `uselocale' function. */ /* Define to 1 if you have the `uselocale' function. */
#cmakedefine HAVE_USELOCALE #cmakedefine HAVE_USELOCALE


/* Define to 1 if newlocale() needs freelocale() called on it's `base` argument */
#cmakedefine NEWLOCALE_NEEDS_FREELOCALE

/* Define to 1 if you have the `vasprintf' function. */ /* Define to 1 if you have the `vasprintf' function. */
#cmakedefine HAVE_VASPRINTF #cmakedefine HAVE_VASPRINTF




+ 5
- 0
json_tokener.c View File

@@ -344,6 +344,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
freelocale(duploc); freelocale(duploc);
return NULL; return NULL;
} }
#ifdef NEWLOCALE_NEEDS_FREELOCALE
// Older versions of FreeBSD (<12.4) don't free the locale
// passed to newlocale(), so do it here
freelocale(duploc);
#endif
uselocale(newloc); uselocale(newloc);
} }
#elif defined(HAVE_SETLOCALE) #elif defined(HAVE_SETLOCALE)


Loading…
Cancel
Save