_itow, _ltow, _ultow added to crtdll.
authorEmanuele Aliberti <ea@iol.it>
Fri, 22 Dec 2000 23:20:15 +0000 (23:20 +0000)
committerEmanuele Aliberti <ea@iol.it>
Fri, 22 Dec 2000 23:20:15 +0000 (23:20 +0000)
*** TO BE TESTED ***

svn path=/trunk/; revision=1474

reactos/lib/crtdll/crtdll.def
reactos/lib/crtdll/makefile
reactos/lib/crtdll/stdlib/itow.c [new file with mode: 0644]

index 5135ba6..7e56082 100644 (file)
@@ -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 <colin@bird.fu.is.saga-u.ac.jp>
+;  Modified by Adhi P. Yoedo <adhi@primatama.co.id>
 ;
 ;  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
index 078812b..83e8375 100644 (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
 #
@@ -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 (file)
index 0000000..887f083
--- /dev/null
@@ -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 */