msvcrt: Added support for _TRUNCATE flag in wcsncpy_s.
This commit is contained in:
parent
f900ed1474
commit
a80aec4c56
|
@ -682,6 +682,12 @@ static void test_wcscpy_s(void)
|
|||
ret = p_wcsncpy_s(szDestShort, 8, szLongText, sizeof(szLongText)/sizeof(WCHAR));
|
||||
ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
|
||||
ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
|
||||
|
||||
szDest[0] = 'A';
|
||||
ret = p_wcsncpy_s(szDest, 5, szLongText, -1);
|
||||
ok(ret == STRUNCATE, "expected STRUNCATE got %d\n", ret);
|
||||
ok(szDest[4] == 0, "szDest[4] not 0\n");
|
||||
ok(!memcmp(szDest, szLongText, 4*sizeof(WCHAR)), "szDest = %s\n", wine_dbgstr_w(szDest));
|
||||
}
|
||||
|
||||
static void test__wcsupr_s(void)
|
||||
|
|
|
@ -1230,6 +1230,7 @@ INT CDECL MSVCRT_wcsncpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, co
|
|||
MSVCRT_size_t count )
|
||||
{
|
||||
MSVCRT_size_t size = 0;
|
||||
INT ret = 0;
|
||||
|
||||
if (!wcDest || !numElement)
|
||||
return MSVCRT_EINVAL;
|
||||
|
@ -1242,8 +1243,12 @@ INT CDECL MSVCRT_wcsncpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, co
|
|||
}
|
||||
|
||||
size = min(strlenW(wcSrc), count);
|
||||
|
||||
if (size >= numElement)
|
||||
if (count==MSVCRT__TRUNCATE && size>=numElement)
|
||||
{
|
||||
ret = MSVCRT_STRUNCATE;
|
||||
size = numElement-1;
|
||||
}
|
||||
else if (size >= numElement)
|
||||
{
|
||||
return MSVCRT_ERANGE;
|
||||
}
|
||||
|
@ -1251,7 +1256,7 @@ INT CDECL MSVCRT_wcsncpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, co
|
|||
memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
|
||||
wcDest[size] = '\0';
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
|
Loading…
Reference in New Issue