Commit af2bc15e authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

msvcrt: Implemented _itow_s.

parent 347049bc
...@@ -836,7 +836,7 @@ ...@@ -836,7 +836,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa @ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s @ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow @ 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 _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1 @ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn @ cdecl _jn(long double) msvcrt._jn
......
...@@ -682,7 +682,7 @@ ...@@ -682,7 +682,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa @ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s @ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow @ 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 _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1 @ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn @ cdecl _jn(long double) msvcrt._jn
......
...@@ -670,7 +670,7 @@ ...@@ -670,7 +670,7 @@
@ cdecl _itoa(long ptr long) msvcrt._itoa @ cdecl _itoa(long ptr long) msvcrt._itoa
@ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s @ cdecl _itoa_s(long ptr long long) msvcrt._itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow @ 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 _j0(double) msvcrt._j0
@ cdecl _j1(double) msvcrt._j1 @ cdecl _j1(double) msvcrt._j1
@ cdecl _jn(long double) msvcrt._jn @ cdecl _jn(long double) msvcrt._jn
......
...@@ -611,7 +611,7 @@ ...@@ -611,7 +611,7 @@
@ cdecl _itoa(long ptr long) ntdll._itoa @ cdecl _itoa(long ptr long) ntdll._itoa
@ cdecl _itoa_s(long ptr long long) @ cdecl _itoa_s(long ptr long long)
@ cdecl _itow(long ptr long) ntdll._itow @ cdecl _itow(long ptr long) ntdll._itow
# stub _itow_s @ cdecl _itow_s(long ptr long long)
@ cdecl _j0(double) @ cdecl _j0(double)
@ cdecl _j1(double) @ cdecl _j1(double)
@ cdecl _jn(long double) @ cdecl _jn(long double)
......
...@@ -746,6 +746,83 @@ int CDECL _itoa_s(int value, char *str, MSVCRT_size_t size, int radix) ...@@ -746,6 +746,83 @@ int CDECL _itoa_s(int value, char *str, MSVCRT_size_t size, int radix)
} }
/********************************************************************* /*********************************************************************
* _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.@) * _ui64toa_s (MSVCRT.@)
*/ */
int CDECL MSVCRT__ui64toa_s(unsigned __int64 value, char *str, int CDECL MSVCRT__ui64toa_s(unsigned __int64 value, char *str,
......
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