]> granicus.if.org Git - json-c/commitdiff
Issue #705: disable locale handling when building for a uClibc system because its...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Sat, 30 Jul 2022 20:27:35 +0000 (20:27 +0000)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Sat, 30 Jul 2022 20:27:35 +0000 (20:27 +0000)
CMakeLists.txt
ChangeLog
tests/test_locale.c

index eb53cefc82c949c940455a6d44335ab8d47d828a..2be027d677a2dbf541051dbf2b06b2fbfaec940a 100644 (file)
@@ -192,6 +192,18 @@ if (HAVE_LOCALE_H)
     check_symbol_exists(setlocale   "locale.h" HAVE_SETLOCALE)
     check_symbol_exists(uselocale   "locale.h" HAVE_USELOCALE)
 endif()
+
+# uClibc *intentionally* crashes in duplocale(), at least as of:
+# https://github.com/ffainelli/uClibc/blob/266bdc1/libc/misc/locale/locale.c#L1322
+# So, if it looks like we're compiling for a system like that just disable 
+# locale handling entirely.
+exec_program(${CMAKE_C_COMPILER} ARGS -dumpmachine OUTPUT_VARIABLE CMAKE_GNU_C_MACHINE)
+if (CMAKE_GNU_C_MACHINE MATCHES "uclibc")
+       message(STATUS "Detected uClibc compiler, disabling locale handling")
+       set(HAVE_SETLOCALE 0)
+       set(HAVE_USELOCALE 0)
+endif()
+
 if (HAVE_STRINGS_H)
     check_symbol_exists(strcasecmp  "strings.h" HAVE_STRCASECMP)
     check_symbol_exists(strncasecmp "strings.h" HAVE_STRNCASECMP)
index 8cadae62623f1ed3e14af729bf5ac5cceeeab8d2..d04edbe125c0cff4dfa9791b363361cbc5239655 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@ Significant changes and bug fixes
 ---------------------------------
 * When serializing with JSON_C_TO_STRING_PRETTY set, keep the opening and 
   closing curly or square braces on same line for empty objects or arrays.
+* Disable locale handling when targeting a uClibc system due to problems
+  with its duplocale() function.
 
 
 0.16 (up to commit 66dcdf5, 2022-04-13)
index 7299ee270fd275231dd965f73a3b7873136d2c3b..79f6c2c6bd8b1f1026b8565b220aea63f1dfd841 100644 (file)
@@ -24,8 +24,6 @@ int main(int argc, char **argv)
        json_object *new_obj;
 #ifdef HAVE_SETLOCALE
        setlocale(LC_NUMERIC, "de_DE");
-#else
-       printf("No locale\n");
 #endif
 
        char buf1[10], buf2[10];