msvcrt: Added strncpy_s implementation.
This commit is contained in:
parent
c483bebe2b
commit
23d0369d9d
|
@ -1388,7 +1388,7 @@
|
|||
@ stub strncat_s
|
||||
@ cdecl strncmp(str str long) msvcrt.strncmp
|
||||
@ cdecl strncpy(ptr str long) msvcrt.strncpy
|
||||
@ stub strncpy_s
|
||||
@ cdecl strncpy_s(ptr long str long) msvcrt.strncpy_s
|
||||
@ cdecl strnlen(str long) msvcrt.strnlen
|
||||
@ cdecl strpbrk(str str) msvcrt.strpbrk
|
||||
@ cdecl strrchr(str long) msvcrt.strrchr
|
||||
|
|
|
@ -1372,7 +1372,7 @@
|
|||
@ stub strncat_s
|
||||
@ cdecl strncmp(str str long) msvcrt.strncmp
|
||||
@ cdecl strncpy(ptr str long) msvcrt.strncpy
|
||||
@ stub strncpy_s
|
||||
@ cdecl strncpy_s(ptr long str long) msvcrt.strncpy_s
|
||||
@ cdecl strnlen(str long) msvcrt.strnlen
|
||||
@ cdecl strpbrk(str str) msvcrt.strpbrk
|
||||
@ cdecl strrchr(str long) msvcrt.strrchr
|
||||
|
|
|
@ -550,3 +550,41 @@ int CDECL memmove_s(void *dest, MSVCRT_size_t numberOfElements, const void *src,
|
|||
memmove(dest, src, count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* strncpy_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL strncpy_s(char *dest, MSVCRT_size_t numberOfElements,
|
||||
const char *src, MSVCRT_size_t count)
|
||||
{
|
||||
MSVCRT_size_t i, end;
|
||||
|
||||
TRACE("(%s %lu %s %lu)\n", dest, numberOfElements, src, count);
|
||||
|
||||
if(!count)
|
||||
return 0;
|
||||
|
||||
if(!dest || !src || !numberOfElements) {
|
||||
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_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_parameter(NULL, NULL, NULL, 0, 0);
|
||||
dest[0] = '\0';
|
||||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return MSVCRT_EINVAL;
|
||||
}
|
||||
|
|
|
@ -1328,7 +1328,7 @@
|
|||
# stub strncat_s
|
||||
@ cdecl strncmp(str str long) ntdll.strncmp
|
||||
@ cdecl strncpy(ptr str long) ntdll.strncpy
|
||||
# stub strncpy_s
|
||||
@ cdecl strncpy_s(ptr long str long)
|
||||
@ cdecl strnlen(str long) MSVCRT_strnlen
|
||||
@ cdecl strpbrk(str str) ntdll.strpbrk
|
||||
@ cdecl strrchr(str long) ntdll.strrchr
|
||||
|
|
Loading…
Reference in New Issue