msvcrt: Add _mbscpy_s implementation.

oldstable
Piotr Caban 2014-05-19 11:43:05 +02:00 committed by Alexandre Julliard
parent aebe1c69f9
commit 9f17544bc9
7 changed files with 66 additions and 10 deletions

View File

@ -1101,8 +1101,8 @@
@ stub _mbscmp_l
@ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr)
@ stub _mbscpy_s
@ stub _mbscpy_s_l
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbsdec(ptr ptr)

View File

@ -1459,8 +1459,8 @@
@ stub _mbscmp_l
@ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr)
@ stub _mbscpy_s
@ stub _mbscpy_s_l
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbsdec(ptr ptr)

View File

@ -773,8 +773,8 @@
@ stub _mbscmp_l
@ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr)
@ stub _mbscpy_s
@ stub _mbscpy_s_l
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbsdec(ptr ptr)

View File

@ -751,8 +751,8 @@
@ stub _mbscmp_l
@ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr)
@ stub _mbscpy_s
@ stub _mbscpy_s_l
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbsdec(ptr ptr)

View File

@ -711,6 +711,23 @@ int CDECL _mbsnbcpy_s(unsigned char* dst, MSVCRT_size_t size, const unsigned cha
return _mbsnbcpy_s_l(dst, size, src, n, NULL);
}
/*********************************************************************
* _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.@)
* REMARKS

View File

@ -722,8 +722,8 @@
@ cdecl _mbscoll(str str)
@ cdecl _mbscoll_l(str str ptr)
@ cdecl _mbscpy(ptr str)
# stub _mbscpy_s(ptr long str)
# stub _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
# stub _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr)

View File

@ -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 *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__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_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);
@ -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]);
}
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 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)
pstrcat_s = (void *)GetProcAddress( hMsvcrt,"strcat_s" );
p_mbsnbcat_s = (void *)GetProcAddress( hMsvcrt,"_mbsnbcat_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_wcsncpy_s = (void *)GetProcAddress( hMsvcrt,"wcsncpy_s" );
p_wcsncat_s = (void *)GetProcAddress( hMsvcrt,"wcsncat_s" );
@ -2679,6 +2717,7 @@ START_TEST(string)
test_memmove_s();
test_strcat_s();
test__mbsnbcpy_s();
test__mbscpy_s();
test_mbcjisjms();
test_mbcjmsjis();
test_mbbtombc();