diff --git a/dlls/api-ms-win-crt-string-l1-1-0/api-ms-win-crt-string-l1-1-0.spec b/dlls/api-ms-win-crt-string-l1-1-0/api-ms-win-crt-string-l1-1-0.spec index 78544371d23..ead56fbcb5a 100644 --- a/dlls/api-ms-win-crt-string-l1-1-0/api-ms-win-crt-string-l1-1-0.spec +++ b/dlls/api-ms-win-crt-string-l1-1-0/api-ms-win-crt-string-l1-1-0.spec @@ -87,7 +87,7 @@ @ cdecl _wcsnicoll(wstr wstr long) ucrtbase._wcsnicoll @ cdecl _wcsnicoll_l(wstr wstr long ptr) ucrtbase._wcsnicoll_l @ cdecl _wcsnset(wstr long long) ucrtbase._wcsnset -@ stub _wcsnset_s +@ cdecl _wcsnset_s(wstr long long long) ucrtbase._wcsnset_s @ cdecl _wcsrev(wstr) ucrtbase._wcsrev @ cdecl _wcsset(wstr long) ucrtbase._wcsset @ cdecl _wcsset_s(wstr long long) ucrtbase._wcsset_s diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 668fb5809bc..e435766e8a2 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1507,7 +1507,7 @@ @ cdecl _wcsnicoll(wstr wstr long) MSVCRT__wcsnicoll @ cdecl _wcsnicoll_l(wstr wstr long ptr) MSVCRT__wcsnicoll_l @ cdecl _wcsnset(wstr long long) MSVCRT__wcsnset -@ stub _wcsnset_s +@ cdecl _wcsnset_s(wstr long long long) MSVCRT__wcsnset_s @ cdecl _wcsrev(wstr) MSVCRT__wcsrev @ cdecl _wcsset(wstr long) MSVCRT__wcsset @ cdecl _wcsset_s(wstr long long) MSVCRT__wcsset_s diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index 220c1223b52..39dfb8c3256 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -1865,7 +1865,7 @@ @ cdecl _wcsnicoll(wstr wstr long) MSVCRT__wcsnicoll @ cdecl _wcsnicoll_l(wstr wstr long ptr) MSVCRT__wcsnicoll_l @ cdecl _wcsnset(wstr long long) MSVCRT__wcsnset -@ stub _wcsnset_s +@ cdecl _wcsnset_s(wstr long long long) MSVCRT__wcsnset_s @ cdecl _wcsrev(wstr) MSVCRT__wcsrev @ cdecl _wcsset(wstr long) MSVCRT__wcsset @ cdecl _wcsset_s(wstr long long) MSVCRT__wcsset_s diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index 28b849aaea9..8cd39ea19e9 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -1883,7 +1883,7 @@ @ cdecl _wcsnicoll(wstr wstr long) MSVCRT__wcsnicoll @ cdecl _wcsnicoll_l(wstr wstr long ptr) MSVCRT__wcsnicoll_l @ cdecl _wcsnset(wstr long long) MSVCRT__wcsnset -@ stub _wcsnset_s +@ cdecl _wcsnset_s(wstr long long long) MSVCRT__wcsnset_s @ cdecl _wcsrev(wstr) MSVCRT__wcsrev @ cdecl _wcsset(wstr long) MSVCRT__wcsset @ cdecl _wcsset_s(wstr long long) MSVCRT__wcsset_s diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec index 2bb377bf372..dc3f3bd807d 100644 --- a/dlls/msvcr120_app/msvcr120_app.spec +++ b/dlls/msvcr120_app/msvcr120_app.spec @@ -1576,7 +1576,7 @@ @ cdecl _wcsnicoll(wstr wstr long) msvcr120._wcsnicoll @ cdecl _wcsnicoll_l(wstr wstr long ptr) msvcr120._wcsnicoll_l @ cdecl _wcsnset(wstr long long) msvcr120._wcsnset -@ stub _wcsnset_s +@ cdecl _wcsnset_s(wstr long long long) msvcr120._wcsnset_s @ cdecl _wcsrev(wstr) msvcr120._wcsrev @ cdecl _wcsset(wstr long) msvcr120._wcsset @ cdecl _wcsset_s(wstr long long) msvcr120._wcsset_s diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 53826db9990..c9208b22f51 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -1186,7 +1186,7 @@ @ cdecl _wcsnicoll(wstr wstr long) MSVCRT__wcsnicoll @ cdecl _wcsnicoll_l(wstr wstr long ptr) MSVCRT__wcsnicoll_l @ cdecl _wcsnset(wstr long long) MSVCRT__wcsnset -@ stub _wcsnset_s +@ cdecl _wcsnset_s(wstr long long long) MSVCRT__wcsnset_s @ cdecl _wcsrev(wstr) MSVCRT__wcsrev @ cdecl _wcsset(wstr long) MSVCRT__wcsset @ cdecl _wcsset_s(wstr long long) MSVCRT__wcsset_s diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 5a9f8913194..7a2ce051cfb 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -1162,7 +1162,7 @@ @ cdecl _wcsnicoll(wstr wstr long) MSVCRT__wcsnicoll @ cdecl _wcsnicoll_l(wstr wstr long ptr) MSVCRT__wcsnicoll_l @ cdecl _wcsnset(wstr long long) MSVCRT__wcsnset -@ stub _wcsnset_s +@ cdecl _wcsnset_s(wstr long long long) MSVCRT__wcsnset_s @ cdecl _wcsrev(wstr) MSVCRT__wcsrev @ cdecl _wcsset(wstr long) MSVCRT__wcsset @ cdecl _wcsset_s(wstr long long) MSVCRT__wcsset_s diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index d4526162649..101e2c7ce5f 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -1117,7 +1117,7 @@ @ cdecl _wcsnicoll(wstr wstr long) MSVCRT__wcsnicoll @ cdecl _wcsnicoll_l(wstr wstr long ptr) MSVCRT__wcsnicoll_l @ cdecl _wcsnset(wstr long long) MSVCRT__wcsnset -# stub _wcsnset_s(wstr long long) +@ cdecl _wcsnset_s(wstr long long long) MSVCRT__wcsnset_s @ cdecl _wcsrev(wstr) MSVCRT__wcsrev @ cdecl _wcsset(wstr long) MSVCRT__wcsset @ cdecl _wcsset_s(wstr long long) MSVCRT__wcsset_s diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 09492e37884..cbfa53a3731 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -101,6 +101,7 @@ static int (__cdecl *p__atodbl_l)(_CRT_DOUBLE*,char*,_locale_t); static double (__cdecl *p__atof_l)(const char*,_locale_t); static double (__cdecl *p__strtod_l)(const char *,char**,_locale_t); static int (__cdecl *p__strnset_s)(char*,size_t,int,size_t); +static int (__cdecl *p__wcsnset_s)(wchar_t*,size_t,wchar_t,size_t); static int (__cdecl *p__wcsset_s)(wchar_t*,size_t,wchar_t); static size_t (__cdecl *p__mbsnlen)(const unsigned char*, size_t); static int (__cdecl *p__mbccpy_s)(unsigned char*, size_t, int*, const unsigned char*); @@ -3221,6 +3222,45 @@ static void test__strnset_s(void) ok(!buf[0] && buf[1]=='c' && buf[2]=='b', "buf = %s\n", buf); } +static void test__wcsnset_s(void) +{ + wchar_t text[] = { 't','e','x','t',0 }; + int r; + + if(!p__wcsnset_s) { + win_skip("_wcsnset_s not available\n"); + return; + } + + r = p__wcsnset_s(NULL, 0, 'a', 0); + ok(r == 0, "r = %d\n", r); + + r = p__wcsnset_s(text, 0, 'a', 1); + ok(r == EINVAL, "r = %d\n", r); + ok(text[0] == 't', "text[0] = %d\n", text[0]); + + r = p__wcsnset_s(NULL, 2, 'a', 1); + ok(r == EINVAL, "r = %d\n", r); + + r = p__wcsnset_s(text, 2, 'a', 3); + ok(r == EINVAL, "r = %d\n", r); + ok(text[0] == 0, "text[0] = %d\n", text[0]); + ok(text[1] == 'e', "text[1] = %d\n", text[1]); + + text[0] = 't'; + r = p__wcsnset_s(text, 5, 'a', 1); + ok(r == 0, "r = %d\n", r); + ok(text[0] == 'a', "text[0] = %d\n", text[0]); + ok(text[1] == 'e', "text[1] = %d\n", text[1]); + + text[1] = 0; + r = p__wcsnset_s(text, 5, 'b', 3); + ok(r == 0, "r = %d\n", r); + ok(text[0] == 'b', "text[0] = %d\n", text[0]); + ok(text[1] == 0, "text[1] = %d\n", text[1]); + ok(text[2] == 'x', "text[2] = %d\n", text[2]); +} + static void test__wcsset_s(void) { wchar_t str[10]; @@ -3788,6 +3828,7 @@ START_TEST(string) p__atof_l = (void*)GetProcAddress(hMsvcrt, "_atof_l"); p__strtod_l = (void*)GetProcAddress(hMsvcrt, "_strtod_l"); p__strnset_s = (void*)GetProcAddress(hMsvcrt, "_strnset_s"); + p__wcsnset_s = (void*)GetProcAddress(hMsvcrt, "_wcsnset_s"); p__wcsset_s = (void*)GetProcAddress(hMsvcrt, "_wcsset_s"); p__mbsnlen = (void*)GetProcAddress(hMsvcrt, "_mbsnlen"); p__mbccpy_s = (void*)GetProcAddress(hMsvcrt, "_mbccpy_s"); @@ -3854,6 +3895,7 @@ START_TEST(string) test_strncpy(); test_strxfrm(); test__strnset_s(); + test__wcsnset_s(); test__wcsset_s(); test__mbscmp(); test__ismbclx(); diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 28e82ec3030..2a75030aa13 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -173,6 +173,30 @@ MSVCRT_wchar_t* CDECL MSVCRT__wcsnset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c, MS return ret; } +/********************************************************************* + * _wcsnset_s (MSVCRT.@) + */ +int CDECL MSVCRT__wcsnset_s( MSVCRT_wchar_t *str, MSVCRT_size_t size, MSVCRT_wchar_t c, MSVCRT_size_t count ) +{ + MSVCRT_size_t i; + + if(!str && !size && !count) return 0; + if(!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL; + if(!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL; + + for(i=0; i