Commit 9f17544b authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Add _mbscpy_s implementation.

parent aebe1c69
...@@ -1101,8 +1101,8 @@ ...@@ -1101,8 +1101,8 @@
@ stub _mbscmp_l @ stub _mbscmp_l
@ cdecl _mbscoll(str str) @ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscoll_l(str str ptr)
@ stub _mbscpy_s @ cdecl _mbscpy_s(ptr long str)
@ stub _mbscpy_s_l @ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str) @ cdecl _mbscspn(str str)
@ stub _mbscspn_l @ stub _mbscspn_l
@ cdecl _mbsdec(ptr ptr) @ cdecl _mbsdec(ptr ptr)
......
...@@ -1459,8 +1459,8 @@ ...@@ -1459,8 +1459,8 @@
@ stub _mbscmp_l @ stub _mbscmp_l
@ cdecl _mbscoll(str str) @ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscoll_l(str str ptr)
@ stub _mbscpy_s @ cdecl _mbscpy_s(ptr long str)
@ stub _mbscpy_s_l @ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str) @ cdecl _mbscspn(str str)
@ stub _mbscspn_l @ stub _mbscspn_l
@ cdecl _mbsdec(ptr ptr) @ cdecl _mbsdec(ptr ptr)
......
...@@ -773,8 +773,8 @@ ...@@ -773,8 +773,8 @@
@ stub _mbscmp_l @ stub _mbscmp_l
@ cdecl _mbscoll(str str) @ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscoll_l(str str ptr)
@ stub _mbscpy_s @ cdecl _mbscpy_s(ptr long str)
@ stub _mbscpy_s_l @ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str) @ cdecl _mbscspn(str str)
@ stub _mbscspn_l @ stub _mbscspn_l
@ cdecl _mbsdec(ptr ptr) @ cdecl _mbsdec(ptr ptr)
......
...@@ -751,8 +751,8 @@ ...@@ -751,8 +751,8 @@
@ stub _mbscmp_l @ stub _mbscmp_l
@ cdecl _mbscoll(str str) @ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscoll_l(str str ptr)
@ stub _mbscpy_s @ cdecl _mbscpy_s(ptr long str)
@ stub _mbscpy_s_l @ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str) @ cdecl _mbscspn(str str)
@ stub _mbscspn_l @ stub _mbscspn_l
@ cdecl _mbsdec(ptr ptr) @ cdecl _mbsdec(ptr ptr)
......
...@@ -712,6 +712,23 @@ int CDECL _mbsnbcpy_s(unsigned char* dst, MSVCRT_size_t size, const unsigned cha ...@@ -712,6 +712,23 @@ int CDECL _mbsnbcpy_s(unsigned char* dst, MSVCRT_size_t size, const unsigned cha
} }
/********************************************************************* /*********************************************************************
* _mbscpy_s_l(MSVCRT.@)
*/
int CDECL _mbscpy_s_l(unsigned char *dst, MSVCRT_size_t size,
const unsigned char *src, MSVCRT__locale_t locale)
{
return _mbsnbcpy_s_l(dst, size, src, -1, locale);
}
/*********************************************************************
* _mbscpy_s(MSVCRT.@)
*/
int CDECL _mbscpy_s(unsigned char *dst, MSVCRT_size_t size, const unsigned char *src)
{
return _mbscpy_s_l(dst, size, src, NULL);
}
/*********************************************************************
* _mbsnbcpy(MSVCRT.@) * _mbsnbcpy(MSVCRT.@)
* REMARKS * REMARKS
* Like strncpy this function doesn't enforce the string to be * Like strncpy this function doesn't enforce the string to be
......
...@@ -722,8 +722,8 @@ ...@@ -722,8 +722,8 @@
@ cdecl _mbscoll(str str) @ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscoll_l(str str ptr)
@ cdecl _mbscpy(ptr str) @ cdecl _mbscpy(ptr str)
# stub _mbscpy_s(ptr long str) @ cdecl _mbscpy_s(ptr long str)
# stub _mbscpy_s_l(ptr long str ptr) @ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str) @ cdecl _mbscspn(str str)
# stub _mbscspn_l(str str ptr) # stub _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr) @ cdecl _mbsdec(ptr ptr)
......
...@@ -60,6 +60,7 @@ static int (__cdecl *pstrcpy_s)(char *dst, size_t len, const char *src); ...@@ -60,6 +60,7 @@ static int (__cdecl *pstrcpy_s)(char *dst, size_t len, const char *src);
static int (__cdecl *pstrcat_s)(char *dst, size_t len, const char *src); static int (__cdecl *pstrcat_s)(char *dst, size_t len, const char *src);
static int (__cdecl *p_mbsnbcat_s)(unsigned char *dst, size_t size, const unsigned char *src, size_t count); static int (__cdecl *p_mbsnbcat_s)(unsigned char *dst, size_t size, const unsigned char *src, size_t count);
static int (__cdecl *p_mbsnbcpy_s)(unsigned char * dst, size_t size, const unsigned char * src, size_t count); static int (__cdecl *p_mbsnbcpy_s)(unsigned char * dst, size_t size, const unsigned char * src, size_t count);
static int (__cdecl *p__mbscpy_s)(unsigned char*, size_t, const unsigned char*);
static int (__cdecl *p_wcscpy_s)(wchar_t *wcDest, size_t size, const wchar_t *wcSrc); static int (__cdecl *p_wcscpy_s)(wchar_t *wcDest, size_t size, const wchar_t *wcSrc);
static int (__cdecl *p_wcsncpy_s)(wchar_t *wcDest, size_t size, const wchar_t *wcSrc, size_t count); static int (__cdecl *p_wcsncpy_s)(wchar_t *wcDest, size_t size, const wchar_t *wcSrc, size_t count);
static int (__cdecl *p_wcsncat_s)(wchar_t *dst, size_t elem, const wchar_t *src, size_t count); static int (__cdecl *p_wcsncat_s)(wchar_t *dst, size_t elem, const wchar_t *src, size_t count);
...@@ -774,6 +775,42 @@ static void test__mbsnbcpy_s(void) ...@@ -774,6 +775,42 @@ static void test__mbsnbcpy_s(void)
dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]); dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
} }
static void test__mbscpy_s(void)
{
const unsigned char src[] = "source string";
unsigned char dest[16];
int ret;
if(!p__mbscpy_s)
{
win_skip("_mbscpy_s not found\n");
return;
}
ret = p__mbscpy_s(NULL, 0, src);
ok(ret == EINVAL, "got %d\n", ret);
ret = p__mbscpy_s(NULL, sizeof(dest), src);
ok(ret == EINVAL, "got %d\n", ret);
ret = p__mbscpy_s(dest, 0, src);
ok(ret == EINVAL, "got %d\n", ret);
dest[0] = 'x';
ret = p__mbscpy_s(dest, sizeof(dest), NULL);
ok(ret == EINVAL, "got %d\n", ret);
ok(!dest[0], "dest buffer was not modified on invalid argument\n");
memset(dest, 'X', sizeof(dest));
ret = p__mbscpy_s(dest, sizeof(dest), src);
ok(!ret, "got %d\n", ret);
ok(!memcmp(dest, src, sizeof(src)), "dest = %s\n", dest);
ok(dest[sizeof(src)] == 'X', "unused part of buffer was modified\n");
memset(dest, 'X', sizeof(dest));
ret = p__mbscpy_s(dest, 4, src);
ok(ret == ERANGE, "got %d\n", ret);
ok(!dest[0], "incorrect dest buffer (%d)\n", dest[0]);
ok(dest[1] == src[1], "incorrect dest buffer (%d)\n", dest[1]);
}
static void test_wcscpy_s(void) static void test_wcscpy_s(void)
{ {
static const WCHAR szLongText[] = { 'T','h','i','s','A','L','o','n','g','s','t','r','i','n','g',0 }; static const WCHAR szLongText[] = { 'T','h','i','s','A','L','o','n','g','s','t','r','i','n','g',0 };
...@@ -2632,6 +2669,7 @@ START_TEST(string) ...@@ -2632,6 +2669,7 @@ START_TEST(string)
pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" ); pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" );
p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_s" ); p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_s" );
p_mbsnbcpy_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcpy_s" ); p_mbsnbcpy_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcpy_s" );
p__mbscpy_s = (void *)GetProcAddress( hMsvcrt,"_mbscpy_s" );
p_wcscpy_s = (void *)GetProcAddress( hMsvcrt,"wcscpy_s" ); p_wcscpy_s = (void *)GetProcAddress( hMsvcrt,"wcscpy_s" );
p_wcsncpy_s = (void *)GetProcAddress( hMsvcrt,"wcsncpy_s" ); p_wcsncpy_s = (void *)GetProcAddress( hMsvcrt,"wcsncpy_s" );
p_wcsncat_s = (void *)GetProcAddress( hMsvcrt,"wcsncat_s" ); p_wcsncat_s = (void *)GetProcAddress( hMsvcrt,"wcsncat_s" );
...@@ -2679,6 +2717,7 @@ START_TEST(string) ...@@ -2679,6 +2717,7 @@ START_TEST(string)
test_memmove_s(); test_memmove_s();
test_strcat_s(); test_strcat_s();
test__mbsnbcpy_s(); test__mbsnbcpy_s();
test__mbscpy_s();
test_mbcjisjms(); test_mbcjisjms();
test_mbcjmsjis(); test_mbcjmsjis();
test_mbbtombc(); test_mbbtombc();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment