Module: wine Branch: master Commit: eaa1b7060375f819146cce127d401a2161db6ea1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=eaa1b7060375f819146cce127d...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Dec 26 12:04:59 2012 +0100
msvcrt: Added _strnicmp_l implementation.
---
dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/msvcrt.spec | 4 ++-- dlls/msvcrt/string.c | 32 +++++++++++++++++++++++++------- 5 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 64b4105..4838a14 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1341,7 +1341,7 @@ @ cdecl _strncoll(str str long) msvcrt._strncoll @ cdecl _strncoll_l(str str long ptr) msvcrt._strncoll_l @ cdecl _strnicmp(str str long) msvcrt._strnicmp -@ stub _strnicmp_l +@ cdecl _strnicmp_l(str str long ptr) msvcrt._strnicmp_l @ cdecl _strnicoll(str str long) msvcrt._strnicoll @ cdecl _strnicoll_l(str str long ptr) msvcrt._strnicoll_l @ cdecl _strnset(str long long) msvcrt._strnset diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 91147cf..0144e08 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -1003,7 +1003,7 @@ @ cdecl _strncoll(str str long) msvcrt._strncoll @ cdecl _strncoll_l(str str long ptr) msvcrt._strncoll_l @ cdecl _strnicmp(str str long) msvcrt._strnicmp -@ stub _strnicmp_l +@ cdecl _strnicmp_l(str str long ptr) msvcrt._strnicmp_l @ cdecl _strnicoll(str str long) msvcrt._strnicoll @ cdecl _strnicoll_l(str str long ptr) msvcrt._strnicoll_l @ cdecl _strnset(str long long) msvcrt._strnset diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index abde141..dd91d5e 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -996,7 +996,7 @@ @ cdecl _strncoll(str str long) msvcrt._strncoll @ cdecl _strncoll_l(str str long ptr) msvcrt._strncoll_l @ cdecl _strnicmp(str str long) msvcrt._strnicmp -@ stub _strnicmp_l +@ cdecl _strnicmp_l(str str long ptr) msvcrt._strnicmp_l @ cdecl _strnicoll(str str long) msvcrt._strnicoll @ cdecl _strnicoll_l(str str long ptr) msvcrt._strnicoll_l @ cdecl _strnset(str long long) msvcrt._strnset diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 3d15a21..29b459b 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -936,8 +936,8 @@ @ cdecl _strlwr_s_l(ptr long ptr) @ cdecl _strncoll(str str long) MSVCRT_strncoll_l @ cdecl _strncoll_l(str str long ptr) MSVCRT_strncoll -@ cdecl _strnicmp(str str long) ntdll._strnicmp -# stub _strnicmp_l(str str long ptr) +@ cdecl _strnicmp(str str long) MSVCRT__strnicmp +@ cdecl _strnicmp_l(str str long ptr) MSVCRT__strnicmp_l @ cdecl _strnicoll(str str long) MSVCRT__strnicoll @ cdecl _strnicoll_l(str str long ptr) MSVCRT__strnicoll_l @ cdecl _strnset(str long long) MSVCRT__strnset diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index b457510..d9ec353 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -1559,9 +1559,10 @@ void * __cdecl MSVCRT_memcpy( void *dst, const void *src, size_t n ) }
/********************************************************************* - * _stricmp_l (MSVCRT.@) + * _strnicmp_l (MSVCRT.@) */ -int __cdecl MSVCRT__stricmp_l(const char *s1, const char *s2, MSVCRT__locale_t locale) +int __cdecl MSVCRT__strnicmp_l(const char *s1, const char *s2, + MSVCRT_size_t count, MSVCRT__locale_t locale) { MSVCRT_pthreadlocinfo locinfo; char c1, c2; @@ -1569,28 +1570,45 @@ int __cdecl MSVCRT__stricmp_l(const char *s1, const char *s2, MSVCRT__locale_t l if(!MSVCRT_CHECK_PMT(s1!=NULL && s2!=NULL)) return MSVCRT__NLSCMPERROR;
+ if(!count) + return 0; + if(!locale) locinfo = get_locinfo(); else locinfo = locale->locinfo;
if(!locinfo->lc_handle[MSVCRT_LC_CTYPE]) - return strcasecmp(s1, s2); + return strncasecmp(s1, s2, count);
do { c1 = MSVCRT__tolower_l(*s1++, locale); c2 = MSVCRT__tolower_l(*s2++, locale); - if(c1 != c2) - break; - }while(c1 && c1==c2); + }while(--count && c1 && c1==c2);
return c1-c2; }
/********************************************************************* + * _stricmp_l (MSVCRT.@) + */ +int __cdecl MSVCRT__stricmp_l(const char *s1, const char *s2, MSVCRT__locale_t locale) +{ + return MSVCRT__strnicmp_l(s1, s2, -1, locale); +} + +/********************************************************************* + * _strnicmp (MSVCRT.@) + */ +int __cdecl MSVCRT__strnicmp(const char *s1, const char *s2, MSVCRT_size_t count) +{ + return MSVCRT__strnicmp_l(s1, s2, count, NULL); +} + +/********************************************************************* * _stricmp (MSVCRT.@) */ int __cdecl MSVCRT__stricmp(const char *s1, const char *s2) { - return MSVCRT__stricmp_l(s1, s2, NULL); + return MSVCRT__strnicmp_l(s1, s2, -1, NULL); }