[PATCH] Added function _ui64tow_s to MSVCRT
Arno Teigseth
arnotixe at gmail.com
Wed Dec 22 15:39:50 CST 2010
---
dlls/msvcr90/msvcr90.spec | 2 +-
dlls/msvcrt/msvcrt.spec | 2 +-
dlls/msvcrt/string.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 5baee98..94e32ff 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -1037,7 +1037,7 @@
@ cdecl _ui64toa(int64 ptr long) msvcrt._ui64toa
@ cdecl _ui64toa_s(int64 ptr long long) msvcrt._ui64toa_s
@ cdecl _ui64tow(int64 ptr long) msvcrt._ui64tow
-@ stub _ui64tow_s
+@ cdecl _ui64tow_s(int64 ptr long long) msvcrt._ui64tow_s
@ cdecl _ultoa(long ptr long) msvcrt._ultoa
@ cdecl _ultoa_s(long ptr long long) msvcrt._ultoa_s
@ cdecl _ultow(long ptr long) msvcrt._ultow
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index ba8c9ea..a12941e 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -976,7 +976,7 @@
@ cdecl _ui64toa(int64 ptr long) ntdll._ui64toa
@ cdecl _ui64toa_s(int64 ptr long long) MSVCRT__ui64toa_s
@ cdecl _ui64tow(int64 ptr long) ntdll._ui64tow
-# stub _ui64tow_s
+@ cdecl _ui64tow_s(int64 ptr long long) MSVCRT__ui64tow_s
@ cdecl _ultoa(long ptr long) ntdll._ultoa
@ cdecl _ultoa_s(long ptr long long)
@ cdecl _ultow(long ptr long) ntdll._ultow
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 11ad5a0..8eb7701 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -919,6 +919,50 @@ int CDECL MSVCRT__ui64toa_s(unsigned __int64 value, char *str,
}
/*********************************************************************
+ * _ui64tow_s (MSVCRT.@)
+ * Arno's beginner luck if this works
+ */
+int CDECL MSVCRT__ui64tow_s(
+ ULONGLONG value, /* [I] Value to be converted */
+ LPWSTR str, /* [O] Destination for the converted value */
+ MSVCRT_size_t size,
+ INT radix) /* [I] Number base for conversion */
+{
+ WCHAR buffer[65];
+ PWCHAR pos;
+ WCHAR digit;
+
+
+ if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
+ !MSVCRT_CHECK_PMT(radix>=2) || !MSVCRT_CHECK_PMT(radix<=36)) {
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return MSVCRT_EINVAL;
+ }
+
+ pos = &buffer[64];
+ *pos = '\0';
+
+ do {
+ digit = value % radix;
+ value = value / radix;
+ if (digit < 10) {
+ *--pos = '0' + digit;
+ } else {
+ *--pos = 'a' + digit - 10;
+ } /* if */
+ } while (value != 0L);
+
+ if(buffer-pos+65 > size) {
+ MSVCRT_INVALID_PMT("str[size] is too small");
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return MSVCRT_EINVAL;
+ }
+
+ memcpy(str, pos, buffer-pos+65);
+ return 0;
+}
+
+/*********************************************************************
* _ultoa_s (MSVCRT.@)
*/
int CDECL _ultoa_s(MSVCRT_ulong value, char *str, MSVCRT_size_t size, int radix)
--
1.6.3.3
More information about the wine-patches
mailing list