use wcs(n)casecmp() if available; use wxStricmp() to implement wxString::CmpNoCase() as it's significantly more efficient than wx code (closes #10375)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58155 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2009-01-16 19:03:26 +00:00
parent ca44dbde5f
commit 6689960c3c
5 changed files with 47 additions and 27 deletions

6
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in 58060 2009-01-12 23:25:39Z FM .
# From configure.in Id: configure.in 58069 2009-01-13 12:01:30Z FM .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for wxWidgets 2.9.0.
#
@ -34957,7 +34957,9 @@ _ACEOF
for ac_func in wcsdup strnlen wcsnlen
for ac_func in wcsdup strnlen wcsnlen wcscasecmp wcsncasecmp
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5

View File

@ -4047,7 +4047,7 @@ if test "$wxUSE_WCHAR_T" = "yes"; then
AC_DEFINE(HAVE_WCSLEN)
fi
AC_CHECK_FUNCS([wcsdup strnlen wcsnlen])
AC_CHECK_FUNCS([wcsdup strnlen wcsnlen wcscasecmp wcsncasecmp])
dnl On HP-UX aCC need this define to find mbstrtowcs() &c
dnl Can't be used for g++ since the mbstate_t in wchar.h can conflict

View File

@ -233,31 +233,39 @@ WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
/* define wxCRT_StricmpA/W and wxCRT_StrnicmpA/W for various compilers */
/* note that we definitely are going to need our own version for widechar
* versions */
#if !defined(wxCRT_StricmpA)
#if defined(__BORLANDC__) || defined(__WATCOMC__) || \
defined(__VISAGECPP__) || \
defined(__EMX__) || defined(__DJGPP__)
#define wxCRT_StricmpA stricmp
#define wxCRT_StrnicmpA strnicmp
#elif defined(__WXPALMOS__)
/* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
* quick hack should do until one can be written.
*/
#define wxCRT_StricmpA StrCaselessCompare
#define wxCRT_StrnicmpA StrNCaselessCompare
#elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
(defined(__MWERKS__) && defined(__INTEL__))
#define wxCRT_StricmpA _stricmp
#define wxCRT_StrnicmpA _strnicmp
#elif defined(__UNIX__) || defined(__GNUWIN32__)
#define wxCRT_StricmpA strcasecmp
#define wxCRT_StrnicmpA strncasecmp
/* #else -- use wxWidgets implementation */
#if defined(__BORLANDC__) || defined(__WATCOMC__) || \
defined(__VISAGECPP__) || \
defined(__EMX__) || defined(__DJGPP__)
#define wxCRT_StricmpA stricmp
#define wxCRT_StrnicmpA strnicmp
#elif defined(__WXPALMOS__)
/* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
* quick hack should do until one can be written.
*/
#define wxCRT_StricmpA StrCaselessCompare
#define wxCRT_StrnicmpA StrNCaselessCompare
#elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
(defined(__MWERKS__) && defined(__INTEL__))
#define wxCRT_StricmpA _stricmp
#define wxCRT_StrnicmpA _strnicmp
#elif defined(__UNIX__) || defined(__GNUWIN32__)
#define wxCRT_StricmpA strcasecmp
#define wxCRT_StrnicmpA strncasecmp
/* #else -- use wxWidgets implementation */
#endif
#ifdef __VISUALC__
#define wxCRT_StricmpW _wcsicmp
#define wxCRT_StrnicmpW _wcsnicmp
#elif defined(__UNIX__)
#ifdef HAVE_WCSCASECMP
#define wxCRT_StricmpW wcscasecmp
#endif
#endif /* !defined(wxCRT_StricmpA) */
/* FIXME-UTF8: use wcs(n)casecmp if available for *W versions */
#ifdef HAVE_WCSNCASECMP
#define wxCRT_StrnicmpW wcsncasecmp
#endif
/* #else -- use wxWidgets implementation */
#endif
#ifdef HAVE_STRTOK_R
#define wxCRT_StrtokA(str, sep, last) strtok_r(str, sep, last)

View File

@ -912,6 +912,12 @@
/* Define if you have usleep() */
#undef HAVE_USLEEP
/* Define if you have wcscasecmp() function */
#undef HAVE_WCSCASECMP
/* Define if you have wcsncasecmp() function */
#undef HAVE_WCSNCASECMP
/* Define if you have wcslen function */
#undef HAVE_WCSLEN

View File

@ -1115,6 +1115,7 @@ size_t wxString::find_last_not_of(const wxOtherCharType* sz, size_t nStart,
int wxString::CmpNoCase(const wxString& s) const
{
#if wxUSE_UNICODE_UTF8
// FIXME-UTF8: use wxUniChar::ToLower/ToUpper once added
const_iterator i1 = begin();
@ -1138,6 +1139,9 @@ int wxString::CmpNoCase(const wxString& s) const
else if ( len1 > len2 )
return 1;
return 0;
#else // wxUSE_UNICODE_WCHAR or ANSI
return wxStricmp(m_impl.c_str(), s.m_impl.c_str());
#endif
}