Procházet zdrojové kódy

Merge pull request #203 from Casperinous/master

Fix for #202 issue.
Max Bruckner před 7 roky
rodič
revize
28328a0b34
3 změnil soubory, kde provedl 11 přidání a 0 odebrání
  1. 6 0
      CMakeLists.txt
  2. 1 0
      README.md
  3. 4 0
      cJSON.c

+ 6 - 0
CMakeLists.txt

@@ -186,5 +186,11 @@ if(ENABLE_CJSON_TEST)
         DEPENDS ${TEST_CJSON})
 endif()
 
+# Enable the use of locales
+option(ENABLE_LOCALES "Enable the use of locales" ON)
+if(ENABLE_LOCALES)
+	add_definitions(-DENABLE_LOCALES)
+endif() 
+
 add_subdirectory(tests)
 add_subdirectory(fuzzing)

+ 1 - 0
README.md

@@ -90,6 +90,7 @@ You can change the build process with a list of different options that you can p
 * `-DENABLE_SANITIZERS=On`: Compile cJSON with [AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer) and [UndefinedBehaviorSanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html) enabled (if possible). (off by default)
 * `-DBUILD_SHARED_LIBS=On`: Build the shared libraries. (on by default)
 * `-DCMAKE_INSTALL_PREFIX=/usr`: Set a prefix for the installation.
+* `-DENABLE_LOCALES=On`: Enable the usage of localeconv method. ( on by default )
 
 If you are packaging cJSON for a distribution of Linux, you would probably take these steps for example:
 ```

+ 4 - 0
cJSON.c

@@ -193,8 +193,12 @@ CJSON_PUBLIC(void) cJSON_Delete(cJSON *item)
 /* get the decimal point character of the current locale */
 static unsigned char get_decimal_point(void)
 {
+#ifdef ENABLE_LOCALES
     struct lconv *lconv = localeconv();
     return (unsigned char) lconv->decimal_point[0];
+#else
+    return '.';
+#endif
 }
 
 typedef struct