src: add CURL_STRICMP() macro, use _stricmp() on Windows

Add `CURL_STRICMP()` macro that works on all platforms depending on
which lib C function is available.

Make sure to always use `_stricmp()` on Windows, which is the
non-deprecated, official API for this on this platform. Before this
patch it used a MinGW-specific call, or a deprecated compatibility
wrapper with MSVC.

Drop `stricmp` variant detections on Windows with autotools.

https://learn.microsoft.com/cpp/c-runtime-library/reference/stricmp-wcsicmp-mbsicmp-stricmp-l-wcsicmp-l-mbsicmp-l

Ref: #15652
Closes #15788
This commit is contained in:
Viktor Szakats 2024-11-27 12:34:38 +01:00
parent 68bd759c2b
commit 6dacd2f208
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
7 changed files with 28 additions and 37 deletions

View file

@ -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 <strings.h>
# 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;