Kick out strtok_r, all our platforms should have it (or strtok_s)

This commit is contained in:
Marek Roszko 2023-09-06 22:49:27 -04:00
parent f45d61ef18
commit 72669df354
5 changed files with 9 additions and 46 deletions

View File

@ -77,6 +77,7 @@ macro( perform_feature_checks )
check_symbol_exists( strncasecmp "string.h" HAVE_STRNCASECMP )
check_symbol_exists( strncasecmp "strings.h" HAVE_STRNCASECMP )
check_symbol_exists( strtok_r "string.h" HAVE_STRTOKR )
check_symbol_exists( strtok_s "string.h" HAVE_STRTOKS )
check_cxx_symbol_exists( strcasecmp "string.h" HAVE_STRCASECMP )
check_cxx_symbol_exists( strncasecmp "string.h" HAVE_STRNCASECMP )

View File

@ -7,7 +7,15 @@
#cmakedefine HAVE_STRNCASECMP
#cmakedefine HAVE_STRTOKS
#ifdef HAVE_STRTOKS
// strtok_s is the actual C11 standard rather than posix strtok_r
// but its also an optional standard, MSVC supports it, so alias it
#define HAVE_STRTOKR
#define strtok_r strtok_s
#else
#cmakedefine HAVE_STRTOKR // spelled oddly to differ from wx's similar test
#endif
// Handle platform differences in math.h
#cmakedefine HAVE_MATH_H

View File

@ -412,10 +412,6 @@ if( TRUE OR NOT USE_KIWAY_DLLS )
endif()
endif()
if( NOT HAVE_STRTOKR )
list( APPEND COMMON_SRCS strtok_r.c )
endif()
list( APPEND COMMON_SRCS
kicad_curl/kicad_curl.cpp
kicad_curl/kicad_curl_easy.cpp

View File

@ -1,35 +0,0 @@
/*
* public domain strtok_r()
*/
#include <string.h>
char* strtok_r( char* str, const char* delim, char** nextp )
{
char* ret;
if( str == NULL )
{
str = *nextp;
}
str += strspn( str, delim );
if( *str == '\0' )
{
return NULL;
}
ret = str;
str += strcspn( str, delim );
if( *str )
{
*str++ = '\0';
}
*nextp = str;
return ret;
}

View File

@ -24,8 +24,6 @@
#ifndef STRING_UTILS_H
#define STRING_UTILS_H
#include "config.h"
#include <string>
#include <vector>
#include <wx/string.h>
@ -230,11 +228,6 @@ wxString GetIllegalFileNameWxChars();
bool ReplaceIllegalFileNameChars( std::string* aName, int aReplaceChar = 0 );
bool ReplaceIllegalFileNameChars( wxString& aName, int aReplaceChar = 0 );
#ifndef HAVE_STRTOKR
// common/strtok_r.c optionally:
extern "C" char* strtok_r( char* str, const char* delim, char** nextp );
#endif
/**
* A helper for sorting strings from the rear.