Alexandre Julliard : ntdll: Add strcat_s and wcscat_s.

Alexandre Julliard julliard at winehq.org
Wed Jun 29 16:25:53 CDT 2022


Module: wine
Branch: master
Commit: 83cd792e355f94e39b63eedc295b1cbfa25bea83
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=83cd792e355f94e39b63eedc295b1cbfa25bea83

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jun 29 11:49:14 2022 +0200

ntdll: Add strcat_s and wcscat_s.

Implementation copied from msvcrt.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/ntdll.spec |  2 ++
 dlls/ntdll/string.c   | 20 ++++++++++++++++++++
 dlls/ntdll/wcstring.c | 20 ++++++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 93cb322f06d..1e94d23c7df 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1587,6 +1587,7 @@
 @ cdecl sqrt(double)
 @ varargs sscanf(str str)
 @ cdecl strcat(str str)
+@ cdecl strcat_s(str long str)
 @ cdecl strchr(str long)
 @ cdecl strcmp(str str)
 @ cdecl strcpy(ptr str)
@@ -1616,6 +1617,7 @@
 @ cdecl vsprintf_s(ptr long str ptr)
 @ cdecl vswprintf_s(ptr long wstr ptr)
 @ cdecl wcscat(wstr wstr)
+@ cdecl wcscat_s(wstr long wstr)
 @ cdecl wcschr(wstr long)
 @ cdecl wcscmp(wstr wstr)
 @ cdecl wcscpy(ptr wstr)
diff --git a/dlls/ntdll/string.c b/dlls/ntdll/string.c
index 6308ecfe049..8a37cd6d8d4 100644
--- a/dlls/ntdll/string.c
+++ b/dlls/ntdll/string.c
@@ -224,6 +224,26 @@ char * __cdecl strcat( char *dst, const char *src )
 }
 
 
+/*********************************************************************
+ *                  strcat_s   (NTDLL.@)
+ */
+errno_t __cdecl strcat_s( char *dst, size_t len, const char *src )
+{
+    size_t i, j;
+
+    if (!dst || !len) return EINVAL;
+    if (!src)
+    {
+        *dst = 0;
+        return EINVAL;
+    }
+    for (i = 0; i < len; i++) if (!dst[i]) break;
+    for (j = 0; (j + i) < len; j++) if (!(dst[j + i] = src[j])) return 0;
+    *dst = 0;
+    return ERANGE;
+}
+
+
 /*********************************************************************
  *                  strchr   (NTDLL.@)
  */
diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c
index b6afdb1d72e..d5e50981153 100644
--- a/dlls/ntdll/wcstring.c
+++ b/dlls/ntdll/wcstring.c
@@ -204,6 +204,26 @@ LPWSTR __cdecl wcscat( LPWSTR dst, LPCWSTR src )
 }
 
 
+/*********************************************************************
+ *           wcscat_s    (NTDLL.@)
+ */
+errno_t __cdecl wcscat_s( wchar_t *dst, size_t len, const wchar_t *src )
+{
+    size_t i, j;
+
+    if (!dst || !len) return EINVAL;
+    if (!src)
+    {
+        *dst = 0;
+        return EINVAL;
+    }
+    for (i = 0; i < len; i++) if (!dst[i]) break;
+    for (j = 0; (j + i) < len; j++) if (!(dst[j + i] = src[j])) return 0;
+    *dst = 0;
+    return ERANGE;
+}
+
+
 /*********************************************************************
  *           wcschr    (NTDLL.@)
  */




More information about the wine-cvs mailing list