Eric Pouech : msvcrt: Implemented _itow_s.
Alexandre Julliard
julliard at winehq.org
Wed Nov 3 11:37:03 CDT 2010
Module: wine
Branch: master
Commit: af2bc15eddfea046a0b283bc7cd73fd4ba9bef78
URL: http://source.winehq.org/git/wine.git/?a=commit;h=af2bc15eddfea046a0b283bc7cd73fd4ba9bef78
Author: Eric Pouech <eric.pouech at orange.fr>
Date: Tue Nov 2 22:02:52 2010 +0100
msvcrt: Implemented _itow_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 | 77 +++++++++++++++++++++++++++++++++++++++++++
5 files changed, 81 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 2f23ff0..d4e5c38 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -836,7 +836,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
-@ stub _itow_s
+@ cdecl _itow_s(long ptr long long) msvcrt._itow_s
@ cdecl _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 5f0198c..7fb8eca 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -682,7 +682,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
-@ stub _itow_s
+@ cdecl _itow_s(long ptr long long) msvcrt._itow_s
@ cdecl _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 7a53b7b..c38e5f9 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -670,7 +670,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
-@ stub _itow_s
+@ cdecl _itow_s(long ptr long long) msvcrt._itow_s
@ cdecl _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index eb0d8ec..a1cd124 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -611,7 +611,7 @@
@ cdecl _itoa(long ptr long) ntdll._itoa
@ cdecl _itoa_s(long ptr long long)
@ cdecl _itow(long ptr long) ntdll._itow
-# stub _itow_s
+@ cdecl _itow_s(long ptr long long)
@ cdecl _j0(double)
@ cdecl _j1(double)
@ cdecl _jn(long double)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 6b3725f..3c4b53c 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -746,6 +746,83 @@ int CDECL _itoa_s(int value, char *str, MSVCRT_size_t size, int radix)
}
/*********************************************************************
+ * _itow_s (MSVCRT.@)
+ */
+int CDECL _itow_s(int value, MSVCRT_wchar_t *str, MSVCRT_size_t size, int radix)
+{
+ unsigned int val, digit;
+ int is_negative;
+ MSVCRT_wchar_t buffer[33], *pos;
+ size_t len;
+
+ if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
+ !MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
+ {
+ if (str && size)
+ str[0] = '\0';
+
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return MSVCRT_EINVAL;
+ }
+
+ if (value < 0 && radix == 10)
+ {
+ is_negative = 1;
+ val = -value;
+ }
+ else
+ {
+ is_negative = 0;
+ val = value;
+ }
+
+ pos = buffer + 32;
+ *pos = '\0';
+
+ do
+ {
+ digit = val % radix;
+ val /= radix;
+
+ if (digit < 10)
+ *--pos = '0' + digit;
+ else
+ *--pos = 'a' + digit - 10;
+ }
+ while (val != 0);
+
+ if (is_negative)
+ *--pos = '-';
+
+ len = buffer + 33 - pos;
+ if (len > size)
+ {
+ size_t i;
+ MSVCRT_wchar_t *p = str;
+
+ /* Copy the temporary buffer backwards up to the available number of
+ * characters. Don't copy the negative sign if present. */
+
+ if (is_negative)
+ {
+ p++;
+ size--;
+ }
+
+ for (pos = buffer + 31, i = 0; i < size; i++)
+ *p++ = *pos--;
+
+ MSVCRT_INVALID_PMT("str[size] is too small");
+ str[0] = '\0';
+ *MSVCRT__errno() = MSVCRT_ERANGE;
+ return MSVCRT_ERANGE;
+ }
+
+ memcpy(str, pos, len * sizeof(MSVCRT_wchar_t));
+ return 0;
+}
+
+/*********************************************************************
* _ui64toa_s (MSVCRT.@)
*/
int CDECL MSVCRT__ui64toa_s(unsigned __int64 value, char *str,
More information about the wine-cvs
mailing list