Commit 37cf8dc5 authored by Eryk Wieliczko's avatar Eryk Wieliczko Committed by Alexandre Julliard

msvcrt: Implement strncat_s.

parent 745126b0
......@@ -1585,7 +1585,7 @@
@ cdecl strftime(str long str ptr) msvcrt.strftime
@ cdecl strlen(str) msvcrt.strlen
@ cdecl strncat(str str long) msvcrt.strncat
@ stub strncat_s
@ cdecl strncat_s(str long str long) msvcrt.strncat_s
@ cdecl strncmp(str str long) msvcrt.strncmp
@ cdecl strncpy(ptr str long) msvcrt.strncpy
@ cdecl strncpy_s(ptr long str long) msvcrt.strncpy_s
......
......@@ -1439,7 +1439,7 @@
@ cdecl strftime(str long str ptr) msvcrt.strftime
@ cdecl strlen(str) msvcrt.strlen
@ cdecl strncat(str str long) msvcrt.strncat
@ stub strncat_s
@ cdecl strncat_s(str long str long) msvcrt.strncat_s
@ cdecl strncmp(str str long) msvcrt.strncmp
@ cdecl strncpy(ptr str long) msvcrt.strncpy
@ cdecl strncpy_s(ptr long str long) msvcrt.strncpy_s
......
......@@ -1423,7 +1423,7 @@
@ cdecl strftime(str long str ptr) msvcrt.strftime
@ cdecl strlen(str) msvcrt.strlen
@ cdecl strncat(str str long) msvcrt.strncat
@ stub strncat_s
@ cdecl strncat_s(str long str long) msvcrt.strncat_s
@ cdecl strncmp(str str long) msvcrt.strncmp
@ cdecl strncpy(ptr str long) msvcrt.strncpy
@ cdecl strncpy_s(ptr long str long) msvcrt.strncpy_s
......
......@@ -1384,7 +1384,7 @@
@ cdecl strftime(str long str ptr) MSVCRT_strftime
@ cdecl strlen(str) ntdll.strlen
@ cdecl strncat(str str long) ntdll.strncat
# stub strncat_s
@ cdecl strncat_s(str long str long) MSVCRT_strncat_s
@ cdecl strncmp(str str long) ntdll.strncmp
@ cdecl strncpy(ptr str long) ntdll.strncpy
@ cdecl strncpy_s(ptr long str long)
......
......@@ -393,6 +393,44 @@ int CDECL MSVCRT_strcat_s( char* dst, MSVCRT_size_t elem, const char* src )
}
/*********************************************************************
* strncat_s (MSVCRT.@)
*/
int CDECL MSVCRT_strncat_s( char* dst, MSVCRT_size_t elem, const char* src, MSVCRT_size_t count )
{
MSVCRT_size_t i, j;
if(!MSVCRT_CHECK_PMT(dst != 0) || !MSVCRT_CHECK_PMT(elem != 0))
return MSVCRT_EINVAL;
if(!MSVCRT_CHECK_PMT(src != 0))
{
dst[0] = '\0';
return MSVCRT_EINVAL;
}
for(i = 0; i < elem; i++)
{
if(dst[i] == '\0')
{
for(j = 0; (j + i) < elem; j++)
{
if(count == MSVCRT__TRUNCATE && j + i == elem - 1)
{
dst[j + i] = '\0';
return MSVCRT_STRUNCATE;
}
if(j == count || (dst[j + i] = src[j]) == '\0')
{
dst[j + i] = '\0';
return 0;
}
}
}
}
/* Set the first element to 0, not the first element after the skipped part */
dst[0] = '\0';
return MSVCRT_ERANGE;
}
/*********************************************************************
* strxfrm (MSVCRT.@)
*/
MSVCRT_size_t CDECL MSVCRT_strxfrm( char *dest, const char *src, MSVCRT_size_t len )
......
......@@ -68,6 +68,7 @@ size_t __cdecl strcspn(const char*,const char*);
char* __cdecl strerror(int);
size_t __cdecl strlen(const char*);
char* __cdecl strncat(char*,const char*,size_t);
errno_t __cdecl strncat_s(char*,size_t,const char*,size_t);
int __cdecl strncmp(const char*,const char*,size_t);
char* __cdecl strncpy(char*,const char*,size_t);
errno_t __cdecl strncpy_s(char*,size_t,const char*,size_t);
......
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