Added proper platform checks for strtok_r

This commit is contained in:
Snaipe 2016-02-06 03:35:51 +01:00
parent 0d3d986c7b
commit 744eb31101
3 changed files with 9 additions and 9 deletions

View file

@ -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)

View file

@ -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

View file

@ -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}"