Eric Pouech : msvcrt: Implemented _i64to[aw]_s.
Alexandre Julliard
julliard at winehq.org
Tue Nov 16 12:45:45 CST 2010
Module: wine
Branch: master
Commit: beca1d73a89a2ca8abb0d52e8448b9d9328b25ce
URL: http://source.winehq.org/git/wine.git/?a=commit;h=beca1d73a89a2ca8abb0d52e8448b9d9328b25ce
Author: Eric Pouech <eric.pouech at orange.fr>
Date: Mon Nov 15 22:00:01 2010 +0100
msvcrt: Implemented _i64to[aw]_s.
---
dlls/msvcr100/msvcr100.spec | 4 +-
dlls/msvcr80/msvcr80.spec | 4 +-
dlls/msvcr90/msvcr90.spec | 4 +-
dlls/msvcrt/msvcrt.spec | 4 +-
dlls/msvcrt/string.c | 156 +++++++++++++++++++++++++++++++++++++++++++
5 files changed, 164 insertions(+), 8 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 4d26904..28243de 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -731,9 +731,9 @@
@ cdecl _hypot(double double) msvcrt._hypot
@ cdecl _hypotf(float float) msvcrt._hypotf
@ cdecl _i64toa(int64 ptr long) msvcrt._i64toa
-@ stub _i64toa_s
+@ cdecl _i64toa_s(int64 ptr long long) msvcrt._i64toa_s
@ cdecl _i64tow(int64 ptr long) msvcrt._i64tow
-@ stub _i64tow_s
+@ cdecl _i64tow_s(int64 ptr long long) msvcrt._i64tow_s
@ stub _initptd
@ cdecl _initterm(ptr ptr) msvcrt._initterm
@ cdecl _initterm_e(ptr ptr) msvcr90._initterm_e
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index a65a89d..9206b93 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -578,9 +578,9 @@
@ cdecl _hypot(double double) msvcrt._hypot
@ cdecl _hypotf(float float) msvcrt._hypotf
@ cdecl _i64toa(int64 ptr long) msvcrt._i64toa
-@ stub _i64toa_s
+@ cdecl _i64toa_s(int64 ptr long long) msvcrt._i64toa_s
@ cdecl _i64tow(int64 ptr long) msvcrt._i64tow
-@ stub _i64tow_s
+@ cdecl _i64tow_s(int64 ptr long long) msvcrt._i64tow_s
@ stub _initptd
@ cdecl _initterm(ptr ptr) msvcrt._initterm
@ cdecl _initterm_e(ptr ptr) msvcr90._initterm_e
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 64332f5..c58637d 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -566,9 +566,9 @@
@ cdecl _hypot(double double) msvcrt._hypot
@ cdecl _hypotf(float float) msvcrt._hypotf
@ cdecl _i64toa(int64 ptr long) msvcrt._i64toa
-@ stub _i64toa_s
+@ cdecl _i64toa_s(int64 ptr long long) msvcrt._i64toa_s
@ cdecl _i64tow(int64 ptr long) msvcrt._i64tow
-@ stub _i64tow_s
+@ cdecl _i64tow_s(int64 ptr long long) msvcrt._i64tow_s
@ stub _initptd
@ cdecl _initterm(ptr ptr) msvcrt._initterm
@ cdecl _initterm_e(ptr ptr)
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 00ba5ea..c73a132 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -515,9 +515,9 @@
@ cdecl _hypot(double double)
@ cdecl _hypotf(float float)
@ cdecl _i64toa(int64 ptr long) ntdll._i64toa
-# stub _i64toa_s
+@ cdecl _i64toa_s(int64 ptr long long) _i64toa_s
@ cdecl _i64tow(int64 ptr long) ntdll._i64tow
-# stub _i64tow_s
+@ cdecl _i64tow_s(int64 ptr long long) _i64tow_s
@ cdecl _initterm(ptr ptr)
# stub _initterm_e
@ stub _inp #(long) -i386
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index d807c14..11ad5a0 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -972,6 +972,162 @@ int CDECL _ultoa_s(MSVCRT_ulong value, char *str, MSVCRT_size_t size, int radix)
return 0;
}
+/*********************************************************************
+ * _i64toa_s (MSVCRT.@)
+ */
+int CDECL _i64toa_s(__int64 value, char *str, MSVCRT_size_t size, int radix)
+{
+ unsigned __int64 val;
+ unsigned int digit;
+ int is_negative;
+ char buffer[65], *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 + 64;
+ *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 + 65 - pos;
+ if (len > size)
+ {
+ size_t i;
+ char *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 + 63, i = 0; i < size; i++)
+ *p++ = *pos--;
+
+ str[0] = '\0';
+ MSVCRT_INVALID_PMT("str[size] is too small");
+ *MSVCRT__errno() = MSVCRT_ERANGE;
+ return MSVCRT_ERANGE;
+ }
+
+ memcpy(str, pos, len);
+ return 0;
+}
+
+/*********************************************************************
+ * _i64tow_s (MSVCRT.@)
+ */
+int CDECL _i64tow_s(__int64 value, MSVCRT_wchar_t *str, MSVCRT_size_t size, int radix)
+{
+ unsigned __int64 val;
+ unsigned int digit;
+ int is_negative;
+ MSVCRT_wchar_t buffer[65], *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 + 64;
+ *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 + 65 - 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 + 63, 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;
+}
+
#define I10_OUTPUT_MAX_PREC 21
/* Internal structure used by $I10_OUTPUT */
struct _I10_OUTPUT_DATA {
More information about the wine-cvs
mailing list