msvcrt: Implement _wcsnset_s.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46902
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gijs Vermeulen 2019-04-01 19:57:07 +02:00 committed by Alexandre Julliard
parent bc501222f0
commit 92ba9e7b6d
11 changed files with 75 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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.@)
*/

View File

@ -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