Alexandre Julliard : ntdll: Add _ui64toa_s.

Alexandre Julliard julliard at winehq.org
Thu Jun 30 16:34:19 CDT 2022


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jun 30 11:06:06 2022 +0200

ntdll: Add _ui64toa_s.

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

---

 dlls/ntdll/ntdll.spec |  2 ++
 dlls/ntdll/string.c   | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 51041c4144b..d592b7adbb4 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1531,9 +1531,11 @@
 @ cdecl _tolower(long)
 @ cdecl _toupper(long)
 @ cdecl _ui64toa(int64 ptr long)
+@ cdecl _ui64toa_s(int64 ptr long long)
 @ cdecl _ui64tow(int64 ptr long)
 @ cdecl _ui64tow_s(int64 ptr long long)
 @ cdecl _ultoa(long ptr long)
+@ cdecl _ultoa_s(long ptr long long)
 @ cdecl _ultow(long ptr long)
 @ cdecl _ultow_s(long ptr long long)
 @ cdecl -norelay _vsnprintf(ptr long str ptr)
diff --git a/dlls/ntdll/string.c b/dlls/ntdll/string.c
index c0db6f832ef..797152a81e1 100644
--- a/dlls/ntdll/string.c
+++ b/dlls/ntdll/string.c
@@ -1213,6 +1213,51 @@ char * __cdecl _i64toa(
 }
 
 
+/*********************************************************************
+ *      _ui64toa_s  (NTDLL.@)
+ */
+errno_t __cdecl _ui64toa_s( unsigned __int64 value, char *str, size_t size, int radix )
+{
+    char buffer[65], *pos;
+
+    if (!str || !size) return EINVAL;
+    if (radix < 2 || radix > 36)
+    {
+        str[0] = 0;
+        return EINVAL;
+    }
+
+    pos = buffer + 64;
+    *pos = 0;
+
+    do {
+	int digit = value % radix;
+	value = value / radix;
+	if (digit < 10)
+	    *--pos = '0' + digit;
+	else
+	    *--pos = 'a' + digit - 10;
+    } while (value != 0);
+
+    if (buffer - pos + 65 > size)
+    {
+        str[0] = 0;
+        return ERANGE;
+    }
+    memcpy( str, pos, buffer - pos + 65 );
+    return 0;
+}
+
+
+/*********************************************************************
+ *      _ultoa_s  (NTDLL.@)
+ */
+errno_t __cdecl _ultoa_s( __msvcrt_ulong value, char *str, size_t size, int radix )
+{
+    return _ui64toa_s( value, str, size, radix );
+}
+
+
 /*********************************************************************
  *      _atoi64   (NTDLL.@)
  *




More information about the wine-cvs mailing list