From b6c91b703e5118588ed0e99d8921fe7b06e23910 Mon Sep 17 00:00:00 2001 From: Emanuele Aliberti Date: Fri, 22 Dec 2000 23:20:15 +0000 Subject: [PATCH] _itow, _ltow, _ultow added to crtdll. *** TO BE TESTED *** svn path=/trunk/; revision=1474 --- reactos/lib/crtdll/crtdll.def | 9 +- reactos/lib/crtdll/makefile | 4 +- reactos/lib/crtdll/stdlib/itow.c | 177 +++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 reactos/lib/crtdll/stdlib/itow.c diff --git a/reactos/lib/crtdll/crtdll.def b/reactos/lib/crtdll/crtdll.def index 5135ba694bc..7e560824c8c 100644 --- a/reactos/lib/crtdll/crtdll.def +++ b/reactos/lib/crtdll/crtdll.def @@ -3,9 +3,11 @@ ; ; Exports from crtdll.dll from Windows 95 SYSTEM directory. Hopefully this ; should also work with the crtdll provided with Windows NT. +; Exports from crtdll.dll from Windows NT Server 4.0. ; ; Contributors: ; Created by Colin Peters +; Modified by Adhi P. Yoedo ; ; THIS SOFTWARE IS NOT COPYRIGHTED ; @@ -17,9 +19,9 @@ ; DISCLAMED. This includes but is not limited to warrenties of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; -; $Revision: 1.13 $ +; $Revision: 1.14 $ ; $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 ; probably not going to be able to use them in any case. @@ -202,6 +204,7 @@ _ismbslead _ismbstrail _isnan _itoa +_itow _j0 _j1 _jn @@ -216,6 +219,7 @@ _lrotr _lsearch _lseek _ltoa +_ltow _makepath _matherr _mbbtombc @@ -346,6 +350,7 @@ _toupper _tzname _tzset _ultoa +_ultow _umask _ungetch _unlink diff --git a/reactos/lib/crtdll/makefile b/reactos/lib/crtdll/makefile index 078812b5fe9..83e8375350a 100644 --- a/reactos/lib/crtdll/makefile +++ b/reactos/lib/crtdll/makefile @@ -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 # @@ -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/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/mbstowcs.o + stdlib/mbstowcs.o stdlib/itow.o SIGNAL_OBJECTS = signal/signal.o signal/xcptfil.o signal/xcptinfo.o diff --git a/reactos/lib/crtdll/stdlib/itow.c b/reactos/lib/crtdll/stdlib/itow.c new file mode 100644 index 00000000000..887f083482a --- /dev/null +++ b/reactos/lib/crtdll/stdlib/itow.c @@ -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 +#include +#include + +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 */