From: Emmanuele Bassi Date: Mon, 7 Nov 2016 20:51:11 +0000 (+0000) Subject: Revert "compat/strdup.h: move common compat check for strdup() to own file" X-Git-Tag: json-c-0.13-20171207~113^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7601f20d70b37ffc6a0fbe65e24173aa5beadc45;p=json-c Revert "compat/strdup.h: move common compat check for strdup() to own file" This reverts commit aaba8c1080533133329086e47f4f45981dfdd1ee. This commit breaks builddir != srcdir build, but, more importantly, it also adds a dependency on a header, "config.h", which is not installed and it's supposed to be private — since it's generated at configuration time and it's not meant to be used by projects compiling against a library. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 77a9558..6dd38ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ 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 58452fc..41b9e6e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,6 @@ 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 deleted file mode 100644 index 6b1a34c..0000000 --- a/compat/strdup.h +++ /dev/null @@ -1,13 +0,0 @@ -#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 796856e..93aaeb3 100644 --- a/json-c.vcproj +++ b/json-c.vcproj @@ -134,9 +134,6 @@ copy json_config.h.win32 json_config.h"/> - - diff --git a/json-c.vcxproj b/json-c.vcxproj index 02e0c2d..8a4f265 100644 --- a/json-c.vcxproj +++ b/json-c.vcxproj @@ -142,7 +142,6 @@ copy json_config.h.win32 json_config.h - @@ -165,4 +164,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 cc13355..67ff360 100644 --- a/json-c.vcxproj.filters +++ b/json-c.vcxproj.filters @@ -50,9 +50,6 @@ Header Files - - Header Files - Header Files @@ -96,4 +93,4 @@ - + \ No newline at end of file diff --git a/json_object.c b/json_object.c index 17fdd34..8a70b5d 100644 --- a/json_object.c +++ b/json_object.c @@ -29,7 +29,13 @@ #include "json_object_private.h" #include "json_util.h" #include "math_compat.h" -#include "compat/strdup.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 */ #if !defined(HAVE_SNPRINTF) && defined(_MSC_VER) /* MSC has the version as _snprintf */ diff --git a/json_tokener.c b/json_tokener.c index 4521ef9..65652f4 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -31,7 +31,6 @@ #include "json_object.h" #include "json_tokener.h" #include "json_util.h" -#include "compat/strdup.h" #ifdef HAVE_LOCALE_H #include @@ -42,6 +41,13 @@ #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