Added SDL_wcscasecmp() and SDL_wcsncasecmp()
authorSam Lantinga
Tue, 24 Nov 2020 12:43:01 -0800
changeset 143807ef432b4e3dc
parent 14379 0bed6ba4e2bc
child 14381 f76496049e93
Added SDL_wcscasecmp() and SDL_wcsncasecmp()
configure
configure.ac
include/SDL_config.h.in
include/SDL_config_windows.h
include/SDL_stdinc.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/stdlib/SDL_string.c
     1.1 --- a/configure	Tue Nov 24 07:56:59 2020 -0800
     1.2 +++ b/configure	Tue Nov 24 12:43:01 2020 -0800
     1.3 @@ -17072,7 +17072,7 @@
     1.4  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     1.5  fi
     1.6  
     1.7 -    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll _Exit
     1.8 +    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll _Exit
     1.9  do :
    1.10    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
    1.11  ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
     2.1 --- a/configure.ac	Tue Nov 24 07:56:59 2020 -0800
     2.2 +++ b/configure.ac	Tue Nov 24 12:43:01 2020 -0800
     2.3 @@ -346,7 +346,7 @@
     2.4          AC_DEFINE(HAVE_MPROTECT, 1, [ ])
     2.5          ]),
     2.6      )
     2.7 -    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll _Exit)
     2.8 +    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll _Exit)
     2.9  
    2.10      AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
    2.11      AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
     3.1 --- a/include/SDL_config.h.in	Tue Nov 24 07:56:59 2020 -0800
     3.2 +++ b/include/SDL_config.h.in	Tue Nov 24 12:43:01 2020 -0800
     3.3 @@ -103,6 +103,10 @@
     3.4  #undef HAVE_WCSSTR
     3.5  #undef HAVE_WCSCMP
     3.6  #undef HAVE_WCSNCMP
     3.7 +#undef HAVE_WCSCASECMP
     3.8 +#undef HAVE__WCSICMP
     3.9 +#undef HAVE_WCSNCASECMP
    3.10 +#undef HAVE__WCSNICMP
    3.11  #undef HAVE_STRLEN
    3.12  #undef HAVE_STRLCPY
    3.13  #undef HAVE_STRLCAT
     4.1 --- a/include/SDL_config_windows.h	Tue Nov 24 07:56:59 2020 -0800
     4.2 +++ b/include/SDL_config_windows.h	Tue Nov 24 12:43:01 2020 -0800
     4.3 @@ -134,6 +134,8 @@
     4.4  #define HAVE_STRNCMP 1
     4.5  #define HAVE__STRICMP 1
     4.6  #define HAVE__STRNICMP 1
     4.7 +#define HAVE__WCSICMP 1
     4.8 +#define HAVE__WCSNICMP 1
     4.9  #define HAVE_ACOS   1
    4.10  #define HAVE_ACOSF  1
    4.11  #define HAVE_ASIN   1
     5.1 --- a/include/SDL_stdinc.h	Tue Nov 24 07:56:59 2020 -0800
     5.2 +++ b/include/SDL_stdinc.h	Tue Nov 24 12:43:01 2020 -0800
     5.3 @@ -469,6 +469,8 @@
     5.4  
     5.5  extern DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2);
     5.6  extern DECLSPEC int SDLCALL SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen);
     5.7 +extern DECLSPEC int SDLCALL SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2);
     5.8 +extern DECLSPEC int SDLCALL SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t len);
     5.9  
    5.10  extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
    5.11  extern DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen);
     6.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Tue Nov 24 07:56:59 2020 -0800
     6.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Tue Nov 24 12:43:01 2020 -0800
     6.3 @@ -786,3 +786,5 @@
     6.4  #define SDL_GameControllerSetSensorEnabled SDL_GameControllerSetSensorEnabled_REAL
     6.5  #define SDL_GameControllerIsSensorEnabled SDL_GameControllerIsSensorEnabled_REAL
     6.6  #define SDL_GameControllerGetSensorData SDL_GameControllerGetSensorData_REAL
     6.7 +#define SDL_wcscasecmp SDL_wcscasecmp_REAL
     6.8 +#define SDL_wcsncasecmp SDL_wcsncasecmp_REAL
     7.1 --- a/src/dynapi/SDL_dynapi_procs.h	Tue Nov 24 07:56:59 2020 -0800
     7.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Tue Nov 24 12:43:01 2020 -0800
     7.3 @@ -847,3 +847,5 @@
     7.4  SDL_DYNAPI_PROC(int,SDL_GameControllerSetSensorEnabled,(SDL_GameController *a, SDL_SensorType b, SDL_bool c),(a,b,c),return)
     7.5  SDL_DYNAPI_PROC(SDL_bool,SDL_GameControllerIsSensorEnabled,(SDL_GameController *a, SDL_SensorType b),(a,b),return)
     7.6  SDL_DYNAPI_PROC(int,SDL_GameControllerGetSensorData,(SDL_GameController *a, SDL_SensorType b, float *c, int d),(a,b,c,d),return)
     7.7 +SDL_DYNAPI_PROC(int,SDL_wcscasecmp,(const wchar_t *a, const wchar_t *b),(a,b),return)
     7.8 +SDL_DYNAPI_PROC(int,SDL_wcsncasecmp,(const wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return)
     8.1 --- a/src/stdlib/SDL_string.c	Tue Nov 24 07:56:59 2020 -0800
     8.2 +++ b/src/stdlib/SDL_string.c	Tue Nov 24 12:43:01 2020 -0800
     8.3 @@ -531,6 +531,85 @@
     8.4  #endif /* HAVE_WCSNCMP */
     8.5  }
     8.6  
     8.7 +int
     8.8 +SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2)
     8.9 +{
    8.10 +#if defined(HAVE_WCSCASECMP)
    8.11 +    return wcscasecmp(str1, str2);
    8.12 +#elif defined(HAVE__WCSICMP)
    8.13 +    return _wcsicmp(str1, str2);
    8.14 +#else
    8.15 +    wchar_t a = 0;
    8.16 +    wchar_t b = 0;
    8.17 +    while (*str1 && *str2) {
    8.18 +        /* FIXME: This doesn't actually support wide characters */
    8.19 +        if (*str1 >= 0x80 || *str2 >= 0x80) {
    8.20 +            a = *str1;
    8.21 +            b = *str2;
    8.22 +        } else {
    8.23 +            a = SDL_toupper((unsigned char) *str1);
    8.24 +            b = SDL_toupper((unsigned char) *str2);
    8.25 +        }
    8.26 +        if (a != b)
    8.27 +            break;
    8.28 +        ++str1;
    8.29 +        ++str2;
    8.30 +    }
    8.31 +
    8.32 +    /* FIXME: This doesn't actually support wide characters */
    8.33 +    if (*str1 >= 0x80 || *str2 >= 0x80) {
    8.34 +        a = *str1;
    8.35 +        b = *str2;
    8.36 +    } else {
    8.37 +        a = SDL_toupper((unsigned char) *str1);
    8.38 +        b = SDL_toupper((unsigned char) *str2);
    8.39 +    }
    8.40 +    return (int) ((unsigned int) a - (unsigned int) b);
    8.41 +#endif /* HAVE__WCSICMP */
    8.42 +}
    8.43 +
    8.44 +int
    8.45 +SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
    8.46 +{
    8.47 +#if defined(HAVE_WCSNCASECMP)
    8.48 +    return wcsncasecmp(str1, str2, maxlen);
    8.49 +#elif defined(HAVE__WCSNICMP)
    8.50 +    return _wcsnicmp(str1, str2, maxlen);
    8.51 +#else
    8.52 +    wchar_t a = 0;
    8.53 +    wchar_t b = 0;
    8.54 +    while (*str1 && *str2 && maxlen) {
    8.55 +        /* FIXME: This doesn't actually support wide characters */
    8.56 +        if (*str1 >= 0x80 || *str2 >= 0x80) {
    8.57 +            a = *str1;
    8.58 +            b = *str2;
    8.59 +        } else {
    8.60 +            a = SDL_toupper((unsigned char) *str1);
    8.61 +            b = SDL_toupper((unsigned char) *str2);
    8.62 +        }
    8.63 +        if (a != b)
    8.64 +            break;
    8.65 +        ++str1;
    8.66 +        ++str2;
    8.67 +        --maxlen;
    8.68 +    }
    8.69 +
    8.70 +    if (maxlen == 0) {
    8.71 +        return 0;
    8.72 +    } else {
    8.73 +        /* FIXME: This doesn't actually support wide characters */
    8.74 +        if (*str1 >= 0x80 || *str2 >= 0x80) {
    8.75 +            a = *str1;
    8.76 +            b = *str2;
    8.77 +        } else {
    8.78 +            a = SDL_toupper((unsigned char) *str1);
    8.79 +            b = SDL_toupper((unsigned char) *str2);
    8.80 +        }
    8.81 +        return (int) ((unsigned int) a - (unsigned int) b);
    8.82 +    }
    8.83 +#endif /* HAVE__WCSNICMP */
    8.84 +}
    8.85 +
    8.86  size_t
    8.87  SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
    8.88  {