extern "C" int __cdecl _wcsicoll ( const wchar_t *_string1, const wchar_t *_string2 ) { if (!__acrt_locale_changed()) { wchar_t f,l; /* validation section */ _VALIDATE_RETURN(_string1 != nullptr, EINVAL, _NLSCMPERROR ); _VALIDATE_RETURN(_string2 != nullptr, EINVAL, _NLSCMPERROR ); do { f = __ascii_towlower(*_string1); l = __ascii_towlower(*_string2); _string1++; _string2++; } while ( (f) && (f == l) ); return (int)(f - l); } else { return _wcsicoll_l(_string1, _string2, nullptr); } }
int __cdecl __wcsicmp ( const wchar_t * dst, const wchar_t * src ) { wchar_t f,l; do { f = __ascii_towlower(*dst); l = __ascii_towlower(*src); dst++; src++; } while ( (f) && (f == l) ); return (int)(f - l); }
extern "C" int __cdecl _wcsicoll_l ( const wchar_t *_string1, const wchar_t *_string2, _locale_t plocinfo ) { int ret; wchar_t f, l; _LocaleUpdate _loc_update(plocinfo); /* validation section */ _VALIDATE_RETURN(_string1 != NULL, EINVAL, _NLSCMPERROR ); _VALIDATE_RETURN(_string2 != NULL, EINVAL, _NLSCMPERROR ); if ( _loc_update.GetLocaleT()->locinfo->lc_handle[LC_COLLATE] == _CLOCALEHANDLE ) { do { f = __ascii_towlower(*_string1); l = __ascii_towlower(*_string2); _string1++; _string2++; } while ( (f) && (f == l) ); return (int)(f - l); } if ( 0 == (ret = __crtCompareStringW( _loc_update.GetLocaleT(), _loc_update.GetLocaleT()->locinfo->lc_handle[LC_COLLATE], SORT_STRINGSORT | NORM_IGNORECASE, _string1, -1, _string2, -1, _loc_update.GetLocaleT()->locinfo->lc_codepage)) ) { errno = EINVAL; return _NLSCMPERROR; } return (ret - 2); }
/* --------------------------------------- 忽略大小写字符串比较 --------------------------------------- */ static int __wcsnicmp_ascii ( __CR_IN__ const wchar_t* string1, __CR_IN__ const wchar_t* string2, __CR_IN__ size_t count ) { wchar_t f, l; int result = 0; if (count) { do { f = __ascii_towlower(*string1); l = __ascii_towlower(*string2); string1++; string2++; } while ((--count) && f && (f == l)); result = (int)(f - l); } return (result); }
// // Compare string with wildcast ignore case. // int __cdecl __wcswicmp(const WCHAR *wild, const WCHAR *string) { const WCHAR *cp = NULL, *mp = NULL; while ((*string) && (*wild != '*')) { if ((__ascii_towlower(*wild) != __ascii_towlower(*string)) && (*wild != '?')) return 0; wild++; string++; } while (*string) { if (*wild == '*') { if (!*++wild) return 1; mp = wild; cp = string+1; } else if ((__ascii_towlower(*wild) == __ascii_towlower(*string)) || (*wild == '?')) { wild++; // cp = string+1; // '*' requires any symbol (*a != a) cp = string; // '*' doesn't require a symbol (*a == a) } else { wild = mp; string = cp++; } } // while (*string) while (*wild == '*') wild++; return !*wild; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Compare string with wildcast ignore case. // int __cdecl __wcswicmp(const WCHAR *wild, const WCHAR *string) { const WCHAR *cp = NULL, *mp = NULL; while ((*string) && (*wild != '*')) { if ((__ascii_towlower(*wild) != __ascii_towlower(*string)) && (*wild != '?')) return 0; wild++; string++; } while (*string) { if (*wild == '*') { if (!*++wild) return 1; mp = wild; cp = string+1; } else if ((__ascii_towlower(*wild) == __ascii_towlower(*string)) || (*wild == '?')) { wild++; string++; } else { wild = mp; string = cp++; } } // while (*string) while (*wild == '*') wild++; return !*wild; }