diff --git a/.cmake/Modules/Capabilities.cmake b/.cmake/Modules/Capabilities.cmake index ad93937..006cf22 100644 --- a/.cmake/Modules/Capabilities.cmake +++ b/.cmake/Modules/Capabilities.cmake @@ -4,6 +4,7 @@ include(CheckPrototypeDefinition) include(CheckLibraryExists) +include(CheckFunctionExists) include(PackageUtils) # Check for packages @@ -21,12 +22,8 @@ cr_find_package (PCRE PKGCONFIG libpcre) # Check for functions -check_prototype_definition( - strtok_s - "char *strtok_s(char *strToken, const char *strDelimit, char **context)" - NULL - "string.h" - HAVE_STRTOK_S) +check_function_exists(strtok_s HAVE_STRTOK_S) +check_function_exists(strtok_r HAVE_STRTOK_R) check_library_exists (rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) diff --git a/src/compat/strtok.h b/src/compat/strtok.h index 78fc227..f733bdd 100644 --- a/src/compat/strtok.h +++ b/src/compat/strtok.h @@ -27,12 +27,14 @@ # include "config.h" # ifdef VANILLA_WIN32 -# if HAVE_STRTOK_S -# define strtok_r strtok_s -# else +# if !HAVE_STRTOK_R +# if HAVE_STRTOK_S +# define strtok_r strtok_s +# else static CR_INLINE char *strtok_r(char *str, const char *delim, CR_UNUSED char **saveptr) { return strtok(str, delim); } +# endif # endif # ifdef _MSC_VER diff --git a/src/config.h.in b/src/config.h.in index 0040dad..4561f06 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -6,6 +6,7 @@ #cmakedefine ENABLE_VALGRIND_ERRORS @ENABLE_VALGRIND_ERRORS@ #cmakedefine MINGW_DEFINE_OFF_T @MINGW_DEFINE_OFF_T@ #cmakedefine01 HAVE_STRTOK_S +#cmakedefine01 HAVE_STRTOK_R # define LOCALEDIR "${LOCALEDIR}" # define PACKAGE "${PROJECT_NAME}"