diff --git a/source/lib/posix/posix.cpp b/source/lib/posix/posix.cpp index 21297fbb07..c4d9e68cab 100644 --- a/source/lib/posix/posix.cpp +++ b/source/lib/posix/posix.cpp @@ -101,3 +101,24 @@ wchar_t* wcsdup(const wchar_t* str) return dst; } #endif + +#if EMULATE_WCSCASECMP +int wcscasecmp (const wchar_t* s1, const wchar_t* s2) +{ + wint_t a1, a2; + + if (s1 == s2) + return 0; + + do + { + a1 = towlower(*s1++); + a2 = towlower(*s2++); + if (a1 == L'\0') + break; + } + while (a1 == a2); + + return a1 - a2; +} +#endif diff --git a/source/lib/posix/posix.h b/source/lib/posix/posix.h index 618247ab8c..deb0b86e25 100644 --- a/source/lib/posix/posix.h +++ b/source/lib/posix/posix.h @@ -96,14 +96,19 @@ need only be renamed (e.g. _open, _stat). #if OS_MACOSX # define EMULATE_WCSDUP 1 +# define EMULATE_WCSCASECMP 1 #else # define EMULATE_WCSDUP 0 +# define EMULATE_WCSCASECMP 0 #endif #if EMULATE_WCSDUP extern wchar_t* wcsdup(const wchar_t* str); #endif +#if EMULATE_WCSCASECMP +extern int wcscasecmp(const wchar_t* s1, const wchar_t* s2); +#endif // rint*, fminf, fpclassify (too few/diverse to make separate HAVE_ for each) #if HAVE_C99 || ICC_VERSION || GCC_VERSION