Commit 41f488a3 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Add strcpy_s and wcscpy_s.

Implementation copied from msvcrt. Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c948a6cf
...@@ -1590,6 +1590,7 @@ ...@@ -1590,6 +1590,7 @@
@ cdecl strchr(str long) @ cdecl strchr(str long)
@ cdecl strcmp(str str) @ cdecl strcmp(str str)
@ cdecl strcpy(ptr str) @ cdecl strcpy(ptr str)
@ cdecl strcpy_s(ptr long str)
@ cdecl strcspn(str str) @ cdecl strcspn(str str)
@ cdecl strlen(str) @ cdecl strlen(str)
@ cdecl strncat(str str long) @ cdecl strncat(str str long)
...@@ -1618,6 +1619,7 @@ ...@@ -1618,6 +1619,7 @@
@ cdecl wcschr(wstr long) @ cdecl wcschr(wstr long)
@ cdecl wcscmp(wstr wstr) @ cdecl wcscmp(wstr wstr)
@ cdecl wcscpy(ptr wstr) @ cdecl wcscpy(ptr wstr)
@ cdecl wcscpy_s(ptr long wstr)
@ cdecl wcscspn(wstr wstr) @ cdecl wcscspn(wstr wstr)
@ cdecl wcslen(wstr) @ cdecl wcslen(wstr)
@ cdecl wcsncat(wstr wstr long) @ cdecl wcsncat(wstr wstr long)
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
*/ */
#include <limits.h> #include <limits.h>
#include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
...@@ -257,6 +258,26 @@ char * __cdecl strcpy( char *dst, const char *src ) ...@@ -257,6 +258,26 @@ char * __cdecl strcpy( char *dst, const char *src )
/********************************************************************* /*********************************************************************
* strcpy_s (NTDLL.@)
*/
errno_t __cdecl strcpy_s( char *dst, size_t len, const char *src )
{
size_t i;
if (!dst || !len) return EINVAL;
if (!src)
{
*dst = 0;
return EINVAL;
}
for (i = 0; i < len; i++) if (!(dst[i] = src[i])) return 0;
*dst = 0;
return ERANGE;
}
/*********************************************************************
* strcspn (NTDLL.@) * strcspn (NTDLL.@)
*/ */
size_t __cdecl strcspn( const char *str, const char *reject ) size_t __cdecl strcspn( const char *str, const char *reject )
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
*/ */
#include <ctype.h> #include <ctype.h>
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -162,6 +163,26 @@ LPWSTR __cdecl wcscpy( LPWSTR dst, LPCWSTR src ) ...@@ -162,6 +163,26 @@ LPWSTR __cdecl wcscpy( LPWSTR dst, LPCWSTR src )
} }
/*********************************************************************
* wcscpy_s (NTDLL.@)
*/
errno_t __cdecl wcscpy_s( wchar_t *dst, size_t len, const wchar_t *src )
{
size_t i;
if (!dst || !len) return EINVAL;
if (!src)
{
*dst = 0;
return EINVAL;
}
for (i = 0; i < len; i++) if (!(dst[i] = src[i])) return 0;
*dst = 0;
return ERANGE;
}
/*********************************************************************** /***********************************************************************
* wcslen (NTDLL.@) * wcslen (NTDLL.@)
*/ */
......
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