diff --git a/CMake/Platforms/WindowsCache.cmake b/CMake/Platforms/WindowsCache.cmake index 175a8b0be8..f5dea6aacc 100644 --- a/CMake/Platforms/WindowsCache.cmake +++ b/CMake/Platforms/WindowsCache.cmake @@ -36,7 +36,6 @@ if(MINGW) set(HAVE_BOOL_T "${HAVE_STDBOOL_H}") set(HAVE_STRTOLL 1) set(HAVE_BASENAME 1) - set(HAVE_STRCASECMP 1) set(HAVE_FTRUNCATE 1) set(HAVE_SYS_PARAM_H 1) set(HAVE_SYS_TIME_H 1) @@ -47,7 +46,6 @@ if(MINGW) set(HAVE_OPENDIR 1) else() set(HAVE_LIBGEN_H 0) - set(HAVE_STRCASECMP 0) set(HAVE_FTRUNCATE 0) set(HAVE_SYS_PARAM_H 0) set(HAVE_SYS_TIME_H 0) @@ -149,8 +147,6 @@ set(HAVE_FSEEKO 0) # mingw-w64 2.0.0 and newer has it set(HAVE_SOCKET 1) set(HAVE_SELECT 1) set(HAVE_STRDUP 1) -set(HAVE_STRICMP 1) -set(HAVE_STRCMPI 1) set(HAVE_MEMRCHR 0) set(HAVE_CLOSESOCKET 1) set(HAVE_SIGSETJMP 0) diff --git a/CMakeLists.txt b/CMakeLists.txt index 964be8b2d9..d60a77100b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1631,9 +1631,6 @@ check_function_exists("sendmmsg" HAVE_SENDMMSG) check_symbol_exists("select" "${CURL_INCLUDES}" HAVE_SELECT) # proto/bsdsocket.h sys/select.h sys/socket.h check_symbol_exists("strdup" "string.h" HAVE_STRDUP) check_symbol_exists("strtok_r" "string.h" HAVE_STRTOK_R) -check_symbol_exists("strcasecmp" "string.h" HAVE_STRCASECMP) -check_symbol_exists("stricmp" "string.h" HAVE_STRICMP) -check_symbol_exists("strcmpi" "string.h" HAVE_STRCMPI) check_symbol_exists("memrchr" "string.h" HAVE_MEMRCHR) check_symbol_exists("alarm" "unistd.h" HAVE_ALARM) check_symbol_exists("fcntl" "fcntl.h" HAVE_FCNTL) @@ -1672,6 +1669,12 @@ check_function_exists("setlocale" HAVE_SETLOCALE) check_function_exists("setmode" HAVE_SETMODE) check_function_exists("setrlimit" HAVE_SETRLIMIT) +if(NOT WIN32) + check_symbol_exists("strcasecmp" "string.h" HAVE_STRCASECMP) + check_symbol_exists("stricmp" "string.h" HAVE_STRICMP) + check_symbol_exists("strcmpi" "string.h" HAVE_STRCMPI) +endif() + if(WIN32 OR CYGWIN) check_function_exists("_setmode" HAVE__SETMODE) endif() diff --git a/configure.ac b/configure.ac index d1e87f101a..e1c06aff81 100644 --- a/configure.ac +++ b/configure.ac @@ -4021,11 +4021,8 @@ CURL_CHECK_FUNC_SIGNAL CURL_CHECK_FUNC_SIGSETJMP CURL_CHECK_FUNC_SOCKET CURL_CHECK_FUNC_SOCKETPAIR -CURL_CHECK_FUNC_STRCASECMP -CURL_CHECK_FUNC_STRCMPI CURL_CHECK_FUNC_STRDUP CURL_CHECK_FUNC_STRERROR_R -CURL_CHECK_FUNC_STRICMP CURL_CHECK_FUNC_STRTOK_R CURL_CHECK_FUNC_STRTOLL @@ -4066,6 +4063,12 @@ AC_CHECK_FUNCS([\ utimes \ ]) +if test "$curl_cv_native_windows" != 'yes'; then + CURL_CHECK_FUNC_STRCASECMP + CURL_CHECK_FUNC_STRCMPI + CURL_CHECK_FUNC_STRICMP +fi + if test "$curl_cv_native_windows" = 'yes' -o "$curl_cv_cygwin" = 'yes'; then AC_CHECK_FUNCS([_setmode]) fi diff --git a/lib/config-win32.h b/lib/config-win32.h index cc4d5cb3df..1f280a96c6 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -158,17 +158,9 @@ /* Define if you have the socket function. */ #define HAVE_SOCKET 1 -/* Define if you have the strcasecmp function. */ -#if defined(__MINGW32__) -#define HAVE_STRCASECMP 1 -#endif - /* Define if you have the strdup function. */ #define HAVE_STRDUP 1 -/* Define if you have the stricmp function. */ -#define HAVE_STRICMP 1 - /* Define if you have the strtoll function. */ #if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || defined(__MINGW32__) #define HAVE_STRTOLL 1 diff --git a/lib/config-win32ce.h b/lib/config-win32ce.h index ba801110ad..492d74350c 100644 --- a/lib/config-win32ce.h +++ b/lib/config-win32ce.h @@ -114,15 +114,9 @@ /* Define if you have the socket function. */ #define HAVE_SOCKET 1 -/* Define if you have the strcasecmp function. */ -/* #define HAVE_STRCASECMP 1 */ - /* Define if you have the strdup function. */ /* #define HAVE_STRDUP 1 */ -/* Define if you have the stricmp function. */ -/* #define HAVE_STRICMP 1 */ - /* Define if you have the strtoll function. */ #if defined(__MINGW32__) #define HAVE_STRTOLL 1 diff --git a/src/tool_setup.h b/src/tool_setup.h index 82eb6e5a0b..8c89e60275 100644 --- a/src/tool_setup.h +++ b/src/tool_setup.h @@ -66,6 +66,21 @@ extern FILE *tool_stderr; # include "tool_strdup.h" #endif +#if defined(_WIN32) +# define CURL_STRICMP(p1, p2) _stricmp(p1, p2) +#elif defined(HAVE_STRCASECMP) +# ifdef HAVE_STRINGS_H +# include +# endif +# define CURL_STRICMP(p1, p2) strcasecmp(p1, p2) +#elif defined(HAVE_STRCMPI) +# define CURL_STRICMP(p1, p2) strcmpi(p1, p2) +#elif defined(HAVE_STRICMP) +# define CURL_STRICMP(p1, p2) stricmp(p1, p2) +#else +# define CURL_STRICMP(p1, p2) strcmp(p1, p2) +#endif + #if defined(_WIN32) /* set in win32_init() */ extern LARGE_INTEGER tool_freq; diff --git a/src/tool_util.c b/src/tool_util.c index 69b1d2b42a..8a078890d4 100644 --- a/src/tool_util.c +++ b/src/tool_util.c @@ -23,10 +23,6 @@ ***************************************************************************/ #include "tool_setup.h" -#if defined(HAVE_STRCASECMP) && defined(HAVE_STRINGS_H) -#include -#endif - #include "tool_util.h" #include "curlx.h" @@ -181,15 +177,7 @@ int struplocompare(const char *p1, const char *p2) return p2 ? -1 : 0; if(!p2) return 1; -#ifdef HAVE_STRCASECMP - return strcasecmp(p1, p2); -#elif defined(HAVE_STRCMPI) - return strcmpi(p1, p2); -#elif defined(HAVE_STRICMP) - return stricmp(p1, p2); -#else - return strcmp(p1, p2); -#endif + return CURL_STRICMP(p1, p2); } /* Indirect version to use as qsort callback. */