]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
compat/strdup.h: move common compat check for strdup() to own file
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Wed, 26 Oct 2016 07:37:50 +0000 (10:37 +0300)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Thu, 3 Nov 2016 13:51:33 +0000 (15:51 +0200)
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
CMakeLists.txt
Makefile.am
compat/strdup.h [new file with mode: 0644]
json-c.vcproj
json-c.vcxproj
json-c.vcxproj.filters
json_object.c
json_tokener.c

index 5015708adf24951a08d91674098268d33978cb0b..39ffe2474aabf76cbfa11e815c5d4d70c242cc74 100644 (file)
@@ -23,6 +23,7 @@ endif()
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
 
 set(JSON_C_HEADERS
+    ./compat/strdup.h
     ./json.h
     ${CMAKE_CURRENT_BINARY_DIR}/include/config.h
     ./json_config.h
index a5d126b0d26aa487ba1faf9875acaab8db8f9bf4..8f7af3850285ae39189f84c264332d3a262a99c7 100644 (file)
@@ -18,6 +18,7 @@ libjson_cincludedir = $(includedir)/json-c
 libjson_cinclude_HEADERS = \
        arraylist.h \
        bits.h \
+       compat/strdup.h \
        debug.h \
        json.h \
        json_c_version.h \
diff --git a/compat/strdup.h b/compat/strdup.h
new file mode 100644 (file)
index 0000000..6b1a34c
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef __STRDUP_H_COMPAT__
+#define __STRDUP_H_COMPAT__
+
+#include "../config.h"
+
+#if !defined(HAVE_STRDUP) && defined(_MSC_VER)
+  /* MSC has the version as _strdup */
+# define strdup _strdup
+#elif !defined(HAVE_STRDUP)
+# error You do not have strdup on your system.
+#endif /* HAVE_STRDUP */
+
+#endif /* __STRDUP_H_COMPAT__ */
index fcda288a1267ce40cefd4242418e52e2d3fafa93..184aa838442e39edd44a8a19ec429a04a1a53d7a 100644 (file)
@@ -131,6 +131,9 @@ copy json_config.h.win32 json_config.h"/>
                        <File
                                RelativePath=".\bits.h">
                        </File>
+                       <File
+                               RelativePath=".\compat\strdup.h">
+                       </File>
                        <File
                                RelativePath=".\debug.h">
                        </File>
index c39ef7e5d6052f92a5365fcac2a33a9c887a5528..d0f1e98148652d6e83d614403d0df5d535c0b9c7 100644 (file)
@@ -141,6 +141,7 @@ copy json_config.h.win32 json_config.h
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="arraylist.h" />
+    <ClInclude Include="compat\strdup.h" />
     <ClInclude Include="debug.h" />
     <ClInclude Include="json_inttypes.h" />
     <ClInclude Include="json_object.h" />
@@ -162,4 +163,4 @@ copy json_config.h.win32 json_config.h
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index 63b6fb14471d79504a866ecbb69387ef64b5f8cf..786106492cd1718577d0f47858636910ec3671de 100644 (file)
@@ -47,6 +47,9 @@
     <ClInclude Include="arraylist.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="compat\strdup.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
     <ClInclude Include="debug.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -87,4 +90,4 @@
     <None Include="README-WIN32.html" />
     <None Include="README.html" />
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index 8a70b5d28077ec5a21c6553bf72a76afa1a45950..17fdd34830ce5bf93b8fa2d858b550365f7d8929 100644 (file)
 #include "json_object_private.h"
 #include "json_util.h"
 #include "math_compat.h"
-
-#if !defined(HAVE_STRDUP) && defined(_MSC_VER)
-  /* MSC has the version as _strdup */
-# define strdup _strdup
-#elif !defined(HAVE_STRDUP)
-# error You do not have strdup on your system.
-#endif /* HAVE_STRDUP */
+#include "compat/strdup.h"
 
 #if !defined(HAVE_SNPRINTF) && defined(_MSC_VER)
   /* MSC has the version as _snprintf */
index 65652f421fff3cca5cc23aa7a9fd25a43a40a6e0..4521ef9a303837d57d5420c0f839da97c72fe58e 100644 (file)
@@ -31,6 +31,7 @@
 #include "json_object.h"
 #include "json_tokener.h"
 #include "json_util.h"
+#include "compat/strdup.h"
 
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 
 #define jt_hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
 
-#if !HAVE_STRDUP && defined(_MSC_VER)
-  /* MSC has the version as _strdup */
-# define strdup _strdup
-#elif !HAVE_STRDUP
-# error You do not have strdup on your system.
-#endif /* HAVE_STRDUP */
-
 #if !HAVE_STRNCASECMP && defined(_MSC_VER)
   /* MSC has the version as _strnicmp */
 # define strncasecmp _strnicmp