Commit 911810c5 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Add _i64toa_s.

parent 4e269f75
......@@ -1503,14 +1503,17 @@
@ stub _fltused
@ cdecl -arch=i386 -ret64 _ftol()
@ cdecl _i64toa(int64 ptr long)
@ cdecl _i64toa_s(int64 ptr long long)
@ cdecl _i64tow(int64 ptr long)
@ cdecl _i64tow_s(int64 ptr long long)
@ cdecl _itoa(long ptr long)
@ cdecl _itoa_s(long ptr long long)
@ cdecl _itow(long ptr long)
@ cdecl _itow_s(long ptr long long)
@ cdecl _lfind(ptr ptr ptr long ptr)
@ stdcall -arch=x86_64,arm64 _local_unwind(ptr ptr)
@ cdecl _ltoa(long ptr long)
@ cdecl _ltoa_s(long ptr long long)
@ cdecl _ltow(long ptr long)
@ cdecl _ltow_s(long ptr long long)
@ cdecl _memccpy(ptr ptr long long)
......
......@@ -1259,6 +1259,80 @@ errno_t __cdecl _ultoa_s( __msvcrt_ulong value, char *str, size_t size, int radi
/*********************************************************************
* _i64toa_s (NTDLL.@)
*/
errno_t __cdecl _i64toa_s( __int64 value, char *str, size_t size, int radix )
{
unsigned __int64 val;
BOOL is_negative;
char buffer[65], *pos;
if (!str || !size) return EINVAL;
if (radix < 2 || radix > 36)
{
str[0] = 0;
return EINVAL;
}
if (value < 0 && radix == 10)
{
is_negative = TRUE;
val = -value;
}
else
{
is_negative = FALSE;
val = value;
}
pos = buffer + 64;
*pos = 0;
do
{
unsigned int digit = val % radix;
val /= radix;
if (digit < 10)
*--pos = '0' + digit;
else
*--pos = 'a' + digit - 10;
}
while (val != 0);
if (is_negative) *--pos = '-';
if (buffer - pos + 65 > size)
{
str[0] = 0;
return ERANGE;
}
memcpy( str, pos, buffer - pos + 65 );
return 0;
}
/*********************************************************************
* _ltoa_s (NTDLL.@)
*/
errno_t __cdecl _ltoa_s( __msvcrt_long value, char *str, size_t size, int radix )
{
if (value < 0 && radix == 10) return _i64toa_s( value, str, size, radix );
return _ui64toa_s( (__msvcrt_ulong)value, str, size, radix );
}
/*********************************************************************
* _itoa_s (NTDLL.@)
*/
errno_t __cdecl _itoa_s( int value, char *str, size_t size, int radix )
{
if (value < 0 && radix == 10) return _i64toa_s( value, str, size, radix );
return _ui64toa_s( (unsigned int)value, str, size, radix );
}
/*********************************************************************
* _atoi64 (NTDLL.@)
*
* Convert a string to a large integer.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment