Eric Pouech : msvcrt: Implemented _ultow_s.

Alexandre Julliard julliard at winehq.org
Tue Nov 29 14:20:38 CST 2011


Module: wine
Branch: master
Commit: d7bc2eff2f2651646753e13b7d840469347a7386
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d7bc2eff2f2651646753e13b7d840469347a7386

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Mon Nov 28 21:53:38 2011 +0100

msvcrt: Implemented _ultow_s.

---

 dlls/msvcr100/msvcr100.spec |    2 +-
 dlls/msvcr80/msvcr80.spec   |    2 +-
 dlls/msvcr90/msvcr90.spec   |    2 +-
 dlls/msvcrt/msvcrt.spec     |    2 +-
 dlls/msvcrt/string.c        |   54 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 4b5b525..16c8486 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1202,7 +1202,7 @@
 @ cdecl _ultoa(long ptr long) msvcrt._ultoa
 @ cdecl _ultoa_s(long ptr long long) msvcrt._ultoa_s
 @ cdecl _ultow(long ptr long) msvcrt._ultow
-@ stub _ultow_s
+@ cdecl _ultow_s(long ptr long long) msvcrt._ultow_s
 @ cdecl _umask(long) msvcrt._umask
 @ stub _umask_s
 @ stub _ungetc_nolock
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 5de5586..240b9f2 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -1055,7 +1055,7 @@
 @ cdecl _ultoa(long ptr long) msvcrt._ultoa
 @ cdecl _ultoa_s(long ptr long long) msvcrt._ultoa_s
 @ cdecl _ultow(long ptr long) msvcrt._ultow
-@ stub _ultow_s
+@ cdecl _ultow_s(long ptr long long) msvcrt._ultow_s
 @ cdecl _umask(long) msvcrt._umask
 @ stub _umask_s
 @ stub _ungetc_nolock
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 77e0e45..f1fa88a 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -1049,7 +1049,7 @@
 @ cdecl _ultoa(long ptr long) msvcrt._ultoa
 @ cdecl _ultoa_s(long ptr long long) msvcrt._ultoa_s
 @ cdecl _ultow(long ptr long) msvcrt._ultow
-@ stub _ultow_s
+@ cdecl _ultow_s(long ptr long long) msvcrt._ultow_s
 @ cdecl _umask(long) msvcrt._umask
 @ stub _umask_s
 @ stub _ungetc_nolock
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index fac2104..2687fd6 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -991,7 +991,7 @@
 @ cdecl _ultoa(long ptr long) ntdll._ultoa
 @ cdecl _ultoa_s(long ptr long long)
 @ cdecl _ultow(long ptr long) ntdll._ultow
-# stub _ultow_s(long ptr long long)
+@ cdecl _ultow_s(long ptr long long)
 @ cdecl _umask(long) MSVCRT__umask
 # stub _umask_s(long ptr)
 @ cdecl _ungetch(long)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 608401d..ad9e88b 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -1288,6 +1288,60 @@ int CDECL _ultoa_s(MSVCRT_ulong value, char *str, MSVCRT_size_t size, int radix)
 }
 
 /*********************************************************************
+ *  _ultow_s (MSVCRT.@)
+ */
+int CDECL _ultow_s(MSVCRT_ulong value, WCHAR *str, MSVCRT_size_t size, int radix)
+{
+    MSVCRT_ulong digit;
+    WCHAR buffer[33], *pos;
+    size_t len;
+
+    if (!str || !size || radix < 2 || radix > 36)
+    {
+        if (str && size)
+            str[0] = '\0';
+
+        *MSVCRT__errno() = MSVCRT_EINVAL;
+        return MSVCRT_EINVAL;
+    }
+
+    pos = buffer + 32;
+    *pos = '\0';
+
+    do
+    {
+        digit = value % radix;
+        value /= radix;
+
+        if (digit < 10)
+            *--pos = '0' + digit;
+        else
+            *--pos = 'a' + digit - 10;
+    }
+    while (value != 0);
+
+    len = buffer + 33 - pos;
+    if (len > size)
+    {
+        size_t i;
+        WCHAR *p = str;
+
+        /* Copy the temporary buffer backwards up to the available number of
+         * characters. */
+
+        for (pos = buffer + 31, i = 0; i < size; i++)
+            *p++ = *pos--;
+
+        str[0] = '\0';
+        *MSVCRT__errno() = MSVCRT_ERANGE;
+        return MSVCRT_ERANGE;
+    }
+
+    memcpy(str, pos, len * sizeof(WCHAR));
+    return 0;
+}
+
+/*********************************************************************
  *  _i64toa_s (MSVCRT.@)
  */
 int CDECL _i64toa_s(__int64 value, char *str, MSVCRT_size_t size, int radix)




More information about the wine-cvs mailing list