mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 15:34:56 +00:00
msvcrt: Move the strncpy_s() implementation to string.c.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
aa7a4b7803
commit
3514e65f26
|
@ -827,44 +827,6 @@ int CDECL wmemcpy_s(wchar_t *dest, size_t numberOfElements,
|
|||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* strncpy_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL strncpy_s(char *dest, size_t numberOfElements,
|
||||
const char *src, size_t count)
|
||||
{
|
||||
size_t i, end;
|
||||
|
||||
TRACE("(%p %Iu %s %Iu)\n", dest, numberOfElements, debugstr_a(src), count);
|
||||
|
||||
if(!count) {
|
||||
if(dest && numberOfElements)
|
||||
*dest = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return EINVAL;
|
||||
|
||||
if(count!=_TRUNCATE && count<numberOfElements)
|
||||
end = count;
|
||||
else
|
||||
end = numberOfElements-1;
|
||||
|
||||
for(i=0; i<end && src[i]; i++)
|
||||
dest[i] = src[i];
|
||||
|
||||
if(!src[i] || end==count || count==_TRUNCATE) {
|
||||
dest[i] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
MSVCRT_INVALID_PMT("dest[numberOfElements] is too small", EINVAL);
|
||||
dest[0] = '\0';
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
BOOL msvcrt_init_heap(void)
|
||||
{
|
||||
heap = HeapCreate(0, 0, 0);
|
||||
|
|
|
@ -1268,6 +1268,44 @@ char* __cdecl strncpy(char *dst, const char *src, size_t len)
|
|||
return dst;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* strncpy_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL strncpy_s(char *dest, size_t numberOfElements,
|
||||
const char *src, size_t count)
|
||||
{
|
||||
size_t i, end;
|
||||
|
||||
TRACE("(%p %Iu %s %Iu)\n", dest, numberOfElements, debugstr_a(src), count);
|
||||
|
||||
if(!count) {
|
||||
if(dest && numberOfElements)
|
||||
*dest = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return EINVAL;
|
||||
|
||||
if(count!=_TRUNCATE && count<numberOfElements)
|
||||
end = count;
|
||||
else
|
||||
end = numberOfElements-1;
|
||||
|
||||
for(i=0; i<end && src[i]; i++)
|
||||
dest[i] = src[i];
|
||||
|
||||
if(!src[i] || end==count || count==_TRUNCATE) {
|
||||
dest[i] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
MSVCRT_INVALID_PMT("dest[numberOfElements] is too small", EINVAL);
|
||||
dest[0] = '\0';
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* strcpy (MSVCRT.@)
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue