]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Do not use duplocale if building for libnix because it isnt supported yet
authorCameron Armstrong (Nightfox) <cameronscottarmstrong@gmail.com>
Mon, 15 Jul 2024 03:30:44 +0000 (11:30 +0800)
committerCameron Armstrong (Nightfox) <cameronscottarmstrong@gmail.com>
Tue, 24 Dec 2024 02:09:50 +0000 (10:09 +0800)
CMakeLists.txt
README.md
cmake/config.h.in
json_tokener.c

index ed877e3539d099125849a35aa0ac6b4aa8024770..11bfa43215e111d15569683e635bb55929f16435 100644 (file)
@@ -84,6 +84,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "AmigaOS")
             set(NEWLIB ON)
         elseif(${M68K_CRT} STREQUAL "clib2")
             set(CLIB2 ON)
+        elseif(${M68K_CRT} STREQUAL "ixemul")
+            set(IXEMUL ON)
         elseif(${M68K_CRT} STREQUAL "nix20")
             set(NIX20 ON)
         elseif(${M68K_CRT} STREQUAL "nix13")
@@ -205,6 +207,10 @@ endif()
 if (HAVE_LOCALE_H)
     check_symbol_exists(setlocale   "locale.h" HAVE_SETLOCALE)
     check_symbol_exists(uselocale   "locale.h" HAVE_USELOCALE)
+    if (NOT NIX20 AND NOT NIX13)
+        # libnix does not fully support this yet
+        check_symbol_exists(duplocale   "locale.h" HAVE_DUPLOCALE)
+    endif()
 endif()
 
 # uClibc *intentionally* crashes in duplocale(), at least as of:
@@ -379,7 +385,7 @@ if (NOT ("${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"))
 
        # OSX Mach-O doesn't support linking with '-Bsymbolic-functions'.
        # Others may not support it, too.
-       list(APPEND CMAKE_REQUIRED_LIBRARIES "-Wl,-Bsymbolic-functions")
+       list(APPEND CMAKE_REQUIRED_LIBRARIES "-Wl,-Bsymbolic-functions,-lamiga,-lc")
        check_c_source_compiles(
        "
        int main (void)
index 1327f3a54341b58a042639366e5c6cd437930b43..4b972d6a1d0e1a38b38689417fef833f9d014fa4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -294,7 +294,7 @@ make
 
 libjson-c.a will get created in the build directory.
 
-You can change newlib to nix20, nix13 or clib2 if you would like to build the library suited for libnix or clib2 instead. Newlib is default.
+You can change newlib to nix20, nix13, ixemul or clib2 if you would like to build the library suited for libnix or clib2 instead. Newlib is default.
 
 ### To build for PowerPC Amiga:
 
index 1e6359d0c6e433a0628956d2ef7aa876a9413d2c..651734084a19a52ccaa4de339d7624f7aa1fc593 100644 (file)
 /* Define to 1 if you have the `uselocale' function. */
 #cmakedefine HAVE_USELOCALE
 
+/* Define to 1 if you have the `duplocale' function. */
+#cmakedefine HAVE_DUPLOCALE
+
 /* Define to 1 if newlocale() needs freelocale() called on it's `base` argument */
 #cmakedefine NEWLOCALE_NEEDS_FREELOCALE
 
index 20bad148b69abaa281bcd2cb980870e67fd7a2c0..53ef209563b68871b685e23b41be6c32b6379392 100644 (file)
@@ -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);
        }