Module: wine Branch: master Commit: 703212b67e37f35af6dcd1d23f81778bb07475b9 URL: https://source.winehq.org/git/wine.git/?a=commit;h=703212b67e37f35af6dcd1d23...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Jun 30 11:05:32 2022 +0200
ntdll: Add _ui64tow_s.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/ntdll.spec | 2 ++ dlls/ntdll/wcstring.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index ca896902762..9666fcc7f36 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1529,8 +1529,10 @@ @ cdecl _toupper(long) @ cdecl _ui64toa(int64 ptr long) @ cdecl _ui64tow(int64 ptr long) +@ cdecl _ui64tow_s(int64 ptr long long) @ cdecl _ultoa(long ptr long) @ cdecl _ultow(long ptr long) +@ cdecl _ultow_s(long ptr long long) @ cdecl -norelay _vsnprintf(ptr long str ptr) @ cdecl _vsnprintf_s(ptr long str ptr) @ cdecl _vsnwprintf(ptr long wstr ptr) diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c index 192bd9e9a46..8d53388f4c4 100644 --- a/dlls/ntdll/wcstring.c +++ b/dlls/ntdll/wcstring.c @@ -1082,6 +1082,51 @@ LPWSTR __cdecl _i64tow( }
+/********************************************************************* + * _ui64tow_s (NTDLL.@) + */ +errno_t __cdecl _ui64tow_s( unsigned __int64 value, wchar_t *str, size_t size, int radix ) +{ + wchar_t buffer[65], *pos; + + if (!str || !size) return EINVAL; + if (radix < 2 || radix > 36) + { + str[0] = 0; + return EINVAL; + } + + pos = buffer + 64; + *pos = 0; + + do { + int 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) + { + str[0] = 0; + return ERANGE; + } + memcpy( str, pos, (buffer - pos + 65) * sizeof(wchar_t) ); + return 0; +} + + +/********************************************************************* + * _ultow_s (NTDLL.@) + */ +errno_t __cdecl _ultow_s( __msvcrt_ulong value, wchar_t *str, size_t size, int radix ) +{ + return _ui64tow_s( value, str, size, radix ); +} + + /********************************************************************* * _wtol (NTDLL.@) *