reactos/reactos/lib/sdk/crt/string/witow.c
Sylvain Petreolle b30bf6de31 [CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.

Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.

svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00

93 lines
1.7 KiB
C

/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/stdlib/itow.c
* PURPOSE: converts a integer to wchar_t
* PROGRAMER:
* UPDATE HISTORY:
* 1995: Created
* 1998: Added ltoa by Ariadne
* 2000: derived from ./itoa.c by ea
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <precomp.h>
/*
* @implemented
*/
wchar_t* _i64tow(__int64 value, wchar_t* string, int radix)
{
wchar_t tmp[65];
wchar_t* tp = tmp;
int i;
unsigned v;
int sign;
wchar_t* sp;
if (radix > 36 || radix <= 1) {
_set_errno(EDOM);
return 0;
}
sign = (radix == 10 && value < 0);
if (sign)
v = -value;
else
v = (unsigned)value;
while (v || tp == tmp) {
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+L'0';
else
*tp++ = i + L'a' - 10;
}
if (string == 0)
string = (wchar_t*)malloc(((tp-tmp)+sign+1)*sizeof(wchar_t));
sp = string;
if (sign)
*sp++ = L'-';
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
/*
* @implemented
*/
wchar_t* _ui64tow(unsigned __int64 value, wchar_t* string, int radix)
{
wchar_t tmp[65];
wchar_t* tp = tmp;
long i;
unsigned long v = value;
wchar_t* sp;
if (radix > 36 || radix <= 1) {
_set_errno(EDOM);
return 0;
}
while (v || tp == tmp) {
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+L'0';
else
*tp++ = i + L'a' - 10;
}
if (string == 0)
string = (wchar_t*)malloc(((tp-tmp)+1)*sizeof(wchar_t));
sp = string;
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}