_itow, _ltow, _ultow added to crtdll.

*** TO BE TESTED ***

svn path=/trunk/; revision=1474
This commit is contained in:
Emanuele Aliberti 2000-12-22 23:20:15 +00:00
parent 91bcb7413f
commit b6c91b703e
3 changed files with 186 additions and 4 deletions

View file

@ -3,9 +3,11 @@
; ;
; Exports from crtdll.dll from Windows 95 SYSTEM directory. Hopefully this ; Exports from crtdll.dll from Windows 95 SYSTEM directory. Hopefully this
; should also work with the crtdll provided with Windows NT. ; should also work with the crtdll provided with Windows NT.
; Exports from crtdll.dll from Windows NT Server 4.0.
; ;
; Contributors: ; Contributors:
; Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp> ; Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
; Modified by Adhi P. Yoedo <adhi@primatama.co.id>
; ;
; THIS SOFTWARE IS NOT COPYRIGHTED ; THIS SOFTWARE IS NOT COPYRIGHTED
; ;
@ -17,9 +19,9 @@
; DISCLAMED. This includes but is not limited to warrenties of ; DISCLAMED. This includes but is not limited to warrenties of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
; ;
; $Revision: 1.13 $ ; $Revision: 1.14 $
; $Author: ea $ ; $Author: ea $
; $Date: 2000/05/01 14:15:01 $ ; $Date: 2000/12/22 23:20:15 $
; ;
; These three functions appear to be name mangled in some way, so GCC is ; These three functions appear to be name mangled in some way, so GCC is
; probably not going to be able to use them in any case. ; probably not going to be able to use them in any case.
@ -202,6 +204,7 @@ _ismbslead
_ismbstrail _ismbstrail
_isnan _isnan
_itoa _itoa
_itow
_j0 _j0
_j1 _j1
_jn _jn
@ -216,6 +219,7 @@ _lrotr
_lsearch _lsearch
_lseek _lseek
_ltoa _ltoa
_ltow
_makepath _makepath
_matherr _matherr
_mbbtombc _mbbtombc
@ -346,6 +350,7 @@ _toupper
_tzname _tzname
_tzset _tzset
_ultoa _ultoa
_ultow
_umask _umask
_ungetch _ungetch
_unlink _unlink

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.41 2000/11/20 19:59:08 ekohl Exp $ # $Id: makefile,v 1.42 2000/12/22 23:15:18 ea Exp $
# #
# ReactOS Operating System # ReactOS Operating System
# #
@ -103,7 +103,7 @@ STDLIB_OBJECTS = stdlib/abort.o stdlib/abs.o stdlib/atexit.o stdlib/atof.o stdli
stdlib/rand.o stdlib/senv.o stdlib/splitp.o stdlib/strtod.o stdlib/strtol.o \ stdlib/rand.o stdlib/senv.o stdlib/splitp.o stdlib/strtod.o stdlib/strtol.o \
stdlib/strtoul.o stdlib/swab.o stdlib/atol.o stdlib/rot.o stdlib/wcstomb.o\ stdlib/strtoul.o stdlib/swab.o stdlib/atol.o stdlib/rot.o stdlib/wcstomb.o\
stdlib/ecvt.o stdlib/ecvtbuf.o stdlib/gcvt.o stdlib/fcvt.o stdlib/fcvtbuf.o\ stdlib/ecvt.o stdlib/ecvtbuf.o stdlib/gcvt.o stdlib/fcvt.o stdlib/fcvtbuf.o\
stdlib/mbstowcs.o stdlib/mbstowcs.o stdlib/itow.o
SIGNAL_OBJECTS = signal/signal.o signal/xcptfil.o signal/xcptinfo.o SIGNAL_OBJECTS = signal/signal.o signal/xcptfil.o signal/xcptinfo.o

View file

@ -0,0 +1,177 @@
/* $Id: itow.c,v 1.1 2000/12/22 23:17:03 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/stdlib/itow.c
* PURPOSE: converts a integer to wchar_t
* PROGRAMER:
* UPDATE HISTORY:
* 1995: Created
* 1998: Added ltoa Boudewijn Dekker
* 2000: derived from ./itoa.c by ea
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/errno.h>
#include <crtdll/stdlib.h>
#include <crtdll/internal/file.h>
wchar_t *
_itow (int value, wchar_t *string, int radix)
{
wchar_t tmp [33];
wchar_t * tp = tmp;
int i;
unsigned int 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+ (wchar_t) '0';
}
else
{
*tp++ = i + (wchar_t) 'a' - 10;
}
}
if (string == 0)
{
string = (wchar_t *) malloc((tp-tmp) + (sign + 1) * sizeof(wchar_t));
}
sp = string;
if (sign)
{
*sp++ = (wchar_t) '-';
}
while (tp > tmp)
{
*sp++ = *--tp;
}
*sp = (wchar_t) 0;
return string;
}
wchar_t *
_ltow (long value, wchar_t *string, int radix)
{
wchar_t tmp [33];
wchar_t * tp = tmp;
long int i;
unsigned long int 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 long) value;
}
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
{
*tp++ = i + (wchar_t) '0';
}
else
{
*tp++ = i + (wchar_t) 'a' - 10;
}
}
if (string == 0)
{
string = (wchar_t *) malloc((tp - tmp) + (sign + 1) * sizeof(wchar_t));
}
sp = string;
if (sign)
{
*sp++ = (wchar_t) '-';
}
while (tp > tmp)
{
*sp++ = *--tp;
}
*sp = (wchar_t) 0;
return string;
}
wchar_t *
_ultow (unsigned long value, wchar_t *string, int radix)
{
wchar_t tmp [33];
wchar_t * tp = tmp;
long int i;
unsigned long int 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 + (wchar_t) '0';
}
else
{
*tp++ = i + (wchar_t) 'a' - 10;
}
}
if (string == 0)
{
string = (wchar_t *) malloc((tp - tmp) + sizeof(wchar_t));
}
sp = string;
while (tp > tmp)
{
*sp++ = *--tp;
}
*sp = (wchar_t) 0;
return string;
}
/* EOF */