mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 20:30:01 +00:00
msvcrt: Implemented _i64to[aw]_s.
This commit is contained in:
parent
28884a8faa
commit
beca1d73a8
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user