From dbec250635d6bef389dbbf3296e949f4653b1276 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 24 Dec 2012 12:10:21 +0100 Subject: [PATCH] msvcrt: Added _stricmp_l implementation. --- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/msvcrt.h | 2 ++ dlls/msvcrt/msvcrt.spec | 6 +++--- dlls/msvcrt/string.c | 39 ++++++++++++++++++++++++++++++++++++- dlls/msvcrt/tests/string.c | 31 +++++++++++++++++++++++++++++ 7 files changed, 77 insertions(+), 7 deletions(-) diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index a09b142429e..64b4105c2b6 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1331,7 +1331,7 @@ @ stub _strerror_s @ stub _strftime_l @ cdecl _stricmp(str str) msvcrt._stricmp -@ stub _stricmp_l +@ cdecl _stricmp_l(str str ptr) msvcrt._stricmp_l @ cdecl _stricoll(str str) msvcrt._stricoll @ cdecl _stricoll_l(str str ptr) msvcrt._stricoll_l @ cdecl _strlwr(str) msvcrt._strlwr diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 4457c2c7751..91147cf7f04 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -993,7 +993,7 @@ @ stub _strerror_s @ stub _strftime_l @ cdecl _stricmp(str str) msvcrt._stricmp -@ stub _stricmp_l +@ cdecl _stricmp_l(str str ptr) msvcrt._stricmp_l @ cdecl _stricoll(str str) msvcrt._stricoll @ cdecl _stricoll_l(str str ptr) msvcrt._stricoll_l @ cdecl _strlwr(str) msvcrt._strlwr diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index c20c5fd4828..abde1412181 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -986,7 +986,7 @@ @ stub _strerror_s @ stub _strftime_l @ cdecl _stricmp(str str) msvcrt._stricmp -@ stub _stricmp_l +@ cdecl _stricmp_l(str str ptr) msvcrt._stricmp_l @ cdecl _stricoll(str str) msvcrt._stricoll @ cdecl _stricoll_l(str str ptr) msvcrt._stricoll_l @ cdecl _strlwr(str) msvcrt._strlwr diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 0d0886f6019..096f77a0c86 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -863,6 +863,8 @@ typedef void (__cdecl *MSVCRT___sighandler_t)(int); /* _get_output_format return code */ #define MSVCRT__TWO_DIGIT_EXPONENT 0x1 +#define MSVCRT__NLSCMPERROR ((unsigned int)0x7fffffff) + void __cdecl MSVCRT_free(void*); void* __cdecl MSVCRT_malloc(MSVCRT_size_t); void* __cdecl MSVCRT_calloc(MSVCRT_size_t,MSVCRT_size_t); diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 6802104051b..3d15a21bf96 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -918,7 +918,7 @@ @ cdecl _stat64(str ptr) MSVCRT_stat64 @ cdecl _stati64(str ptr) MSVCRT_stati64 @ cdecl _statusfp() -@ cdecl _strcmpi(str str) ntdll._strcmpi +@ cdecl _strcmpi(str str) MSVCRT__stricmp @ cdecl _strcoll_l(str str ptr) MSVCRT_strcoll_l @ cdecl _strdate(ptr) MSVCRT__strdate @ cdecl _strdate_s(ptr long) @@ -926,8 +926,8 @@ # stub _strdup_dbg(str long str long) @ cdecl _strerror(long) MSVCRT__strerror # stub _strerror_s(ptr long long) -@ cdecl _stricmp(str str) ntdll._stricmp -# stub _stricmp_l(str str ptr) +@ cdecl _stricmp(str str) MSVCRT__stricmp +@ cdecl _stricmp_l(str str ptr) MSVCRT__stricmp_l @ cdecl _stricoll(str str) MSVCRT__stricoll @ cdecl _stricoll_l(str str ptr) MSVCRT__stricoll_l @ cdecl _strlwr(str) MSVCRT__strlwr diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index a2541587da8..b457510dcb6 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -1551,9 +1551,46 @@ int CDECL MSVCRT_I10_OUTPUT(MSVCRT__LDOUBLE ld80, int prec, int flag, struct _I1 #undef I10_OUTPUT_MAX_PREC /********************************************************************* - * memcpy (NTDLL.@) + * memcpy (MSVCRT.@) */ void * __cdecl MSVCRT_memcpy( void *dst, const void *src, size_t n ) { return memmove( dst, src, n ); } + +/********************************************************************* + * _stricmp_l (MSVCRT.@) + */ +int __cdecl MSVCRT__stricmp_l(const char *s1, const char *s2, MSVCRT__locale_t locale) +{ + MSVCRT_pthreadlocinfo locinfo; + char c1, c2; + + if(!MSVCRT_CHECK_PMT(s1!=NULL && s2!=NULL)) + return MSVCRT__NLSCMPERROR; + + if(!locale) + locinfo = get_locinfo(); + else + locinfo = locale->locinfo; + + if(!locinfo->lc_handle[MSVCRT_LC_CTYPE]) + return strcasecmp(s1, s2); + + do { + c1 = MSVCRT__tolower_l(*s1++, locale); + c2 = MSVCRT__tolower_l(*s2++, locale); + if(c1 != c2) + break; + }while(c1 && c1==c2); + + return c1-c2; +} + +/********************************************************************* + * _stricmp (MSVCRT.@) + */ +int __cdecl MSVCRT__stricmp(const char *s1, const char *s2) +{ + return MSVCRT__stricmp_l(s1, s2, NULL); +} diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index bbaeda062de..f2fd8f964a7 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -2438,6 +2438,36 @@ static void test__atodbl(void) ok(ret == _OVERFLOW, "_atodbl(&d, \"1e309\") returned %d, expected _OVERFLOW\n", ret); } +static void test__stricmp(void) +{ + int ret; + + ret = _stricmp("test", "test"); + ok(ret == 0, "_stricmp returned %d\n", ret); + ret = _stricmp("a", "z"); + ok(ret < 0, "_stricmp returned %d\n", ret); + ret = _stricmp("z", "a"); + ok(ret > 0, "_stricmp returned %d\n", ret); + ret = _stricmp("\xa5", "\xb9"); + ok(ret < 0, "_stricmp returned %d\n", ret); + + if(!setlocale(LC_ALL, "polish")) { + win_skip("stricmp tests"); + return; + } + + ret = _stricmp("test", "test"); + ok(ret == 0, "_stricmp returned %d\n", ret); + ret = _stricmp("a", "z"); + ok(ret < 0, "_stricmp returned %d\n", ret); + ret = _stricmp("z", "a"); + ok(ret > 0, "_stricmp returned %d\n", ret); + ret = _stricmp("\xa5", "\xb9"); + ok(ret == 0, "_stricmp returned %d\n", ret); + + setlocale(LC_ALL, "C"); +} + START_TEST(string) { char mem[100]; @@ -2533,4 +2563,5 @@ START_TEST(string) test_wctomb(); test_tolower(); test__atodbl(); + test__stricmp(); }