Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46902 Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- .../api-ms-win-crt-string-l1-1-0.spec | 2 +- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr120/msvcr120.spec | 2 +- dlls/msvcr120_app/msvcr120_app.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/msvcrt.spec | 2 +- dlls/msvcrt/tests/string.c | 42 +++++++++++++++++++ dlls/msvcrt/wcs.c | 24 +++++++++++ dlls/ucrtbase/ucrtbase.spec | 2 +- 11 files changed, 75 insertions(+), 9 deletions(-)
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 78544371d2..ead56fbcb5 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 e8e9cca41e..17dec164db 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 c7f99f7f53..fc70280a9d 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 568f2fb19d..1aa4eda89d 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 2bb377bf37..dc3f3bd807 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 63a470fc1b..3fa5d9e651 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 3554c7bf31..262f306c10 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 ca9ff60644..d11dad9871 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 ff3a87d69d..8c242875aa 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]; @@ -3787,6 +3827,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"); @@ -3853,6 +3894,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 28e82ec303..2a75030aa1 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<size-1 && i<count; i++) { + if(!str[i]) return 0; + str[i] = c; + } + for(; i<size; i++) + if(!str[i]) return 0; + + str[0] = 0; + MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0); + *MSVCRT__errno() = MSVCRT_EINVAL; + return MSVCRT_EINVAL; +} + /********************************************************************* * _wcsrev (MSVCRT.@) */ diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index 544ebf8c92..0a74205d8b 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -2032,7 +2032,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