From 01b9fd3679ed5411d2f90af3e9fd88b93c0acff2 Mon Sep 17 00:00:00 2001 From: Arno Teigseth Date: Wed, 29 Dec 2010 02:13:53 -0500 Subject: [PATCH] msvcrt: Added _ui64tow_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 | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 82606e27788..64dc69a7f14 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1197,7 +1197,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/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index e54eea6d6fa..e28079af5eb 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -1050,7 +1050,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/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 5baee987b1a..94e32ff01fd 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 ba8c9ea171b..a12941eea7d 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 11ad5a0c2d7..6be223742f5 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -918,6 +918,43 @@ int CDECL MSVCRT__ui64toa_s(unsigned __int64 value, char *str, return 0; } +/********************************************************************* + * _ui64tow_s (MSVCRT.@) + */ +int CDECL MSVCRT__ui64tow_s( unsigned __int64 value, MSVCRT_wchar_t *str, + MSVCRT_size_t size, int radix ) +{ + MSVCRT_wchar_t buffer[65], *pos; + int 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; + } while (value != 0); + + 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.@) */