[PATCH 03/14] [Msvcrt*]: implemented _itow_s
Eric Pouech
eric.pouech at orange.fr
Tue Nov 2 16:02:52 CDT 2010
A+
---
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 ec0a1ba..498abfc 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 a5bb126..3d6bb47 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 14eec1b..b0089af 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 1e8f06d..13fd742 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -609,7 +609,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 9f4d6a6..ea3ca1b 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -748,6 +748,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-patches
mailing list