From: Alexandru Ardelean Date: Wed, 26 Oct 2016 07:37:50 +0000 (+0300) Subject: compat/strdup.h: move common compat check for strdup() to own file X-Git-Tag: json-c-0.13-20171207~114^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aaba8c1080533133329086e47f4f45981dfdd1ee;p=thirdparty%2Fjson-c.git compat/strdup.h: move common compat check for strdup() to own file Signed-off-by: Alexandru Ardelean --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5015708a..39ffe247 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Makefile.am b/Makefile.am index a5d126b0..8f7af385 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 00000000..6b1a34c8 --- /dev/null +++ b/compat/strdup.h @@ -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__ */ diff --git a/json-c.vcproj b/json-c.vcproj index fcda288a..184aa838 100644 --- a/json-c.vcproj +++ b/json-c.vcproj @@ -131,6 +131,9 @@ copy json_config.h.win32 json_config.h"/> + + diff --git a/json-c.vcxproj b/json-c.vcxproj index c39ef7e5..d0f1e981 100644 --- a/json-c.vcxproj +++ b/json-c.vcxproj @@ -141,6 +141,7 @@ copy json_config.h.win32 json_config.h + @@ -162,4 +163,4 @@ copy json_config.h.win32 json_config.h - \ No newline at end of file + diff --git a/json-c.vcxproj.filters b/json-c.vcxproj.filters index 63b6fb14..78610649 100644 --- a/json-c.vcxproj.filters +++ b/json-c.vcxproj.filters @@ -47,6 +47,9 @@ Header Files + + Header Files + Header Files @@ -87,4 +90,4 @@ - \ No newline at end of file + diff --git a/json_object.c b/json_object.c index 8a70b5d2..17fdd348 100644 --- a/json_object.c +++ b/json_object.c @@ -29,13 +29,7 @@ #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 */ diff --git a/json_tokener.c b/json_tokener.c index 65652f42..4521ef9a 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -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 @@ -41,13 +42,6 @@ #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