msvcrt: Implemented _itow_s.

This commit is contained in:
Eric Pouech 2010-11-02 22:02:52 +01:00 committed by Alexandre Julliard
parent 347049bca8
commit af2bc15edd
5 changed files with 81 additions and 4 deletions

View File

@ -836,7 +836,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
@ stub _itow_s
@ cdecl _itow_s(long ptr long long) msvcrt._itow_s
@ cdecl _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn

View File

@ -682,7 +682,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
@ stub _itow_s
@ cdecl _itow_s(long ptr long long) msvcrt._itow_s
@ cdecl _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn

View File

@ -670,7 +670,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
@ stub _itow_s
@ cdecl _itow_s(long ptr long long) msvcrt._itow_s
@ cdecl _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn

View File

@ -611,7 +611,7 @@
@ cdecl _itoa(long ptr long) ntdll._itoa
@ cdecl _itoa_s(long ptr long long)
@ cdecl _itow(long ptr long) ntdll._itow
# stub _itow_s
@ cdecl _itow_s(long ptr long long)
@ cdecl _j0(double)
@ cdecl _j1(double)
@ cdecl _jn(long double)

View File

@ -745,6 +745,83 @@ int CDECL _itoa_s(int value, char *str, MSVCRT_size_t size, int radix)
return 0;
}
/*********************************************************************
* _itow_s (MSVCRT.@)
*/
int CDECL _itow_s(int value, MSVCRT_wchar_t *str, MSVCRT_size_t size, int radix)
{
unsigned int val, digit;
int is_negative;
MSVCRT_wchar_t buffer[33], *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 + 32;
*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 + 33 - 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 + 31, 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;
}
/*********************************************************************
* _ui64toa_s (MSVCRT.@)
*/