diff --git a/reactos/include/ndk/rtlfuncs.h b/reactos/include/ndk/rtlfuncs.h
index 8eade3854d7..c0a326b5b6c 100644
--- a/reactos/include/ndk/rtlfuncs.h
+++ b/reactos/include/ndk/rtlfuncs.h
@@ -2013,4 +2013,29 @@ NTSTATUS
NTAPI
RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
+
+static __inline struct _PEB* NtCurrentPeb (void)
+{
+ struct _PEB * pPeb;
+
+#if defined(__GNUC__)
+
+ __asm__ __volatile__
+ (
+ "movl %%fs:0x30, %0\n" /* fs:30h == Teb->Peb */
+ : "=r" (pPeb) /* can't have two memory operands */
+ : /* no inputs */
+ );
+
+#elif defined(_MSC_VER)
+
+ __asm mov eax, fs:0x30;
+ __asm mov pPeb, eax
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+ return pPeb;
+}
#endif
diff --git a/reactos/include/ndk/zwfuncs.h b/reactos/include/ndk/zwfuncs.h
index d5fd8c57782..ca90c178b20 100644
--- a/reactos/include/ndk/zwfuncs.h
+++ b/reactos/include/ndk/zwfuncs.h
@@ -4350,29 +4350,4 @@ ZwYieldExecution(
VOID
);
-
-static __inline struct _PEB* NtCurrentPeb (void)
-{
- struct _PEB * pPeb;
-
-#if defined(__GNUC__)
-
- __asm__ __volatile__
- (
- "movl %%fs:0x30, %0\n" /* fs:30h == Teb->Peb */
- : "=r" (pPeb) /* can't have two memory operands */
- : /* no inputs */
- );
-
-#elif defined(_MSC_VER)
-
- __asm mov eax, fs:0x30;
- __asm mov pPeb, eax
-
-#else
-#error Unknown compiler for inline assembler
-#endif
-
- return pPeb;
-}
#endif
diff --git a/reactos/lib/crt/crt.xml b/reactos/lib/crt/crt.xml
index 34572403c00..5d0e8342ab5 100644
--- a/reactos/lib/crt/crt.xml
+++ b/reactos/lib/crt/crt.xml
@@ -22,17 +22,6 @@
putch.c
ungetch.c
-
- ctype.c
- isalnum.c
- isascii.c
- iscntrl.c
- isgraph.c
- isprint.c
- ispunct.c
- isupper.c
- isctype.c
-
chdir.c
chdrive.c
diff --git a/reactos/lib/crt/ctype/ctype.c b/reactos/lib/crt/ctype/ctype.c
deleted file mode 100644
index f98fab7d6c3..00000000000
--- a/reactos/lib/crt/ctype/ctype.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/ctype.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-unsigned short _ctype[] = {
- 0, /* , 0xFFFF */
- _CONTROL, /* CTRL+@, 0x00 */
- _CONTROL, /* CTRL+A, 0x01 */
- _CONTROL, /* CTRL+B, 0x02 */
- _CONTROL, /* CTRL+C, 0x03 */
- _CONTROL, /* CTRL+D, 0x04 */
- _CONTROL, /* CTRL+E, 0x05 */
- _CONTROL, /* CTRL+F, 0x06 */
- _CONTROL, /* CTRL+G, 0x07 */
- _CONTROL, /* CTRL+H, 0x08 */
- _CONTROL | _SPACE, /* CTRL+I, 0x09 */
- _CONTROL | _SPACE, /* CTRL+J, 0x0a */
- _CONTROL | _SPACE, /* CTRL+K, 0x0b */
- _CONTROL | _SPACE, /* CTRL+L, 0x0c */
- _CONTROL | _SPACE, /* CTRL+M, 0x0d */
- _CONTROL, /* CTRL+N, 0x0e */
- _CONTROL, /* CTRL+O, 0x0f */
- _CONTROL, /* CTRL+P, 0x10 */
- _CONTROL, /* CTRL+Q, 0x11 */
- _CONTROL, /* CTRL+R, 0x12 */
- _CONTROL, /* CTRL+S, 0x13 */
- _CONTROL, /* CTRL+T, 0x14 */
- _CONTROL, /* CTRL+U, 0x15 */
- _CONTROL, /* CTRL+V, 0x16 */
- _CONTROL, /* CTRL+W, 0x17 */
- _CONTROL, /* CTRL+X, 0x18 */
- _CONTROL, /* CTRL+Y, 0x19 */
- _CONTROL, /* CTRL+Z, 0x1a */
- _CONTROL, /* CTRL+[, 0x1b */
- _CONTROL, /* CTRL+\, 0x1c */
- _CONTROL, /* CTRL+], 0x1d */
- _CONTROL, /* CTRL+^, 0x1e */
- _CONTROL, /* CTRL+_, 0x1f */
- _SPACE | _BLANK, /* ` ', 0x20 */
- _PUNCT, /* `!', 0x21 */
- _PUNCT, /* 0x22 */
- _PUNCT, /* `#', 0x23 */
- _PUNCT, /* `$', 0x24 */
- _PUNCT, /* `%', 0x25 */
- _PUNCT, /* `&', 0x26 */
- _PUNCT, /* 0x27 */
- _PUNCT, /* `(', 0x28 */
- _PUNCT, /* `)', 0x29 */
- _PUNCT, /* `*', 0x2a */
- _PUNCT, /* `+', 0x2b */
- _PUNCT, /* `,', 0x2c */
- _PUNCT, /* `-', 0x2d */
- _PUNCT, /* `.', 0x2e */
- _PUNCT, /* `/', 0x2f */
- _DIGIT | _HEX, /* `0', 0x30 */
- _DIGIT | _HEX, /* `1', 0x31 */
- _DIGIT | _HEX, /* `2', 0x32 */
- _DIGIT | _HEX, /* `3', 0x33 */
- _DIGIT | _HEX, /* `4', 0x34 */
- _DIGIT | _HEX, /* `5', 0x35 */
- _DIGIT | _HEX, /* `6', 0x36 */
- _DIGIT | _HEX, /* `7', 0x37 */
- _DIGIT | _HEX, /* `8', 0x38 */
- _DIGIT | _HEX, /* `9', 0x39 */
- _PUNCT, /* `:', 0x3a */
- _PUNCT, /* `;', 0x3b */
- _PUNCT, /* `<', 0x3c */
- _PUNCT, /* `=', 0x3d */
- _PUNCT, /* `>', 0x3e */
- _PUNCT, /* `?', 0x3f */
- _PUNCT, /* `@', 0x40 */
- _UPPER | _HEX, /* `A', 0x41 */
- _UPPER | _HEX, /* `B', 0x42 */
- _UPPER | _HEX, /* `C', 0x43 */
- _UPPER | _HEX, /* `D', 0x44 */
- _UPPER | _HEX, /* `E', 0x45 */
- _UPPER | _HEX, /* `F', 0x46 */
- _UPPER, /* `G', 0x47 */
- _UPPER, /* `H', 0x48 */
- _UPPER, /* `I', 0x49 */
- _UPPER, /* `J', 0x4a */
- _UPPER, /* `K', 0x4b */
- _UPPER, /* `L', 0x4c */
- _UPPER, /* `M', 0x4d */
- _UPPER, /* `N', 0x4e */
- _UPPER, /* `O', 0x4f */
- _UPPER, /* `P', 0x50 */
- _UPPER, /* `Q', 0x51 */
- _UPPER, /* `R', 0x52 */
- _UPPER, /* `S', 0x53 */
- _UPPER, /* `T', 0x54 */
- _UPPER, /* `U', 0x55 */
- _UPPER, /* `V', 0x56 */
- _UPPER, /* `W', 0x57 */
- _UPPER, /* `X', 0x58 */
- _UPPER, /* `Y', 0x59 */
- _UPPER, /* `Z', 0x5a */
- _PUNCT, /* `[', 0x5b */
- _PUNCT, /* 0x5c */
- _PUNCT, /* `]', 0x5d */
- _PUNCT, /* `^', 0x5e */
- _PUNCT, /* `_', 0x5f */
- _PUNCT, /* 0x60 */
- _LOWER | _HEX, /* `a', 0x61 */
- _LOWER | _HEX, /* `b', 0x62 */
- _LOWER | _HEX, /* `c', 0x63 */
- _LOWER | _HEX, /* `d', 0x64 */
- _LOWER | _HEX, /* `e', 0x65 */
- _LOWER | _HEX, /* `f', 0x66 */
- _LOWER, /* `g', 0x67 */
- _LOWER, /* `h', 0x68 */
- _LOWER, /* `i', 0x69 */
- _LOWER, /* `j', 0x6a */
- _LOWER, /* `k', 0x6b */
- _LOWER, /* `l', 0x6c */
- _LOWER, /* `m', 0x6d */
- _LOWER, /* `n', 0x6e */
- _LOWER, /* `o', 0x6f */
- _LOWER, /* `p', 0x70 */
- _LOWER, /* `q', 0x71 */
- _LOWER, /* `r', 0x72 */
- _LOWER, /* `s', 0x73 */
- _LOWER, /* `t', 0x74 */
- _LOWER, /* `u', 0x75 */
- _LOWER, /* `v', 0x76 */
- _LOWER, /* `w', 0x77 */
- _LOWER, /* `x', 0x78 */
- _LOWER, /* `y', 0x79 */
- _LOWER, /* `z', 0x7a */
- _PUNCT, /* `{', 0x7b */
- _PUNCT, /* `|', 0x7c */
- _PUNCT, /* `}', 0x7d */
- _PUNCT, /* `~', 0x7e */
- _CONTROL, /* 0x7f */
- 0, /* 0x80 */
- 0, /* 0x81 */
- 0, /* 0x82 */
- 0, /* 0x83 */
- 0, /* 0x84 */
- 0, /* 0x85 */
- 0, /* 0x86 */
- 0, /* 0x87 */
- 0, /* 0x88 */
- 0, /* 0x89 */
- 0, /* 0x8a */
- 0, /* 0x8b */
- 0, /* 0x8c */
- 0, /* 0x8d */
- 0, /* 0x8e */
- 0, /* 0x8f */
- 0, /* 0x90 */
- 0, /* 0x91 */
- 0, /* 0x92 */
- 0, /* 0x93 */
- 0, /* 0x94 */
- 0, /* 0x95 */
- 0, /* 0x96 */
- 0, /* 0x97 */
- 0, /* 0x98 */
- 0, /* 0x99 */
- 0, /* 0x9a */
- 0, /* 0x9b */
- 0, /* 0x9c */
- 0, /* 0x9d */
- 0, /* 0x9e */
- 0, /* 0x9f */
- 0, /* 0xa0 */
- 0, /* 0xa1 */
- 0, /* 0xa2 */
- 0, /* 0xa3 */
- 0, /* 0xa4 */
- 0, /* 0xa5 */
- 0, /* 0xa6 */
- 0, /* 0xa7 */
- 0, /* 0xa8 */
- 0, /* 0xa9 */
- 0, /* 0xaa */
- 0, /* 0xab */
- 0, /* 0xac */
- 0, /* 0xad */
- 0, /* 0xae */
- 0, /* 0xaf */
- 0, /* 0xb0 */
- 0, /* 0xb1 */
- 0, /* 0xb2 */
- 0, /* 0xb3 */
- 0, /* 0xb4 */
- 0, /* 0xb5 */
- 0, /* 0xb6 */
- 0, /* 0xb7 */
- 0, /* 0xb8 */
- 0, /* 0xb9 */
- 0, /* 0xba */
- 0, /* 0xbb */
- 0, /* 0xbc */
- 0, /* 0xbd */
- 0, /* 0xbe */
- 0, /* 0xbf */
- 0, /* 0xc0 */
- 0, /* 0xc1 */
- 0, /* 0xc2 */
- 0, /* 0xc3 */
- 0, /* 0xc4 */
- 0, /* 0xc5 */
- 0, /* 0xc6 */
- 0, /* 0xc7 */
- 0, /* 0xc8 */
- 0, /* 0xc9 */
- 0, /* 0xca */
- 0, /* 0xcb */
- 0, /* 0xcc */
- 0, /* 0xcd */
- 0, /* 0xce */
- 0, /* 0xcf */
- 0, /* 0xd0 */
- 0, /* 0xd1 */
- 0, /* 0xd2 */
- 0, /* 0xd3 */
- 0, /* 0xd4 */
- 0, /* 0xd5 */
- 0, /* 0xd6 */
- 0, /* 0xd7 */
- 0, /* 0xd8 */
- 0, /* 0xd9 */
- 0, /* 0xda */
- 0, /* 0xdb */
- 0, /* 0xdc */
- 0, /* 0xdd */
- 0, /* 0xde */
- 0, /* 0xdf */
- 0, /* 0xe0 */
- 0, /* 0xe1 */
- 0, /* 0xe2 */
- 0, /* 0xe3 */
- 0, /* 0xe4 */
- 0, /* 0xe5 */
- 0, /* 0xe6 */
- 0, /* 0xe7 */
- 0, /* 0xe8 */
- 0, /* 0xe9 */
- 0, /* 0xea */
- 0, /* 0xeb */
- 0, /* 0xec */
- 0, /* 0xed */
- 0, /* 0xee */
- 0, /* 0xef */
- 0, /* 0xf0 */
- 0, /* 0xf1 */
- 0, /* 0xf2 */
- 0, /* 0xf3 */
- 0, /* 0xf4 */
- 0, /* 0xf5 */
- 0, /* 0xf6 */
- 0, /* 0xf7 */
- 0, /* 0xf8 */
- 0, /* 0xf9 */
- 0, /* 0xfa */
- 0, /* 0xfb */
- 0, /* 0xfc */
- 0, /* 0xfd */
- 0, /* 0xfe */
- 0 /* 0xff */
-};
-
-/* EOF */
diff --git a/reactos/lib/crt/ctype/isalnum.c b/reactos/lib/crt/ctype/isalnum.c
deleted file mode 100644
index a9a484ea1b6..00000000000
--- a/reactos/lib/crt/ctype/isalnum.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/msvcrt/ctype/isalnum.c
- * PURPOSE: Test for a alpha numeric character
- * PROGRAMER: Boudewijn Dekker
- * UPDATE HISTORY:
- * 28/12/98: Created
- */
-#include
-
-
-#undef isalnum
-/*
- * @implemented
- */
-int isalnum(int c)
-{
- return _isctype(c, _ALPHA | _DIGIT);
-}
-
-#undef iswalnum
-/*
- * @implemented
- */
-int iswalnum(wint_t c)
-{
- return iswctype(c, _ALPHA | _DIGIT);
-}
diff --git a/reactos/lib/crt/ctype/isalpha.c b/reactos/lib/crt/ctype/isalpha.c
deleted file mode 100644
index daa1878964d..00000000000
--- a/reactos/lib/crt/ctype/isalpha.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/mscvrt/ctype/isalpha.c
- * PURPOSE: Checks if a character is alphanumeric
- * PROGRAMER: Boudewijn Dekker
- * UPDATE HISTORY:
- * 28/12/98: Created
- */
-
-#include
-
-
-#undef isalpha
-
-/*
- * @implemented
- */
-int isalpha(int c)
-{
- return _isctype(c, _ALPHA);
-}
-
-#undef iswalpha
-/*
- * @implemented
- */
-int iswalpha(wint_t c)
-{
- return iswctype(c, _ALPHA);
-}
diff --git a/reactos/lib/crt/ctype/isascii.c b/reactos/lib/crt/ctype/isascii.c
deleted file mode 100644
index 9c98a603339..00000000000
--- a/reactos/lib/crt/ctype/isascii.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/msvcrt/ctype/isascii.c
- * PURPOSE: Checks if a character is ascii
- * PROGRAMER: Boudewijn Dekker
- * UPDATE HISTORY:
- * 28/12/98: Created
- */
-
-#include
-
-/*
- * @implemented
- */
-int __isascii(int c)
-{
- return (!((c)&(~0x7f)));
-}
-
-/*
- * @implemented
- */
-int iswascii(wint_t c)
-{
- return __isascii(c);
-}
diff --git a/reactos/lib/crt/ctype/iscntrl.c b/reactos/lib/crt/ctype/iscntrl.c
deleted file mode 100644
index 8d128a29c55..00000000000
--- a/reactos/lib/crt/ctype/iscntrl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/iscntrl.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-#undef iscntrl
-/*
- * @implemented
- */
-int iscntrl(int c)
-{
- return _isctype(c, _CONTROL);
-}
-
-#undef iswcntrl
-/*
- * @implemented
- */
-int iswcntrl(wint_t c)
-{
- return iswctype(c, _CONTROL);
-}
diff --git a/reactos/lib/crt/ctype/iscsym.c b/reactos/lib/crt/ctype/iscsym.c
deleted file mode 100644
index bd108b4347e..00000000000
--- a/reactos/lib/crt/ctype/iscsym.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/msvcrt/ctype/iscsym.c
- * PURPOSE: Check for a valid characters in a c symbol
- * PROGRAMER: Boudewijn Dekker
- * UPDATE HISTORY:
- * 28/12/98: Created
- */
-#include
-
-
-/*
- * @implemented
- */
-int __iscsymf(int c)
-{
- return (isalpha(c) || ( c == '_' )) ;
-}
-
-/*
- * @implemented
- */
-int __iscsym(int c)
-{
- return (isalnum(c) || ( c == '_' )) ;
-}
diff --git a/reactos/lib/crt/ctype/isctype.c b/reactos/lib/crt/ctype/isctype.c
deleted file mode 100644
index b691bbe6f57..00000000000
--- a/reactos/lib/crt/ctype/isctype.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/isctype.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-
-extern unsigned short _ctype[];
-
-unsigned short *_pctype = _ctype + 1;
-unsigned short *_pwctype = _ctype + 1;
-
-
-/*
- * @implemented
- */
-unsigned short **__p__pctype(void)
-{
- return &_pctype;
-}
-
-/*
- * @implemented
- */
-unsigned short **__p__pwctype(void)
-{
- return &_pwctype;
-}
-
-/*
- * @implemented
- */
-int _isctype(int c, int ctypeFlags)
-{
- return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
-}
-
-/*
- * @implemented
- */
-int iswctype(wint_t wc, wctype_t wctypeFlags)
-{
- return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
-}
-
-/*
- * obsolete
- *
- * @implemented
- */
-int is_wctype(wint_t wc, wctype_t wctypeFlags)
-{
- return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
-}
-
-/* EOF */
diff --git a/reactos/lib/crt/ctype/isdigit.c b/reactos/lib/crt/ctype/isdigit.c
deleted file mode 100644
index 16219bc876f..00000000000
--- a/reactos/lib/crt/ctype/isdigit.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/isdigit.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-
-#undef isdigit
-/*
- * @implemented
- */
-int isdigit(int c)
-{
- return _isctype(c, _DIGIT);
-}
-
-#undef iswdigit
-/*
- * @implemented
- */
-int iswdigit(wint_t c)
-{
- return iswctype(c, _DIGIT);
-}
diff --git a/reactos/lib/crt/ctype/isgraph.c b/reactos/lib/crt/ctype/isgraph.c
deleted file mode 100644
index 8db6f627ca8..00000000000
--- a/reactos/lib/crt/ctype/isgraph.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/isgraph.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-#undef isgraph
-/*
- * @implemented
- */
-int isgraph(int c)
-{
- return _isctype(c,_PUNCT | _ALPHA | _DIGIT);
-}
-
-#undef iswgraph
-/*
- * @implemented
- */
-int iswgraph(wint_t c)
-{
- return iswctype(c,_PUNCT | _ALPHA | _DIGIT);
-}
diff --git a/reactos/lib/crt/ctype/islower.c b/reactos/lib/crt/ctype/islower.c
deleted file mode 100644
index a804c05f9a9..00000000000
--- a/reactos/lib/crt/ctype/islower.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/islower.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-
-#undef islower
-/*
- * @implemented
- */
-int islower(int c)
-{
- return _isctype(c, _LOWER);
-}
-
-/*
- * @implemented
- */
-int iswlower(wint_t c)
-{
- return iswctype(c, _LOWER);
-}
diff --git a/reactos/lib/crt/ctype/isprint.c b/reactos/lib/crt/ctype/isprint.c
deleted file mode 100644
index c98cecbcd52..00000000000
--- a/reactos/lib/crt/ctype/isprint.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/isprint.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-#undef isprint
-/*
- * @implemented
- */
-int isprint(int c)
-{
- return _isctype(c,_BLANK | _PUNCT | _ALPHA | _DIGIT);
-}
-
-/*
- * @implemented
- */
-int iswprint(wint_t c)
-{
- return iswctype((unsigned short)c,_BLANK | _PUNCT | _ALPHA | _DIGIT);
-}
diff --git a/reactos/lib/crt/ctype/ispunct.c b/reactos/lib/crt/ctype/ispunct.c
deleted file mode 100644
index b0197aa7cf5..00000000000
--- a/reactos/lib/crt/ctype/ispunct.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/ispunct.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-#undef ispunct
-/*
- * @implemented
- */
-int ispunct(int c)
-{
- return _isctype(c, _PUNCT);
-}
-
-#undef iswpunct
-/*
- * @implemented
- */
-int iswpunct(wint_t c)
-{
- return iswctype(c, _PUNCT);
-}
diff --git a/reactos/lib/crt/ctype/isspace.c b/reactos/lib/crt/ctype/isspace.c
deleted file mode 100644
index 57e01b2cb2d..00000000000
--- a/reactos/lib/crt/ctype/isspace.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/msvcrt/ctype/isspace.c
- * PURPOSE: Test for a space character
- * PROGRAMER: Boudewijn Dekker
- * UPDATE HISTORY:
- * 28/12/98: Created
- */
-
-#include
-
-
-#undef isspace
-/*
- * @implemented
- */
-int isspace(int c)
-{
- return _isctype(c,_SPACE);
-}
-
-#undef iswspace
-/*
- * @implemented
- */
-int iswspace(wint_t c)
-{
- return iswctype(c,_SPACE);
-}
diff --git a/reactos/lib/crt/ctype/isupper.c b/reactos/lib/crt/ctype/isupper.c
deleted file mode 100644
index fe19dc4cec9..00000000000
--- a/reactos/lib/crt/ctype/isupper.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/isupper.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-#undef isupper
-/*
- * @implemented
- */
-int isupper(int c)
-{
- return _isctype(c, _UPPER);
-}
-
-/*
- * @implemented
- */
-int iswupper(wint_t c)
-{
- return iswctype(c, _UPPER);
-}
diff --git a/reactos/lib/crt/ctype/isxdigit.c b/reactos/lib/crt/ctype/isxdigit.c
deleted file mode 100644
index 04be96ec81a..00000000000
--- a/reactos/lib/crt/ctype/isxdigit.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/isxdigit.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-#undef isxdigit
-/*
- * @implemented
- */
-int isxdigit(int c)
-{
- return _isctype(c, _HEX);
-}
-
-#undef iswxdigit
-/*
- * @implemented
- */
-int iswxdigit(wint_t c)
-{
- return iswctype(c, _HEX);
-}
-
diff --git a/reactos/lib/crt/ctype/toascii.c b/reactos/lib/crt/ctype/toascii.c
deleted file mode 100644
index 81e3c02e8df..00000000000
--- a/reactos/lib/crt/ctype/toascii.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/toascii.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-/*
- * @implemented
- */
-int __toascii(int c)
-{
- return((unsigned)(c) & 0x7F);
-}
diff --git a/reactos/lib/crt/ctype/tolower.c b/reactos/lib/crt/ctype/tolower.c
deleted file mode 100644
index 324d0f16eab..00000000000
--- a/reactos/lib/crt/ctype/tolower.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/tolower.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-#undef tolower
-/*
- * @implemented
- */
-int tolower(int c)
-{
- if (_isctype (c, _UPPER))
- return (c - ('A' - 'a'));
- return(c);
-}
-
-#undef towlower
-/*
- * @implemented
- */
-wchar_t towlower(wchar_t c)
-{
- if (iswctype (c, _UPPER))
- return (c - (L'A' - L'a'));
- return(c);
-}
-
-/*
- * @implemented
- */
-int _tolower(int c)
-{
- return (c - ('A' - 'a'));
-}
-
-/*
-int towlower(wint_t);
-int towupper(wint_t);
-
-wchar_t _towlower(wchar_t c)
-{
- return (c - (L'A' - L'a'));
-}
-*/
-
-
diff --git a/reactos/lib/crt/ctype/toupper.c b/reactos/lib/crt/ctype/toupper.c
deleted file mode 100644
index df93d23e677..00000000000
--- a/reactos/lib/crt/ctype/toupper.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: msvcrt/ctype/toupper.c
- * PURPOSE: C Runtime
- * PROGRAMMER: Copyright (C) 1995 DJ Delorie
- */
-
-#include
-
-#undef toupper
-/*
- * @implemented
- */
-int toupper(int c)
-{
- if (_isctype (c, _LOWER))
- return (c + ('A' - 'a'));
- return(c);
-}
-
-#undef towupper
-/*
- * @implemented
- */
-wchar_t towupper(wchar_t c)
-{
- if (iswctype (c, _LOWER))
- return (c + (L'A' - L'a'));
- return(c);
-}
-
-/*
- * @implemented
- */
-int _toupper(int c)
-{
- return (c + ('A' - 'a'));
-}
-
-/*
-wchar_t _towupper(wchar_t c)
-{
- return (c + (L'A' - L'a'));
-}
-*/
-
diff --git a/reactos/lib/ntdll/ntdll.xml b/reactos/lib/ntdll/ntdll.xml
index 78445567e46..c87d72289a5 100644
--- a/reactos/lib/ntdll/ntdll.xml
+++ b/reactos/lib/ntdll/ntdll.xml
@@ -37,11 +37,6 @@
libsupp.c
version.c
-
- sprintf.c
- sscanf.c
- swprintf.c
-
ntdll.rc
diff --git a/reactos/lib/rtl/rtl.xml b/reactos/lib/rtl/rtl.xml
index 1be8c54b433..5a074b5f0e8 100644
--- a/reactos/lib/rtl/rtl.xml
+++ b/reactos/lib/rtl/rtl.xml
@@ -51,6 +51,8 @@
sd.c
security.c
sid.c
+ sprintf.c
+ swprintf.c
splaytree.c
thread.c
time.c
diff --git a/reactos/lib/ntdll/stdio/sprintf.c b/reactos/lib/rtl/sprintf.c
similarity index 93%
rename from reactos/lib/ntdll/stdio/sprintf.c
rename to reactos/lib/rtl/sprintf.c
index 9934dfafe2e..cd958e2e696 100644
--- a/reactos/lib/ntdll/stdio/sprintf.c
+++ b/reactos/lib/rtl/sprintf.c
@@ -1,551 +1,545 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: lib/ntdll/stdio/sprintf.c
- * PURPOSE: Single byte sprintf functions
- * PROGRAMMERS: David Welch
- * Eric Kohl
- *
- */
-
-/*
- * linux/lib/vsprintf.c
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
-/*
- * Wirzenius wrote this portably, Torvalds fucked it up :-)
- */
-
-#include
-
-#define ZEROPAD 1 /* pad with zero */
-#define SIGN 2 /* unsigned/signed long */
-#define PLUS 4 /* show plus */
-#define SPACE 8 /* space if plus */
-#define LEFT 16 /* left justified */
-#define SPECIAL 32 /* 0x */
-#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
-
-
-static
-__inline
-int
-do_div(long long *n, int base)
-{
- int a;
- a = ((unsigned long long) *n) % (unsigned) base;
- *n = ((unsigned long long) *n) / (unsigned) base;
- return a;
-}
-
-
-static int skip_atoi(const char **s)
-{
- int i=0;
-
- while (isdigit(**s))
- i = i*10 + *((*s)++) - '0';
- return i;
-}
-
-
-static char *
-number(char * buf, char * end, long long num, int base, int size, int precision, int type)
-{
- char c,sign,tmp[66];
- const char *digits;
- const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
- const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- int i;
-
- digits = (type & LARGE) ? large_digits : small_digits;
- if (type & LEFT)
- type &= ~ZEROPAD;
- if (base < 2 || base > 36)
- return 0;
- c = (type & ZEROPAD) ? '0' : ' ';
- sign = 0;
- if (type & SIGN) {
- if (num < 0) {
- sign = '-';
- num = -num;
- size--;
- } else if (type & PLUS) {
- sign = '+';
- size--;
- } else if (type & SPACE) {
- sign = ' ';
- size--;
- }
- }
- if (type & SPECIAL) {
- if (base == 16)
- size -= 2;
- else if (base == 8)
- size--;
- }
- i = 0;
- if (num == 0)
- tmp[i++]='0';
- else while (num != 0)
- tmp[i++] = digits[do_div(&num,base)];
- if (i > precision)
- precision = i;
- size -= precision;
- if (!(type&(ZEROPAD+LEFT))) {
- while(size-->0) {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- }
- if (sign) {
- if (buf <= end)
- *buf = sign;
- ++buf;
- }
- if (type & SPECIAL) {
- if (base==8) {
- if (buf <= end)
- *buf = '0';
- ++buf;
- } else if (base==16) {
- if (buf <= end)
- *buf = '0';
- ++buf;
- if (buf <= end)
- *buf = digits[33];
- ++buf;
- }
- }
- if (!(type & LEFT)) {
- while (size-- > 0) {
- if (buf <= end)
- *buf = c;
- ++buf;
- }
- }
- while (i < precision--) {
- if (buf <= end)
- *buf = '0';
- ++buf;
- }
- while (i-- > 0) {
- if (buf <= end)
- *buf = tmp[i];
- ++buf;
- }
- while (size-- > 0) {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- return buf;
-}
-
-static char*
-string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags)
-{
- int i;
- if (s == NULL)
- {
- s = "";
- len = 6;
- }
- else
- {
- if (len == -1)
- {
- len = 0;
- while ((unsigned int)len < (unsigned int)precision && s[len])
- len++;
- }
- else
- {
- if ((unsigned int)len > (unsigned int)precision)
- len = precision;
- }
- }
- if (!(flags & LEFT))
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- for (i = 0; i < len; ++i)
- {
- if (buf <= end)
- *buf = *s++;
- ++buf;
- }
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- return buf;
-}
-
-static char*
-stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
-{
- int i;
- if (sw == NULL)
- {
- sw = L"";
- len = 6;
- }
- else
- {
- if (len == -1)
- {
- len = 0;
- while ((unsigned int)len < (unsigned int)precision && sw[len])
- len++;
- }
- else
- {
- if ((unsigned int)len > (unsigned int)precision)
- len = precision;
- }
- }
- if (!(flags & LEFT))
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- for (i = 0; i < len; ++i)
- {
- if (buf <= end)
- *buf = (unsigned char)(*sw++);
- ++buf;
- }
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- return buf;
-}
-
-/*
- * @implemented
- */
-int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args)
-{
- int len;
- unsigned long long num;
- int base;
- char *str, *end;
- const char *s;
- const wchar_t *sw;
-
- int flags; /* flags to number() */
-
- int field_width; /* width of output field */
- int precision; /* min. # of digits for integers; max
- number of chars for from string */
- int qualifier; /* 'h', 'l', 'L', 'I' or 'w' for integer fields */
-
- str = buf;
- end = buf + cnt - 1;
- if (end < buf - 1) {
- end = ((void *) -1);
- cnt = end - buf + 1;
- }
-
- for ( ; *fmt ; ++fmt) {
- if (*fmt != '%') {
- if (str <= end)
- *str = *fmt;
- ++str;
- continue;
- }
-
- /* process flags */
- flags = 0;
- repeat:
- ++fmt; /* this also skips first '%' */
- switch (*fmt) {
- case '-': flags |= LEFT; goto repeat;
- case '+': flags |= PLUS; goto repeat;
- case ' ': flags |= SPACE; goto repeat;
- case '#': flags |= SPECIAL; goto repeat;
- case '0': flags |= ZEROPAD; goto repeat;
- }
-
- /* get field width */
- field_width = -1;
- if (isdigit(*fmt))
- field_width = skip_atoi(&fmt);
- else if (*fmt == '*') {
- ++fmt;
- /* it's the next argument */
- field_width = va_arg(args, int);
- if (field_width < 0) {
- field_width = -field_width;
- flags |= LEFT;
- }
- }
-
- /* get the precision */
- precision = -1;
- if (*fmt == '.') {
- ++fmt;
- if (isdigit(*fmt))
- precision = skip_atoi(&fmt);
- else if (*fmt == '*') {
- ++fmt;
- /* it's the next argument */
- precision = va_arg(args, int);
- }
- if (precision < 0)
- precision = 0;
- }
-
- /* get the conversion qualifier */
- qualifier = -1;
- if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') {
- qualifier = *fmt;
- ++fmt;
- } else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') {
- qualifier = *fmt;
- fmt += 3;
- }
-
- /* default base */
- base = 10;
-
- switch (*fmt) {
- case 'c': /* finished */
- if (!(flags & LEFT))
- while (--field_width > 0) {
- if (str <= end)
- *str = ' ';
- ++str;
- }
- if (qualifier == 'l' || qualifier == 'w') {
- if (str <= end)
- *str = (unsigned char)(wchar_t) va_arg(args, int);
- ++str;
- } else {
- if (str <= end)
- *str = (unsigned char) va_arg(args, int);
- ++str;
- }
- while (--field_width > 0) {
- if (str <= end)
- *str = ' ';
- ++str;
- }
- continue;
-
- case 'C': /* finished */
- if (!(flags & LEFT))
- while (--field_width > 0) {
- if (str <= end)
- *str = ' ';
- ++str;
- }
- if (qualifier == 'h') {
- if (str <= end)
- *str = (unsigned char) va_arg(args, int);
- ++str;
- } else {
- if (str <= end)
- *str = (unsigned char)(wchar_t) va_arg(args, int);
- ++str;
- }
- while (--field_width > 0) {
- if (str <= end)
- *str = ' ';
- ++str;
- }
- continue;
-
- case 's': /* finished */
- if (qualifier == 'l' || qualifier == 'w') {
- /* print unicode string */
- sw = va_arg(args, wchar_t *);
- str = stringw(str, end, sw, -1, field_width, precision, flags);
- } else {
- /* print ascii string */
- s = va_arg(args, char *);
- str = string(str, end, s, -1, field_width, precision, flags);
- }
- continue;
-
- case 'S':
- if (qualifier == 'h') {
- /* print ascii string */
- s = va_arg(args, char *);
- str = string(str, end, s, -1, field_width, precision, flags);
- } else {
- /* print unicode string */
- sw = va_arg(args, wchar_t *);
- str = stringw(str, end, sw, -1, field_width, precision, flags);
- }
- continue;
-
- case 'Z':
- if (qualifier == 'w') {
- /* print counted unicode string */
- PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
- if ((pus == NULL) || (pus->Buffer == NULL)) {
- sw = NULL;
- len = -1;
- } else {
- sw = pus->Buffer;
- len = pus->Length / sizeof(WCHAR);
- }
- str = stringw(str, end, sw, len, field_width, precision, flags);
- } else {
- /* print counted ascii string */
- PANSI_STRING pus = va_arg(args, PANSI_STRING);
- if ((pus == NULL) || (pus->Buffer == NULL)) {
- s = NULL;
- len = -1;
- } else {
- s = pus->Buffer;
- len = pus->Length;
- }
- str = string(str, end, s, len, field_width, precision, flags);
- }
- continue;
-
- case 'p':
- if (field_width == -1) {
- field_width = 2 * sizeof(void *);
- flags |= ZEROPAD;
- }
- str = number(str, end,
- (unsigned long) va_arg(args, void *), 16,
- field_width, precision, flags);
- continue;
-
- case 'n':
- /* FIXME: What does C99 say about the overflow case here? */
- if (qualifier == 'l') {
- long * ip = va_arg(args, long *);
- *ip = (str - buf);
- } else {
- int * ip = va_arg(args, int *);
- *ip = (str - buf);
- }
- continue;
-
- /* integer number formats - set up the flags and "break" */
- case 'o':
- base = 8;
- break;
-
- case 'b':
- base = 2;
- break;
-
- case 'X':
- flags |= LARGE;
- case 'x':
- base = 16;
- break;
-
- case 'd':
- case 'i':
- flags |= SIGN;
- case 'u':
- break;
-
- default:
- if (*fmt != '%') {
- if (str <= end)
- *str = '%';
- ++str;
- }
- if (*fmt) {
- if (str <= end)
- *str = *fmt;
- ++str;
- } else
- --fmt;
- continue;
- }
-
- if (qualifier == 'I')
- num = va_arg(args, unsigned long long);
- else if (qualifier == 'l') {
- if (flags & SIGN)
- num = va_arg(args, long);
- else
- num = va_arg(args, unsigned long);
- }
- else if (qualifier == 'h') {
- if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- }
- else {
- if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- }
- str = number(str, end, num, base, field_width, precision, flags);
- }
- if (str <= end)
- *str = '\0';
- else if (cnt > 0)
- /* don't write out a null byte if the buf size is zero */
- *end = '\0';
- return str-buf;
-}
-
-
-/*
- * @implemented
- */
-int sprintf(char * buf, const char *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=_vsnprintf(buf,INT_MAX,fmt,args);
- va_end(args);
- return i;
-}
-
-
-/*
- * @implemented
- */
-int _snprintf(char * buf, size_t cnt, const char *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=_vsnprintf(buf,cnt,fmt,args);
- va_end(args);
- return i;
-}
-
-
-/*
- * @implemented
- */
-int vsprintf(char *buf, const char *fmt, va_list args)
-{
- return _vsnprintf(buf,INT_MAX,fmt,args);
-}
-
-/* EOF */
+/*
+ * PROGRAMMERS: David Welch
+ * Eric Kohl
+ *
+ */
+
+/*
+ * linux/lib/vsprintf.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
+/*
+ * Wirzenius wrote this portably, Torvalds fucked it up :-)
+ */
+#include
+
+#define ZEROPAD 1 /* pad with zero */
+#define SIGN 2 /* unsigned/signed long */
+#define PLUS 4 /* show plus */
+#define SPACE 8 /* space if plus */
+#define LEFT 16 /* left justified */
+#define SPECIAL 32 /* 0x */
+#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
+
+
+static
+__inline
+int
+do_div(long long *n, int base)
+{
+ int a;
+ a = ((unsigned long long) *n) % (unsigned) base;
+ *n = ((unsigned long long) *n) / (unsigned) base;
+ return a;
+}
+
+
+static int skip_atoi(const char **s)
+{
+ int i=0;
+
+ while (isdigit(**s))
+ i = i*10 + *((*s)++) - '0';
+ return i;
+}
+
+
+static char *
+number(char * buf, char * end, long long num, int base, int size, int precision, int type)
+{
+ char c,sign,tmp[66];
+ const char *digits;
+ const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+ const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ int i;
+
+ digits = (type & LARGE) ? large_digits : small_digits;
+ if (type & LEFT)
+ type &= ~ZEROPAD;
+ if (base < 2 || base > 36)
+ return 0;
+ c = (type & ZEROPAD) ? '0' : ' ';
+ sign = 0;
+ if (type & SIGN) {
+ if (num < 0) {
+ sign = '-';
+ num = -num;
+ size--;
+ } else if (type & PLUS) {
+ sign = '+';
+ size--;
+ } else if (type & SPACE) {
+ sign = ' ';
+ size--;
+ }
+ }
+ if (type & SPECIAL) {
+ if (base == 16)
+ size -= 2;
+ else if (base == 8)
+ size--;
+ }
+ i = 0;
+ if (num == 0)
+ tmp[i++]='0';
+ else while (num != 0)
+ tmp[i++] = digits[do_div(&num,base)];
+ if (i > precision)
+ precision = i;
+ size -= precision;
+ if (!(type&(ZEROPAD+LEFT))) {
+ while(size-->0) {
+ if (buf <= end)
+ *buf = ' ';
+ ++buf;
+ }
+ }
+ if (sign) {
+ if (buf <= end)
+ *buf = sign;
+ ++buf;
+ }
+ if (type & SPECIAL) {
+ if (base==8) {
+ if (buf <= end)
+ *buf = '0';
+ ++buf;
+ } else if (base==16) {
+ if (buf <= end)
+ *buf = '0';
+ ++buf;
+ if (buf <= end)
+ *buf = digits[33];
+ ++buf;
+ }
+ }
+ if (!(type & LEFT)) {
+ while (size-- > 0) {
+ if (buf <= end)
+ *buf = c;
+ ++buf;
+ }
+ }
+ while (i < precision--) {
+ if (buf <= end)
+ *buf = '0';
+ ++buf;
+ }
+ while (i-- > 0) {
+ if (buf <= end)
+ *buf = tmp[i];
+ ++buf;
+ }
+ while (size-- > 0) {
+ if (buf <= end)
+ *buf = ' ';
+ ++buf;
+ }
+ return buf;
+}
+
+static char*
+string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags)
+{
+ int i;
+ if (s == NULL)
+ {
+ s = "";
+ len = 6;
+ }
+ else
+ {
+ if (len == -1)
+ {
+ len = 0;
+ while ((unsigned int)len < (unsigned int)precision && s[len])
+ len++;
+ }
+ else
+ {
+ if ((unsigned int)len > (unsigned int)precision)
+ len = precision;
+ }
+ }
+ if (!(flags & LEFT))
+ while (len < field_width--)
+ {
+ if (buf <= end)
+ *buf = ' ';
+ ++buf;
+ }
+ for (i = 0; i < len; ++i)
+ {
+ if (buf <= end)
+ *buf = *s++;
+ ++buf;
+ }
+ while (len < field_width--)
+ {
+ if (buf <= end)
+ *buf = ' ';
+ ++buf;
+ }
+ return buf;
+}
+
+static char*
+stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
+{
+ int i;
+ if (sw == NULL)
+ {
+ sw = L"";
+ len = 6;
+ }
+ else
+ {
+ if (len == -1)
+ {
+ len = 0;
+ while ((unsigned int)len < (unsigned int)precision && sw[len])
+ len++;
+ }
+ else
+ {
+ if ((unsigned int)len > (unsigned int)precision)
+ len = precision;
+ }
+ }
+ if (!(flags & LEFT))
+ while (len < field_width--)
+ {
+ if (buf <= end)
+ *buf = ' ';
+ ++buf;
+ }
+ for (i = 0; i < len; ++i)
+ {
+ if (buf <= end)
+ *buf = (unsigned char)(*sw++);
+ ++buf;
+ }
+ while (len < field_width--)
+ {
+ if (buf <= end)
+ *buf = ' ';
+ ++buf;
+ }
+ return buf;
+}
+
+/*
+ * @implemented
+ */
+int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args)
+{
+ int len;
+ unsigned long long num;
+ int base;
+ char *str, *end;
+ const char *s;
+ const wchar_t *sw;
+
+ int flags; /* flags to number() */
+
+ int field_width; /* width of output field */
+ int precision; /* min. # of digits for integers; max
+ number of chars for from string */
+ int qualifier; /* 'h', 'l', 'L', 'I' or 'w' for integer fields */
+
+ str = buf;
+ end = buf + cnt - 1;
+ if (end < buf - 1) {
+ end = ((void *) -1);
+ cnt = end - buf + 1;
+ }
+
+ for ( ; *fmt ; ++fmt) {
+ if (*fmt != '%') {
+ if (str <= end)
+ *str = *fmt;
+ ++str;
+ continue;
+ }
+
+ /* process flags */
+ flags = 0;
+ repeat:
+ ++fmt; /* this also skips first '%' */
+ switch (*fmt) {
+ case '-': flags |= LEFT; goto repeat;
+ case '+': flags |= PLUS; goto repeat;
+ case ' ': flags |= SPACE; goto repeat;
+ case '#': flags |= SPECIAL; goto repeat;
+ case '0': flags |= ZEROPAD; goto repeat;
+ }
+
+ /* get field width */
+ field_width = -1;
+ if (isdigit(*fmt))
+ field_width = skip_atoi(&fmt);
+ else if (*fmt == '*') {
+ ++fmt;
+ /* it's the next argument */
+ field_width = va_arg(args, int);
+ if (field_width < 0) {
+ field_width = -field_width;
+ flags |= LEFT;
+ }
+ }
+
+ /* get the precision */
+ precision = -1;
+ if (*fmt == '.') {
+ ++fmt;
+ if (isdigit(*fmt))
+ precision = skip_atoi(&fmt);
+ else if (*fmt == '*') {
+ ++fmt;
+ /* it's the next argument */
+ precision = va_arg(args, int);
+ }
+ if (precision < 0)
+ precision = 0;
+ }
+
+ /* get the conversion qualifier */
+ qualifier = -1;
+ if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') {
+ qualifier = *fmt;
+ ++fmt;
+ } else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') {
+ qualifier = *fmt;
+ fmt += 3;
+ }
+
+ /* default base */
+ base = 10;
+
+ switch (*fmt) {
+ case 'c': /* finished */
+ if (!(flags & LEFT))
+ while (--field_width > 0) {
+ if (str <= end)
+ *str = ' ';
+ ++str;
+ }
+ if (qualifier == 'l' || qualifier == 'w') {
+ if (str <= end)
+ *str = (unsigned char)(wchar_t) va_arg(args, int);
+ ++str;
+ } else {
+ if (str <= end)
+ *str = (unsigned char) va_arg(args, int);
+ ++str;
+ }
+ while (--field_width > 0) {
+ if (str <= end)
+ *str = ' ';
+ ++str;
+ }
+ continue;
+
+ case 'C': /* finished */
+ if (!(flags & LEFT))
+ while (--field_width > 0) {
+ if (str <= end)
+ *str = ' ';
+ ++str;
+ }
+ if (qualifier == 'h') {
+ if (str <= end)
+ *str = (unsigned char) va_arg(args, int);
+ ++str;
+ } else {
+ if (str <= end)
+ *str = (unsigned char)(wchar_t) va_arg(args, int);
+ ++str;
+ }
+ while (--field_width > 0) {
+ if (str <= end)
+ *str = ' ';
+ ++str;
+ }
+ continue;
+
+ case 's': /* finished */
+ if (qualifier == 'l' || qualifier == 'w') {
+ /* print unicode string */
+ sw = va_arg(args, wchar_t *);
+ str = stringw(str, end, sw, -1, field_width, precision, flags);
+ } else {
+ /* print ascii string */
+ s = va_arg(args, char *);
+ str = string(str, end, s, -1, field_width, precision, flags);
+ }
+ continue;
+
+ case 'S':
+ if (qualifier == 'h') {
+ /* print ascii string */
+ s = va_arg(args, char *);
+ str = string(str, end, s, -1, field_width, precision, flags);
+ } else {
+ /* print unicode string */
+ sw = va_arg(args, wchar_t *);
+ str = stringw(str, end, sw, -1, field_width, precision, flags);
+ }
+ continue;
+
+ case 'Z':
+ if (qualifier == 'w') {
+ /* print counted unicode string */
+ PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
+ if ((pus == NULL) || (pus->Buffer == NULL)) {
+ sw = NULL;
+ len = -1;
+ } else {
+ sw = pus->Buffer;
+ len = pus->Length / sizeof(WCHAR);
+ }
+ str = stringw(str, end, sw, len, field_width, precision, flags);
+ } else {
+ /* print counted ascii string */
+ PANSI_STRING pus = va_arg(args, PANSI_STRING);
+ if ((pus == NULL) || (pus->Buffer == NULL)) {
+ s = NULL;
+ len = -1;
+ } else {
+ s = pus->Buffer;
+ len = pus->Length;
+ }
+ str = string(str, end, s, len, field_width, precision, flags);
+ }
+ continue;
+
+ case 'p':
+ if (field_width == -1) {
+ field_width = 2 * sizeof(void *);
+ flags |= ZEROPAD;
+ }
+ str = number(str, end,
+ (unsigned long) va_arg(args, void *), 16,
+ field_width, precision, flags);
+ continue;
+
+ case 'n':
+ /* FIXME: What does C99 say about the overflow case here? */
+ if (qualifier == 'l') {
+ long * ip = va_arg(args, long *);
+ *ip = (str - buf);
+ } else {
+ int * ip = va_arg(args, int *);
+ *ip = (str - buf);
+ }
+ continue;
+
+ /* integer number formats - set up the flags and "break" */
+ case 'o':
+ base = 8;
+ break;
+
+ case 'b':
+ base = 2;
+ break;
+
+ case 'X':
+ flags |= LARGE;
+ case 'x':
+ base = 16;
+ break;
+
+ case 'd':
+ case 'i':
+ flags |= SIGN;
+ case 'u':
+ break;
+
+ default:
+ if (*fmt != '%') {
+ if (str <= end)
+ *str = '%';
+ ++str;
+ }
+ if (*fmt) {
+ if (str <= end)
+ *str = *fmt;
+ ++str;
+ } else
+ --fmt;
+ continue;
+ }
+
+ if (qualifier == 'I')
+ num = va_arg(args, unsigned long long);
+ else if (qualifier == 'l') {
+ if (flags & SIGN)
+ num = va_arg(args, long);
+ else
+ num = va_arg(args, unsigned long);
+ }
+ else if (qualifier == 'h') {
+ if (flags & SIGN)
+ num = va_arg(args, int);
+ else
+ num = va_arg(args, unsigned int);
+ }
+ else {
+ if (flags & SIGN)
+ num = va_arg(args, int);
+ else
+ num = va_arg(args, unsigned int);
+ }
+ str = number(str, end, num, base, field_width, precision, flags);
+ }
+ if (str <= end)
+ *str = '\0';
+ else if (cnt > 0)
+ /* don't write out a null byte if the buf size is zero */
+ *end = '\0';
+ return str-buf;
+}
+
+
+/*
+ * @implemented
+ */
+int sprintf(char * buf, const char *fmt, ...)
+{
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i=_vsnprintf(buf,MAXLONG,fmt,args);
+ va_end(args);
+ return i;
+}
+
+
+/*
+ * @implemented
+ */
+int _snprintf(char * buf, size_t cnt, const char *fmt, ...)
+{
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i=_vsnprintf(buf,cnt,fmt,args);
+ va_end(args);
+ return i;
+}
+
+
+/*
+ * @implemented
+ */
+int vsprintf(char *buf, const char *fmt, va_list args)
+{
+ return _vsnprintf(buf,MAXLONG,fmt,args);
+}
+
+/* EOF */
diff --git a/reactos/lib/ntdll/stdio/swprintf.c b/reactos/lib/rtl/swprintf.c
similarity index 93%
rename from reactos/lib/ntdll/stdio/swprintf.c
rename to reactos/lib/rtl/swprintf.c
index 3ee5149b3ba..294e8d9eb79 100644
--- a/reactos/lib/ntdll/stdio/swprintf.c
+++ b/reactos/lib/rtl/swprintf.c
@@ -1,554 +1,545 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: lib/ntdll/stdio/swprintf.c
- * PURPOSE: unicode sprintf functions
- * PROGRAMMERS: David Welch
- * Eric Kohl
- *
- * TODO:
- * - Verify the implementation of '%Z'.
- */
-
-/*
- * linux/lib/vsprintf.c
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
-/*
- * Wirzenius wrote this portably, Torvalds fucked it up :-)
- */
-
-#include
-#define NDEBUG
-#include
-#include
-#include
-
-#define ZEROPAD 1 /* pad with zero */
-#define SIGN 2 /* unsigned/signed long */
-#define PLUS 4 /* show plus */
-#define SPACE 8 /* space if plus */
-#define LEFT 16 /* left justified */
-#define SPECIAL 32 /* 0x */
-#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
-
-
-static
-__inline
-int
-do_div(long long *n, int base)
-{
- int a;
- a = ((unsigned long long) *n) % (unsigned) base;
- *n = ((unsigned long long) *n) / (unsigned) base;
- return a;
-}
-
-
-static int skip_atoi(const wchar_t **s)
-{
- int i=0;
-
- while (iswdigit(**s))
- i = i*10 + *((*s)++) - L'0';
- return i;
-}
-
-
-static wchar_t *
-number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int precision, int type)
-{
- wchar_t c, sign, tmp[66];
- const wchar_t *digits;
- const wchar_t *small_digits = L"0123456789abcdefghijklmnopqrstuvwxyz";
- const wchar_t *large_digits = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- int i;
-
- digits = (type & LARGE) ? large_digits : small_digits;
- if (type & LEFT)
- type &= ~ZEROPAD;
- if (base < 2 || base > 36)
- return 0;
- c = (type & ZEROPAD) ? L'0' : L' ';
- sign = 0;
- if (type & SIGN) {
- if (num < 0) {
- sign = L'-';
- num = -num;
- size--;
- } else if (type & PLUS) {
- sign = L'+';
- size--;
- } else if (type & SPACE) {
- sign = ' ';
- size--;
- }
- }
- if (type & SPECIAL) {
- if (base == 16)
- size -= 2;
- else if (base == 8)
- size--;
- }
- i = 0;
- if (num == 0)
- tmp[i++] = L'0';
- else while (num != 0)
- tmp[i++] = digits[do_div(&num,base)];
- if (i > precision)
- precision = i;
- size -= precision;
- if (!(type&(ZEROPAD+LEFT))) {
- while(size-->0) {
- if (buf <= end)
- *buf = L' ';
- ++buf;
- }
- }
- if (sign) {
- if (buf <= end)
- *buf = sign;
- ++buf;
- }
- if (type & SPECIAL) {
- if (base==8) {
- if (buf <= end)
- *buf = L'0';
- ++buf;
- } else if (base==16) {
- if (buf <= end)
- *buf = L'0';
- ++buf;
- if (buf <= end)
- *buf = digits[33];
- ++buf;
- }
- }
- if (!(type & LEFT)) {
- while (size-- > 0) {
- if (buf <= end)
- *buf = c;
- ++buf;
- }
- }
- while (i < precision--) {
- if (buf <= end)
- *buf = L'0';
- ++buf;
- }
- while (i-- > 0) {
- if (buf <= end)
- *buf = tmp[i];
- ++buf;
- }
- while (size-- > 0) {
- if (buf <= end)
- *buf = L' ';
- ++buf;
- }
- return buf;
-}
-
-static wchar_t*
-string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int precision, int flags)
-{
- int i;
- if (s == NULL)
- {
- s = "";
- len = 6;
- }
- else
- {
- if (len == -1)
- {
- len = 0;
- while ((unsigned int)len < (unsigned int)precision && s[len])
- len++;
- }
- else
- {
- if ((unsigned int)len > (unsigned int)precision)
- len = precision;
- }
- }
- if (!(flags & LEFT))
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = L' ';
- ++buf;
- }
- for (i = 0; i < len; ++i)
- {
- if (buf <= end)
- *buf = *s++;
- ++buf;
- }
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = L' ';
- ++buf;
- }
- return buf;
-}
-
-static wchar_t*
-stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
-{
- int i;
- if (sw == NULL)
- {
- sw = L"";
- len = 6;
- }
- else
- {
- if (len == -1)
- {
- len = 0;
- while ((unsigned int)len < (unsigned int)precision && sw[len])
- len++;
- }
- else
- {
- if ((unsigned int)len > (unsigned int)precision)
- len = precision;
- }
- }
- if (!(flags & LEFT))
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = L' ';
- buf++;
- }
- for (i = 0; i < len; ++i)
- {
- if (buf <= end)
- *buf = *sw++;
- buf++;
- }
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = L' ';
- buf++;
- }
- return buf;
-}
-
-/*
- * @implemented
- */
-int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args)
-{
- int len;
- unsigned long long num;
- int base;
- wchar_t * str, * end;
- const char *s;
- const wchar_t *sw;
-
- int flags; /* flags to number() */
-
- int field_width; /* width of output field */
- int precision; /* min. # of digits for integers; max
- number of chars for from string */
- int qualifier; /* 'h', 'l', 'L', 'w' or 'I' for integer fields */
-
- str = buf;
- end = buf + cnt - 1;
- if (end < buf - 1) {
- end = ((void *) -1);
- cnt = end - buf + 1;
- }
-
- for ( ; *fmt ; ++fmt) {
- if (*fmt != L'%') {
- if (str <= end)
- *str = *fmt;
- ++str;
- continue;
- }
-
- /* process flags */
- flags = 0;
- repeat:
- ++fmt; /* this also skips first '%' */
- switch (*fmt) {
- case L'-': flags |= LEFT; goto repeat;
- case L'+': flags |= PLUS; goto repeat;
- case L' ': flags |= SPACE; goto repeat;
- case L'#': flags |= SPECIAL; goto repeat;
- case L'0': flags |= ZEROPAD; goto repeat;
- }
-
- /* get field width */
- field_width = -1;
- if (iswdigit(*fmt))
- field_width = skip_atoi(&fmt);
- else if (*fmt == L'*') {
- ++fmt;
- /* it's the next argument */
- field_width = va_arg(args, int);
- if (field_width < 0) {
- field_width = -field_width;
- flags |= LEFT;
- }
- }
-
- /* get the precision */
- precision = -1;
- if (*fmt == L'.') {
- ++fmt;
- if (iswdigit(*fmt))
- precision = skip_atoi(&fmt);
- else if (*fmt == L'*') {
- ++fmt;
- /* it's the next argument */
- precision = va_arg(args, int);
- }
- if (precision < 0)
- precision = 0;
- }
-
- /* get the conversion qualifier */
- qualifier = -1;
- if (*fmt == L'h' || *fmt == L'l' || *fmt == L'L' || *fmt == L'w') {
- qualifier = *fmt;
- ++fmt;
- } else if (*fmt == L'I' && *(fmt+1) == L'6' && *(fmt+2) == L'4') {
- qualifier = *fmt;
- fmt += 3;
- }
-
- /* default base */
- base = 10;
-
- switch (*fmt) {
- case L'c':
- if (!(flags & LEFT))
- while (--field_width > 0) {
- if (str <= end)
- *str = L' ';
- ++str;
- }
- if (qualifier == 'h') {
- if (str <= end)
- *str = (wchar_t) va_arg(args, int);
- ++str;
- } else {
- if (str <= end)
- *str = (wchar_t) va_arg(args, int);
- ++str;
- }
- while (--field_width > 0) {
- if (str <= end)
- *str = L' ';
- ++str;
- }
- continue;
-
- case L'C':
- if (!(flags & LEFT))
- while (--field_width > 0) {
- if (str <= end)
- *str = L' ';
- ++str;
- }
- if (qualifier == 'l' || qualifier == 'w') {
- if (str <= end)
- *str = (wchar_t) va_arg(args, int);
- ++str;
- } else {
- if (str <= end)
- *str = (wchar_t) va_arg(args, int);
- ++str;
- }
- while (--field_width > 0) {
- if (str <= end)
- *str = L' ';
- ++str;
- }
- continue;
-
- case L's':
- if (qualifier == 'h') {
- /* print ascii string */
- s = va_arg(args, char *);
- str = string(str, end, s, -1, field_width, precision, flags);
- } else {
- /* print unicode string */
- sw = va_arg(args, wchar_t *);
- str = stringw(str, end, sw, -1, field_width, precision, flags);
- }
- continue;
-
- case L'S':
- if (qualifier == 'l' || qualifier == 'w') {
- /* print unicode string */
- sw = va_arg(args, wchar_t *);
- str = stringw(str, end, sw, -1, field_width, precision, flags);
- } else {
- /* print ascii string */
- s = va_arg(args, char *);
- str = string(str, end, s, -1, field_width, precision, flags);
- }
- continue;
-
- case L'Z':
- if (qualifier == 'h') {
- /* print counted ascii string */
- PANSI_STRING pus = va_arg(args, PANSI_STRING);
- if ((pus == NULL) || (pus->Buffer == NULL)) {
- s = NULL;
- len = -1;
- } else {
- s = pus->Buffer;
- len = pus->Length;
- }
- str = string(str, end, s, len, field_width, precision, flags);
- } else {
- /* print counted unicode string */
- PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
- if ((pus == NULL) || (pus->Buffer == NULL)) {
- sw = NULL;
- len = -1;
- } else {
- sw = pus->Buffer;
- len = pus->Length / sizeof(WCHAR);
- }
- str = stringw(str, end, sw, len, field_width, precision, flags);
- }
- continue;
-
- case L'p':
- if (field_width == -1) {
- field_width = 2*sizeof(void *);
- flags |= ZEROPAD;
- }
- str = number(str, end,
- (unsigned long) va_arg(args, void *), 16,
- field_width, precision, flags);
- continue;
-
- case L'n':
- /* FIXME: What does C99 say about the overflow case here? */
- if (qualifier == 'l') {
- long * ip = va_arg(args, long *);
- *ip = (str - buf);
- } else {
- int * ip = va_arg(args, int *);
- *ip = (str - buf);
- }
- continue;
-
- /* integer number formats - set up the flags and "break" */
- case L'o':
- base = 8;
- break;
-
- case L'b':
- base = 2;
- break;
-
- case L'X':
- flags |= LARGE;
- case L'x':
- base = 16;
- break;
-
- case L'd':
- case L'i':
- flags |= SIGN;
- case L'u':
- break;
-
- default:
- if (*fmt != L'%') {
- if (str <= end)
- *str = L'%';
- ++str;
- }
- if (*fmt) {
- if (str <= end)
- *str = *fmt;
- ++str;
- } else
- --fmt;
- continue;
- }
-
- if (qualifier == L'I')
- num = va_arg(args, unsigned long long);
- else if (qualifier == L'l') {
- if (flags & SIGN)
- num = va_arg(args, long);
- else
- num = va_arg(args, unsigned long);
- }
- else if (qualifier == L'h') {
- if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- }
- else {
- if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- }
- str = number(str, end, num, base, field_width, precision, flags);
- }
- if (str <= end)
- *str = L'\0';
- else if (cnt > 0)
- /* don't write out a null byte if the buf size is zero */
- *end = L'\0';
- return str-buf;
-}
-
-
-/*
- * @implemented
- */
-int swprintf(wchar_t *buf, const wchar_t *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=_vsnwprintf(buf,INT_MAX,fmt,args);
- va_end(args);
- return i;
-}
-
-
-/*
- * @implemented
- */
-int _snwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=_vsnwprintf(buf,cnt,fmt,args);
- va_end(args);
- return i;
-}
-
-
-int vswprintf(wchar_t *buf, const wchar_t *fmt, va_list args)
-{
- return _vsnwprintf(buf,INT_MAX,fmt,args);
-}
-
-/* EOF */
+/*
+ * PROGRAMMERS: David Welch
+ * Eric Kohl
+ *
+ * TODO:
+ * - Verify the implementation of '%Z'.
+ */
+
+/*
+ * linux/lib/vsprintf.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
+/*
+ * Wirzenius wrote this portably, Torvalds fucked it up :-)
+ */
+
+#include
+
+#define ZEROPAD 1 /* pad with zero */
+#define SIGN 2 /* unsigned/signed long */
+#define PLUS 4 /* show plus */
+#define SPACE 8 /* space if plus */
+#define LEFT 16 /* left justified */
+#define SPECIAL 32 /* 0x */
+#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
+
+
+static
+__inline
+int
+do_div(long long *n, int base)
+{
+ int a;
+ a = ((unsigned long long) *n) % (unsigned) base;
+ *n = ((unsigned long long) *n) / (unsigned) base;
+ return a;
+}
+
+
+static int skip_atoi(const wchar_t **s)
+{
+ int i=0;
+
+ while (iswdigit(**s))
+ i = i*10 + *((*s)++) - L'0';
+ return i;
+}
+
+
+static wchar_t *
+number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int precision, int type)
+{
+ wchar_t c, sign, tmp[66];
+ const wchar_t *digits;
+ const wchar_t *small_digits = L"0123456789abcdefghijklmnopqrstuvwxyz";
+ const wchar_t *large_digits = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ int i;
+
+ digits = (type & LARGE) ? large_digits : small_digits;
+ if (type & LEFT)
+ type &= ~ZEROPAD;
+ if (base < 2 || base > 36)
+ return 0;
+ c = (type & ZEROPAD) ? L'0' : L' ';
+ sign = 0;
+ if (type & SIGN) {
+ if (num < 0) {
+ sign = L'-';
+ num = -num;
+ size--;
+ } else if (type & PLUS) {
+ sign = L'+';
+ size--;
+ } else if (type & SPACE) {
+ sign = ' ';
+ size--;
+ }
+ }
+ if (type & SPECIAL) {
+ if (base == 16)
+ size -= 2;
+ else if (base == 8)
+ size--;
+ }
+ i = 0;
+ if (num == 0)
+ tmp[i++] = L'0';
+ else while (num != 0)
+ tmp[i++] = digits[do_div(&num,base)];
+ if (i > precision)
+ precision = i;
+ size -= precision;
+ if (!(type&(ZEROPAD+LEFT))) {
+ while(size-->0) {
+ if (buf <= end)
+ *buf = L' ';
+ ++buf;
+ }
+ }
+ if (sign) {
+ if (buf <= end)
+ *buf = sign;
+ ++buf;
+ }
+ if (type & SPECIAL) {
+ if (base==8) {
+ if (buf <= end)
+ *buf = L'0';
+ ++buf;
+ } else if (base==16) {
+ if (buf <= end)
+ *buf = L'0';
+ ++buf;
+ if (buf <= end)
+ *buf = digits[33];
+ ++buf;
+ }
+ }
+ if (!(type & LEFT)) {
+ while (size-- > 0) {
+ if (buf <= end)
+ *buf = c;
+ ++buf;
+ }
+ }
+ while (i < precision--) {
+ if (buf <= end)
+ *buf = L'0';
+ ++buf;
+ }
+ while (i-- > 0) {
+ if (buf <= end)
+ *buf = tmp[i];
+ ++buf;
+ }
+ while (size-- > 0) {
+ if (buf <= end)
+ *buf = L' ';
+ ++buf;
+ }
+ return buf;
+}
+
+static wchar_t*
+string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int precision, int flags)
+{
+ int i;
+ if (s == NULL)
+ {
+ s = "";
+ len = 6;
+ }
+ else
+ {
+ if (len == -1)
+ {
+ len = 0;
+ while ((unsigned int)len < (unsigned int)precision && s[len])
+ len++;
+ }
+ else
+ {
+ if ((unsigned int)len > (unsigned int)precision)
+ len = precision;
+ }
+ }
+ if (!(flags & LEFT))
+ while (len < field_width--)
+ {
+ if (buf <= end)
+ *buf = L' ';
+ ++buf;
+ }
+ for (i = 0; i < len; ++i)
+ {
+ if (buf <= end)
+ *buf = *s++;
+ ++buf;
+ }
+ while (len < field_width--)
+ {
+ if (buf <= end)
+ *buf = L' ';
+ ++buf;
+ }
+ return buf;
+}
+
+static wchar_t*
+stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
+{
+ int i;
+ if (sw == NULL)
+ {
+ sw = L"";
+ len = 6;
+ }
+ else
+ {
+ if (len == -1)
+ {
+ len = 0;
+ while ((unsigned int)len < (unsigned int)precision && sw[len])
+ len++;
+ }
+ else
+ {
+ if ((unsigned int)len > (unsigned int)precision)
+ len = precision;
+ }
+ }
+ if (!(flags & LEFT))
+ while (len < field_width--)
+ {
+ if (buf <= end)
+ *buf = L' ';
+ buf++;
+ }
+ for (i = 0; i < len; ++i)
+ {
+ if (buf <= end)
+ *buf = *sw++;
+ buf++;
+ }
+ while (len < field_width--)
+ {
+ if (buf <= end)
+ *buf = L' ';
+ buf++;
+ }
+ return buf;
+}
+
+/*
+ * @implemented
+ */
+int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args)
+{
+ int len;
+ unsigned long long num;
+ int base;
+ wchar_t * str, * end;
+ const char *s;
+ const wchar_t *sw;
+
+ int flags; /* flags to number() */
+
+ int field_width; /* width of output field */
+ int precision; /* min. # of digits for integers; max
+ number of chars for from string */
+ int qualifier; /* 'h', 'l', 'L', 'w' or 'I' for integer fields */
+
+ str = buf;
+ end = buf + cnt - 1;
+ if (end < buf - 1) {
+ end = ((void *) -1);
+ cnt = end - buf + 1;
+ }
+
+ for ( ; *fmt ; ++fmt) {
+ if (*fmt != L'%') {
+ if (str <= end)
+ *str = *fmt;
+ ++str;
+ continue;
+ }
+
+ /* process flags */
+ flags = 0;
+ repeat:
+ ++fmt; /* this also skips first '%' */
+ switch (*fmt) {
+ case L'-': flags |= LEFT; goto repeat;
+ case L'+': flags |= PLUS; goto repeat;
+ case L' ': flags |= SPACE; goto repeat;
+ case L'#': flags |= SPECIAL; goto repeat;
+ case L'0': flags |= ZEROPAD; goto repeat;
+ }
+
+ /* get field width */
+ field_width = -1;
+ if (iswdigit(*fmt))
+ field_width = skip_atoi(&fmt);
+ else if (*fmt == L'*') {
+ ++fmt;
+ /* it's the next argument */
+ field_width = va_arg(args, int);
+ if (field_width < 0) {
+ field_width = -field_width;
+ flags |= LEFT;
+ }
+ }
+
+ /* get the precision */
+ precision = -1;
+ if (*fmt == L'.') {
+ ++fmt;
+ if (iswdigit(*fmt))
+ precision = skip_atoi(&fmt);
+ else if (*fmt == L'*') {
+ ++fmt;
+ /* it's the next argument */
+ precision = va_arg(args, int);
+ }
+ if (precision < 0)
+ precision = 0;
+ }
+
+ /* get the conversion qualifier */
+ qualifier = -1;
+ if (*fmt == L'h' || *fmt == L'l' || *fmt == L'L' || *fmt == L'w') {
+ qualifier = *fmt;
+ ++fmt;
+ } else if (*fmt == L'I' && *(fmt+1) == L'6' && *(fmt+2) == L'4') {
+ qualifier = *fmt;
+ fmt += 3;
+ }
+
+ /* default base */
+ base = 10;
+
+ switch (*fmt) {
+ case L'c':
+ if (!(flags & LEFT))
+ while (--field_width > 0) {
+ if (str <= end)
+ *str = L' ';
+ ++str;
+ }
+ if (qualifier == 'h') {
+ if (str <= end)
+ *str = (wchar_t) va_arg(args, int);
+ ++str;
+ } else {
+ if (str <= end)
+ *str = (wchar_t) va_arg(args, int);
+ ++str;
+ }
+ while (--field_width > 0) {
+ if (str <= end)
+ *str = L' ';
+ ++str;
+ }
+ continue;
+
+ case L'C':
+ if (!(flags & LEFT))
+ while (--field_width > 0) {
+ if (str <= end)
+ *str = L' ';
+ ++str;
+ }
+ if (qualifier == 'l' || qualifier == 'w') {
+ if (str <= end)
+ *str = (wchar_t) va_arg(args, int);
+ ++str;
+ } else {
+ if (str <= end)
+ *str = (wchar_t) va_arg(args, int);
+ ++str;
+ }
+ while (--field_width > 0) {
+ if (str <= end)
+ *str = L' ';
+ ++str;
+ }
+ continue;
+
+ case L's':
+ if (qualifier == 'h') {
+ /* print ascii string */
+ s = va_arg(args, char *);
+ str = string(str, end, s, -1, field_width, precision, flags);
+ } else {
+ /* print unicode string */
+ sw = va_arg(args, wchar_t *);
+ str = stringw(str, end, sw, -1, field_width, precision, flags);
+ }
+ continue;
+
+ case L'S':
+ if (qualifier == 'l' || qualifier == 'w') {
+ /* print unicode string */
+ sw = va_arg(args, wchar_t *);
+ str = stringw(str, end, sw, -1, field_width, precision, flags);
+ } else {
+ /* print ascii string */
+ s = va_arg(args, char *);
+ str = string(str, end, s, -1, field_width, precision, flags);
+ }
+ continue;
+
+ case L'Z':
+ if (qualifier == 'h') {
+ /* print counted ascii string */
+ PANSI_STRING pus = va_arg(args, PANSI_STRING);
+ if ((pus == NULL) || (pus->Buffer == NULL)) {
+ s = NULL;
+ len = -1;
+ } else {
+ s = pus->Buffer;
+ len = pus->Length;
+ }
+ str = string(str, end, s, len, field_width, precision, flags);
+ } else {
+ /* print counted unicode string */
+ PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
+ if ((pus == NULL) || (pus->Buffer == NULL)) {
+ sw = NULL;
+ len = -1;
+ } else {
+ sw = pus->Buffer;
+ len = pus->Length / sizeof(WCHAR);
+ }
+ str = stringw(str, end, sw, len, field_width, precision, flags);
+ }
+ continue;
+
+ case L'p':
+ if (field_width == -1) {
+ field_width = 2*sizeof(void *);
+ flags |= ZEROPAD;
+ }
+ str = number(str, end,
+ (unsigned long) va_arg(args, void *), 16,
+ field_width, precision, flags);
+ continue;
+
+ case L'n':
+ /* FIXME: What does C99 say about the overflow case here? */
+ if (qualifier == 'l') {
+ long * ip = va_arg(args, long *);
+ *ip = (str - buf);
+ } else {
+ int * ip = va_arg(args, int *);
+ *ip = (str - buf);
+ }
+ continue;
+
+ /* integer number formats - set up the flags and "break" */
+ case L'o':
+ base = 8;
+ break;
+
+ case L'b':
+ base = 2;
+ break;
+
+ case L'X':
+ flags |= LARGE;
+ case L'x':
+ base = 16;
+ break;
+
+ case L'd':
+ case L'i':
+ flags |= SIGN;
+ case L'u':
+ break;
+
+ default:
+ if (*fmt != L'%') {
+ if (str <= end)
+ *str = L'%';
+ ++str;
+ }
+ if (*fmt) {
+ if (str <= end)
+ *str = *fmt;
+ ++str;
+ } else
+ --fmt;
+ continue;
+ }
+
+ if (qualifier == L'I')
+ num = va_arg(args, unsigned long long);
+ else if (qualifier == L'l') {
+ if (flags & SIGN)
+ num = va_arg(args, long);
+ else
+ num = va_arg(args, unsigned long);
+ }
+ else if (qualifier == L'h') {
+ if (flags & SIGN)
+ num = va_arg(args, int);
+ else
+ num = va_arg(args, unsigned int);
+ }
+ else {
+ if (flags & SIGN)
+ num = va_arg(args, int);
+ else
+ num = va_arg(args, unsigned int);
+ }
+ str = number(str, end, num, base, field_width, precision, flags);
+ }
+ if (str <= end)
+ *str = L'\0';
+ else if (cnt > 0)
+ /* don't write out a null byte if the buf size is zero */
+ *end = L'\0';
+ return str-buf;
+}
+
+
+/*
+ * @implemented
+ */
+int swprintf(wchar_t *buf, const wchar_t *fmt, ...)
+{
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i=_vsnwprintf(buf,MAXLONG,fmt,args);
+ va_end(args);
+ return i;
+}
+
+
+/*
+ * @implemented
+ */
+int _snwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, ...)
+{
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i=_vsnwprintf(buf,cnt,fmt,args);
+ va_end(args);
+ return i;
+}
+
+
+int vswprintf(wchar_t *buf, const wchar_t *fmt, va_list args)
+{
+ return _vsnwprintf(buf,MAXLONG,fmt,args);
+}
+
+/* EOF */
diff --git a/reactos/lib/string/ctype.c b/reactos/lib/string/ctype.c
index 06d011c3ebd..c9a542f185e 100644
--- a/reactos/lib/string/ctype.c
+++ b/reactos/lib/string/ctype.c
@@ -269,6 +269,22 @@ unsigned short _ctype[] = {
unsigned short *_pctype = _ctype + 1;
unsigned short *_pwctype = _ctype + 1;
+/*
+ * @implemented
+ */
+unsigned short **__p__pctype(void)
+{
+ return &_pctype;
+}
+
+/*
+ * @implemented
+ */
+unsigned short **__p__pwctype(void)
+{
+ return &_pwctype;
+}
+
int _isctype (int c, int ctypeFlags)
{
return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
@@ -282,6 +298,16 @@ int iswctype(wint_t wc, wctype_t wctypeFlags)
return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
}
+/*
+ * obsolete
+ *
+ * @implemented
+ */
+int is_wctype(wint_t wc, wctype_t wctypeFlags)
+{
+ return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
+}
+
/*
* @implemented
*/
@@ -298,6 +324,14 @@ int isalnum(int c)
return(_isctype(c, _ALPHA | _DIGIT));
}
+/*
+ * @implemented
+ */
+int iswalnum(wint_t c)
+{
+ return iswctype(c, _ALPHA | _DIGIT);
+}
+
/*
* @implemented
*/
@@ -306,6 +340,14 @@ int __isascii(int c)
return ((unsigned char)c <= 0x7f);
}
+/*
+ * @implemented
+ */
+int iswascii(wint_t c)
+{
+ return __isascii(c);
+}
+
/*
* @implemented
*/
@@ -403,6 +445,14 @@ int iswalpha(wint_t c)
return (iswctype (c, _ALPHA));
}
+/*
+ * @implemented
+ */
+int iswcntrl(wint_t c)
+{
+ return iswctype(c, _CONTROL);
+}
+
/*
* @implemented
*/
@@ -411,6 +461,31 @@ int iswdigit(wint_t c)
return (iswctype (c, _DIGIT));
}
+/*
+ * @implemented
+ */
+int iswgraph(wint_t c)
+{
+ return iswctype(c,_PUNCT | _ALPHA | _DIGIT);
+}
+
+/*
+ * @implemented
+ */
+int iswprint(wint_t c)
+{
+ return iswctype((unsigned short)c,_BLANK | _PUNCT | _ALPHA | _DIGIT);
+}
+
+
+/*
+ * @implemented
+ */
+int iswpunct(wint_t c)
+{
+ return iswctype(c, _PUNCT);
+}
+
/*
* @implemented
*/
@@ -419,6 +494,15 @@ int iswlower(wint_t c)
return (iswctype (c, _LOWER));
}
+/*
+ * @implemented
+ */
+int iswupper(wint_t c)
+{
+ return iswctype(c, _UPPER);
+}
+
+
/*
* @implemented
*/
diff --git a/reactos/lib/ntdll/stdio/scanf.h b/reactos/lib/string/scanf.h
similarity index 97%
rename from reactos/lib/ntdll/stdio/scanf.h
rename to reactos/lib/string/scanf.h
index dd2fc9f3d60..c6d06ee069e 100644
--- a/reactos/lib/ntdll/stdio/scanf.h
+++ b/reactos/lib/string/scanf.h
@@ -83,17 +83,6 @@ _FUNCTION_ {
int rd = 0, consumed = 0;
int nch;
if (!*format) return 0;
-#ifndef WIDE_SCANF
-#ifdef CONSOLE
- TRACE("(%s): \n", debugstr_a(format));
-#else /* CONSOLE */
-#ifdef STRING
- TRACE("%s (%s)\n", file, debugstr_a(format));
-#else /* STRING */
- TRACE("%p (%s)\n", file, debugstr_a(format));
-#endif /* STRING */
-#endif /* CONSOLE */
-#endif /* WIDE_SCANF */
nch = _GETC_(file);
if (nch == _EOF_) return _EOF_RET;
@@ -232,7 +221,6 @@ _FUNCTION_ {
else _SET_NUMBER_(int);
} else {
if (negative) {
- WARN("Dropping sign in reading a negative number into an unsigned value");
negative = 0;
}
if (I64_prefix) _SET_NUMBER_(ULONGLONG);
@@ -542,7 +530,6 @@ _FUNCTION_ {
if (nch!=_EOF_) {
_UNGETC_(nch, file);
}
- TRACE("returning %d\n", rd);
return rd;
}
diff --git a/reactos/lib/ntdll/stdio/sscanf.c b/reactos/lib/string/sscanf.c
similarity index 83%
rename from reactos/lib/ntdll/stdio/sscanf.c
rename to reactos/lib/string/sscanf.c
index d98b1b205cd..aa4ea837989 100644
--- a/reactos/lib/ntdll/stdio/sscanf.c
+++ b/reactos/lib/string/sscanf.c
@@ -1,8 +1,12 @@
/**/
-#include
-#define NDEBUG
-#include
+#include
+#define NTOS_MODE_USER
+#define _NTSYSTEM_
+#include
+#include
+#include
+#include
#include
/* helper function for *scanf. Returns the value of character c in the
@@ -16,10 +20,6 @@ static int char2digit(char c, int base) {
return -1;
}
-#define debugstr_a(a) (a)
-#define TRACE DPRINT
-#define WARN DPRINT1
-
/* vsscanf */
#undef WIDE_SCANF
#undef CONSOLE
diff --git a/reactos/lib/string/string.xml b/reactos/lib/string/string.xml
index efb29ecfaf1..de8276fb75f 100644
--- a/reactos/lib/string/string.xml
+++ b/reactos/lib/string/string.xml
@@ -96,4 +96,5 @@
wtoi.c
wtol.c
rand.c
+ sscanf.c
diff --git a/reactos/ntoskrnl/ntoskrnl.xml b/reactos/ntoskrnl/ntoskrnl.xml
index 9bbf8b0518d..f7b673ccf68 100644
--- a/reactos/ntoskrnl/ntoskrnl.xml
+++ b/reactos/ntoskrnl/ntoskrnl.xml
@@ -320,9 +320,7 @@
nls.c
purecall.c
regio.c
- sprintf.c
strtok.c
- swprintf.c
access.c
diff --git a/reactos/ntoskrnl/rtl/ctype.c b/reactos/ntoskrnl/rtl/ctype.c
deleted file mode 100644
index 79004133168..00000000000
--- a/reactos/ntoskrnl/rtl/ctype.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/rtl/ctype.c
- * PURPOSE: Character type and conversion functions
- *
- * PROGRAMMERS: Eric Kohl
- */
-#undef __MSVCRT__
-#include
-
-#undef _pctype
-
-#define upalpha ('A' - 'a')
-
-
-unsigned short _ctype[] = {
- 0, /* , 0xFFFF */
- _CONTROL, /* CTRL+@, 0x00 */
- _CONTROL, /* CTRL+A, 0x01 */
- _CONTROL, /* CTRL+B, 0x02 */
- _CONTROL, /* CTRL+C, 0x03 */
- _CONTROL, /* CTRL+D, 0x04 */
- _CONTROL, /* CTRL+E, 0x05 */
- _CONTROL, /* CTRL+F, 0x06 */
- _CONTROL, /* CTRL+G, 0x07 */
- _CONTROL, /* CTRL+H, 0x08 */
- _CONTROL | _SPACE, /* CTRL+I, 0x09 */
- _CONTROL | _SPACE, /* CTRL+J, 0x0a */
- _CONTROL | _SPACE, /* CTRL+K, 0x0b */
- _CONTROL | _SPACE, /* CTRL+L, 0x0c */
- _CONTROL | _SPACE, /* CTRL+M, 0x0d */
- _CONTROL, /* CTRL+N, 0x0e */
- _CONTROL, /* CTRL+O, 0x0f */
- _CONTROL, /* CTRL+P, 0x10 */
- _CONTROL, /* CTRL+Q, 0x11 */
- _CONTROL, /* CTRL+R, 0x12 */
- _CONTROL, /* CTRL+S, 0x13 */
- _CONTROL, /* CTRL+T, 0x14 */
- _CONTROL, /* CTRL+U, 0x15 */
- _CONTROL, /* CTRL+V, 0x16 */
- _CONTROL, /* CTRL+W, 0x17 */
- _CONTROL, /* CTRL+X, 0x18 */
- _CONTROL, /* CTRL+Y, 0x19 */
- _CONTROL, /* CTRL+Z, 0x1a */
- _CONTROL, /* CTRL+[, 0x1b */
- _CONTROL, /* CTRL+\, 0x1c */
- _CONTROL, /* CTRL+], 0x1d */
- _CONTROL, /* CTRL+^, 0x1e */
- _CONTROL, /* CTRL+_, 0x1f */
- _SPACE | _BLANK, /* ` ', 0x20 */
- _PUNCT, /* `!', 0x21 */
- _PUNCT, /* 0x22 */
- _PUNCT, /* `#', 0x23 */
- _PUNCT, /* `$', 0x24 */
- _PUNCT, /* `%', 0x25 */
- _PUNCT, /* `&', 0x26 */
- _PUNCT, /* 0x27 */
- _PUNCT, /* `(', 0x28 */
- _PUNCT, /* `)', 0x29 */
- _PUNCT, /* `*', 0x2a */
- _PUNCT, /* `+', 0x2b */
- _PUNCT, /* `,', 0x2c */
- _PUNCT, /* `-', 0x2d */
- _PUNCT, /* `.', 0x2e */
- _PUNCT, /* `/', 0x2f */
- _DIGIT | _HEX, /* `0', 0x30 */
- _DIGIT | _HEX, /* `1', 0x31 */
- _DIGIT | _HEX, /* `2', 0x32 */
- _DIGIT | _HEX, /* `3', 0x33 */
- _DIGIT | _HEX, /* `4', 0x34 */
- _DIGIT | _HEX, /* `5', 0x35 */
- _DIGIT | _HEX, /* `6', 0x36 */
- _DIGIT | _HEX, /* `7', 0x37 */
- _DIGIT | _HEX, /* `8', 0x38 */
- _DIGIT | _HEX, /* `9', 0x39 */
- _PUNCT, /* `:', 0x3a */
- _PUNCT, /* `;', 0x3b */
- _PUNCT, /* `<', 0x3c */
- _PUNCT, /* `=', 0x3d */
- _PUNCT, /* `>', 0x3e */
- _PUNCT, /* `?', 0x3f */
- _PUNCT, /* `@', 0x40 */
- _UPPER | _HEX, /* `A', 0x41 */
- _UPPER | _HEX, /* `B', 0x42 */
- _UPPER | _HEX, /* `C', 0x43 */
- _UPPER | _HEX, /* `D', 0x44 */
- _UPPER | _HEX, /* `E', 0x45 */
- _UPPER | _HEX, /* `F', 0x46 */
- _UPPER, /* `G', 0x47 */
- _UPPER, /* `H', 0x48 */
- _UPPER, /* `I', 0x49 */
- _UPPER, /* `J', 0x4a */
- _UPPER, /* `K', 0x4b */
- _UPPER, /* `L', 0x4c */
- _UPPER, /* `M', 0x4d */
- _UPPER, /* `N', 0x4e */
- _UPPER, /* `O', 0x4f */
- _UPPER, /* `P', 0x50 */
- _UPPER, /* `Q', 0x51 */
- _UPPER, /* `R', 0x52 */
- _UPPER, /* `S', 0x53 */
- _UPPER, /* `T', 0x54 */
- _UPPER, /* `U', 0x55 */
- _UPPER, /* `V', 0x56 */
- _UPPER, /* `W', 0x57 */
- _UPPER, /* `X', 0x58 */
- _UPPER, /* `Y', 0x59 */
- _UPPER, /* `Z', 0x5a */
- _PUNCT, /* `[', 0x5b */
- _PUNCT, /* 0x5c */
- _PUNCT, /* `]', 0x5d */
- _PUNCT, /* `^', 0x5e */
- _PUNCT, /* `_', 0x5f */
- _PUNCT, /* 0x60 */
- _LOWER | _HEX, /* `a', 0x61 */
- _LOWER | _HEX, /* `b', 0x62 */
- _LOWER | _HEX, /* `c', 0x63 */
- _LOWER | _HEX, /* `d', 0x64 */
- _LOWER | _HEX, /* `e', 0x65 */
- _LOWER | _HEX, /* `f', 0x66 */
- _LOWER, /* `g', 0x67 */
- _LOWER, /* `h', 0x68 */
- _LOWER, /* `i', 0x69 */
- _LOWER, /* `j', 0x6a */
- _LOWER, /* `k', 0x6b */
- _LOWER, /* `l', 0x6c */
- _LOWER, /* `m', 0x6d */
- _LOWER, /* `n', 0x6e */
- _LOWER, /* `o', 0x6f */
- _LOWER, /* `p', 0x70 */
- _LOWER, /* `q', 0x71 */
- _LOWER, /* `r', 0x72 */
- _LOWER, /* `s', 0x73 */
- _LOWER, /* `t', 0x74 */
- _LOWER, /* `u', 0x75 */
- _LOWER, /* `v', 0x76 */
- _LOWER, /* `w', 0x77 */
- _LOWER, /* `x', 0x78 */
- _LOWER, /* `y', 0x79 */
- _LOWER, /* `z', 0x7a */
- _PUNCT, /* `{', 0x7b */
- _PUNCT, /* `|', 0x7c */
- _PUNCT, /* `}', 0x7d */
- _PUNCT, /* `~', 0x7e */
- _CONTROL, /* 0x7f */
- 0, /* 0x80 */
- 0, /* 0x81 */
- 0, /* 0x82 */
- 0, /* 0x83 */
- 0, /* 0x84 */
- 0, /* 0x85 */
- 0, /* 0x86 */
- 0, /* 0x87 */
- 0, /* 0x88 */
- 0, /* 0x89 */
- 0, /* 0x8a */
- 0, /* 0x8b */
- 0, /* 0x8c */
- 0, /* 0x8d */
- 0, /* 0x8e */
- 0, /* 0x8f */
- 0, /* 0x90 */
- 0, /* 0x91 */
- 0, /* 0x92 */
- 0, /* 0x93 */
- 0, /* 0x94 */
- 0, /* 0x95 */
- 0, /* 0x96 */
- 0, /* 0x97 */
- 0, /* 0x98 */
- 0, /* 0x99 */
- 0, /* 0x9a */
- 0, /* 0x9b */
- 0, /* 0x9c */
- 0, /* 0x9d */
- 0, /* 0x9e */
- 0, /* 0x9f */
- 0, /* 0xa0 */
- 0, /* 0xa1 */
- 0, /* 0xa2 */
- 0, /* 0xa3 */
- 0, /* 0xa4 */
- 0, /* 0xa5 */
- 0, /* 0xa6 */
- 0, /* 0xa7 */
- 0, /* 0xa8 */
- 0, /* 0xa9 */
- 0, /* 0xaa */
- 0, /* 0xab */
- 0, /* 0xac */
- 0, /* 0xad */
- 0, /* 0xae */
- 0, /* 0xaf */
- 0, /* 0xb0 */
- 0, /* 0xb1 */
- 0, /* 0xb2 */
- 0, /* 0xb3 */
- 0, /* 0xb4 */
- 0, /* 0xb5 */
- 0, /* 0xb6 */
- 0, /* 0xb7 */
- 0, /* 0xb8 */
- 0, /* 0xb9 */
- 0, /* 0xba */
- 0, /* 0xbb */
- 0, /* 0xbc */
- 0, /* 0xbd */
- 0, /* 0xbe */
- 0, /* 0xbf */
- 0, /* 0xc0 */
- 0, /* 0xc1 */
- 0, /* 0xc2 */
- 0, /* 0xc3 */
- 0, /* 0xc4 */
- 0, /* 0xc5 */
- 0, /* 0xc6 */
- 0, /* 0xc7 */
- 0, /* 0xc8 */
- 0, /* 0xc9 */
- 0, /* 0xca */
- 0, /* 0xcb */
- 0, /* 0xcc */
- 0, /* 0xcd */
- 0, /* 0xce */
- 0, /* 0xcf */
- 0, /* 0xd0 */
- 0, /* 0xd1 */
- 0, /* 0xd2 */
- 0, /* 0xd3 */
- 0, /* 0xd4 */
- 0, /* 0xd5 */
- 0, /* 0xd6 */
- 0, /* 0xd7 */
- 0, /* 0xd8 */
- 0, /* 0xd9 */
- 0, /* 0xda */
- 0, /* 0xdb */
- 0, /* 0xdc */
- 0, /* 0xdd */
- 0, /* 0xde */
- 0, /* 0xdf */
- 0, /* 0xe0 */
- 0, /* 0xe1 */
- 0, /* 0xe2 */
- 0, /* 0xe3 */
- 0, /* 0xe4 */
- 0, /* 0xe5 */
- 0, /* 0xe6 */
- 0, /* 0xe7 */
- 0, /* 0xe8 */
- 0, /* 0xe9 */
- 0, /* 0xea */
- 0, /* 0xeb */
- 0, /* 0xec */
- 0, /* 0xed */
- 0, /* 0xee */
- 0, /* 0xef */
- 0, /* 0xf0 */
- 0, /* 0xf1 */
- 0, /* 0xf2 */
- 0, /* 0xf3 */
- 0, /* 0xf4 */
- 0, /* 0xf5 */
- 0, /* 0xf6 */
- 0, /* 0xf7 */
- 0, /* 0xf8 */
- 0, /* 0xf9 */
- 0, /* 0xfa */
- 0, /* 0xfb */
- 0, /* 0xfc */
- 0, /* 0xfd */
- 0, /* 0xfe */
- 0 /* 0xff */
-};
-
-unsigned short *_pctype = _ctype + 1;
-unsigned short *_pwctype = _ctype + 1;
-
-int _isctype (int c, int ctypeFlags)
-{
- return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
-}
-
-int iswctype(wint_t wc, wctype_t wctypeFlags)
-{
- return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags);
-}
-
-
-int isalpha(int c)
-{
- return(_isctype(c, _ALPHA));
-}
-
-/*
-int isalnum(int c)
-{
- return(_isctype(c, _ALPHA | _DIGIT));
-}
-
-int __isascii(int c)
-{
- return ((unsigned char)c <= 0x7f);
-}
-
-int iscntrl(int c)
-{
- return(_isctype(c, _CONTROL));
-}
-
-int __iscsym(int c)
-{
- return(isalnum(c)||(c == '_'));
-}
-
-int __iscsymf(int c)
-{
- return(isalpha(c)||(c == '_'));
-}
-*/
-
-/*
- * @implemented
- */
-int isdigit(int c)
-{
- return(_isctype(c, _DIGIT));
-}
-
-/*
-int isgraph(int c)
-{
- return (_isctype (c, _PUNCT | _ALPHA | _DIGIT));
-}
-*/
-
-/*
- * @implemented
- */
-int islower(int c)
-{
- return (_isctype (c, _LOWER));
-}
-
-/*
- * @implemented
- */
-int isprint(int c)
-{
- return (_isctype (c, _BLANK | _PUNCT | _ALPHA | _DIGIT));
-}
-
-/*
-int ispunct(int c)
-{
- return (_isctype (c, _PUNCT));
-}
-*/
-
-/*
- * @implemented
- */
-int isspace(int c)
-{
- return (_isctype (c, _SPACE));
-}
-
-/*
- * @implemented
- */
-int isupper(int c)
-{
- return (_isctype (c, _UPPER));
-}
-
-/*
- * @implemented
- */
-int isxdigit(int c)
-{
- return (_isctype (c, _HEX));
-}
-
-/*
-int iswalpha(wint_t c)
-{
- return (iswctype (c, _ALPHA));
-}
-*/
-
-int iswdigit(wint_t c)
-{
- return (iswctype (c, _DIGIT));
-}
-
-int iswlower(wint_t c)
-{
- return (iswctype (c, _LOWER));
-}
-
-int iswxdigit(wint_t c)
-{
- return (iswctype (c, _HEX));
-}
-
-
-/*
-int __toascii(int c)
-{
- return((unsigned)(c) & 0x7f);
-}
-
-int _tolower(int c)
-{
- if (_isctype (c, _UPPER))
- return (c - upalpha);
- return(c);
-}
-
-int _toupper(int c)
-{
- if (_isctype (c, _LOWER))
- return (c + upalpha);
- return(c);
-}
-*/
-
-/*
- * @implemented
- */
-int tolower(int c)
-{
- if (_isctype (c, _UPPER))
- return (c - upalpha);
- return(c);
-}
-
-/*
- * @implemented
- */
-int toupper(int c)
-{
- if (_isctype (c, _LOWER))
- return (c + upalpha);
- return(c);
-}
-
-/*
- * @implemented
- */
-wchar_t towlower(wchar_t c)
-{
- if (iswctype (c, _UPPER))
- return (c - upalpha);
- return(c);
-}
-
-/*
- * @implemented
- */
-wchar_t towupper(wchar_t c)
-{
- if (iswctype (c, _LOWER))
- return (c + upalpha);
- return(c);
-}
-
-/* EOF */
diff --git a/reactos/ntoskrnl/rtl/sprintf.c b/reactos/ntoskrnl/rtl/sprintf.c
deleted file mode 100644
index d2c8c376736..00000000000
--- a/reactos/ntoskrnl/rtl/sprintf.c
+++ /dev/null
@@ -1,590 +0,0 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/rtl/sprintf.c
- * PURPOSE: Single byte sprintf functions
- *
- * PROGRAMMERS: David Welch
- * Eric Kohl
- */
-
-/*
- * linux/lib/vsprintf.c
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
-/*
- * Wirzenius wrote this portably, Torvalds fucked it up :-)
- */
-
-#include
-#include
-#include
-
-
-#define ZEROPAD 1 /* pad with zero */
-#define SIGN 2 /* unsigned/signed long */
-#define PLUS 4 /* show plus */
-#define SPACE 8 /* space if plus */
-#define LEFT 16 /* left justified */
-#define SPECIAL 32 /* 0x */
-#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
-
-
-#if defined(__GNUC__)
-
-#define do_div(n,base) ({ \
-int __res; \
-__res = ((unsigned long long) n) % (unsigned) base; \
-n = ((unsigned long long) n) / (unsigned) base; \
-__res; })
-
-#else /* __GNUC__ */
-/* n /= base, "returns" remainder */
-__inline int int_do_div(__int64* n, int base)
-{
- int __res = (int)(((unsigned __int64)*n) % (unsigned) base);
- *n = (int)(((unsigned __int64)*n) / (unsigned) base);
- return __res;
-}
-#define do_div(n,base) int_do_div(&n, base)
-
-#endif /* __GNUC__ */
-
-
-static int skip_atoi(const char **s)
-{
- int i=0;
-
- while (isdigit(**s))
- i = i*10 + *((*s)++) - '0';
- return i;
-}
-
-
-static char *
-#if defined(__GNUC__)
-number(char *buf, char *end, long long num, int base, int size, int precision, int type)
-#else
-number(char *buf, char *end, __int64 num, int base, int size, int precision, int type)
-#endif
-{
- char c,sign,tmp[66];
- const char *digits;
- const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
- const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- int i;
-
- digits = (type & LARGE) ? large_digits : small_digits;
- if (type & LEFT)
- type &= ~ZEROPAD;
- if (base < 2 || base > 36)
- return 0;
- c = (type & ZEROPAD) ? '0' : ' ';
- sign = 0;
- if (type & SIGN) {
- if (num < 0) {
- sign = '-';
- num = -num;
- size--;
- } else if (type & PLUS) {
- sign = '+';
- size--;
- } else if (type & SPACE) {
- sign = ' ';
- size--;
- }
- }
- if (type & SPECIAL) {
- if (base == 16)
- size -= 2;
- else if (base == 8)
- size--;
- }
- i = 0;
- if (num == 0)
- tmp[i++]='0';
- else while (num != 0)
- tmp[i++] = digits[do_div(num,base)];
- if (i > precision)
- precision = i;
- size -= precision;
- if (!(type&(ZEROPAD+LEFT))) {
- while(size-->0) {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- }
- if (sign) {
- if (buf <= end)
- *buf = sign;
- ++buf;
- }
- if (type & SPECIAL) {
- if (base==8) {
- if (buf <= end)
- *buf = '0';
- ++buf;
- } else if (base==16) {
- if (buf <= end)
- *buf = '0';
- ++buf;
- if (buf <= end)
- *buf = digits[33];
- ++buf;
- }
- }
- if (!(type & LEFT)) {
- while (size-- > 0) {
- if (buf <= end)
- *buf = c;
- ++buf;
- }
- }
- while (i < precision--) {
- if (buf <= end)
- *buf = '0';
- ++buf;
- }
- while (i-- > 0) {
- if (buf <= end)
- *buf = tmp[i];
- ++buf;
- }
- while (size-- > 0) {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- return buf;
-}
-
-static char*
-string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags)
-{
- int i;
- if (s == NULL)
- {
- s = "";
- len = 6;
- }
- else
- {
- if (len == -1)
- {
- len = 0;
- while ((unsigned int)len < (unsigned int)precision && s[len])
- len++;
- }
- else
- {
- if ((unsigned int)len > (unsigned int)precision)
- len = precision;
- }
- }
- if (!(flags & LEFT))
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- for (i = 0; i < len; ++i)
- {
- if (buf <= end)
- *buf = *s++;
- ++buf;
- }
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- return buf;
-}
-
-static char*
-stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
-{
- int i;
- if (sw == NULL)
- {
- sw = L"";
- len = 6;
- }
- else
- {
- if (len == -1)
- {
- len = 0;
- while ((unsigned int)len < (unsigned int)precision && sw[len])
- len++;
- }
- else
- {
- if ((unsigned int)len > (unsigned int)precision)
- len = precision;
- }
- }
- if (!(flags & LEFT))
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- for (i = 0; i < len; ++i)
- {
- if (buf <= end)
- *buf = (unsigned char)(*sw++);
- ++buf;
- }
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = ' ';
- ++buf;
- }
- return buf;
-}
-
-/*
- * @implemented
- */
-int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args)
-{
- int len;
-#if defined(__GNUC__)
- unsigned long long num;
-#else
- unsigned __int64 num;
-#endif
- int base;
- char *str, *end;
- const char *s;
- const wchar_t *sw;
-
- int flags; /* flags to number() */
-
- int field_width; /* width of output field */
- int precision; /* min. # of digits for integers; max
- number of chars for from string */
- int qualifier; /* 'h', 'l', 'L', 'I' or 'w' for integer fields */
-
- str = buf;
- end = buf + cnt - 1;
- if (end < buf - 1) {
- end = ((void *) -1);
- cnt = end - buf + 1;
- }
-
- for ( ; *fmt ; ++fmt) {
- if (*fmt != '%') {
- if (str <= end)
- *str = *fmt;
- ++str;
- continue;
- }
-
- /* process flags */
- flags = 0;
- repeat:
- ++fmt; /* this also skips first '%' */
- switch (*fmt) {
- case '-': flags |= LEFT; goto repeat;
- case '+': flags |= PLUS; goto repeat;
- case ' ': flags |= SPACE; goto repeat;
- case '#': flags |= SPECIAL; goto repeat;
- case '0': flags |= ZEROPAD; goto repeat;
- }
-
- /* get field width */
- field_width = -1;
- if (isdigit(*fmt))
- field_width = skip_atoi(&fmt);
- else if (*fmt == '*') {
- ++fmt;
- /* it's the next argument */
- field_width = va_arg(args, int);
- if (field_width < 0) {
- field_width = -field_width;
- flags |= LEFT;
- }
- }
-
- /* get the precision */
- precision = -1;
- if (*fmt == '.') {
- ++fmt;
- if (isdigit(*fmt))
- precision = skip_atoi(&fmt);
- else if (*fmt == '*') {
- ++fmt;
- /* it's the next argument */
- precision = va_arg(args, int);
- }
- if (precision < 0)
- precision = 0;
- }
-
- /* get the conversion qualifier */
- qualifier = -1;
- if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') {
- qualifier = *fmt;
- ++fmt;
- } else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') {
- qualifier = *fmt;
- fmt += 3;
- }
-
- /* default base */
- base = 10;
-
- switch (*fmt) {
- case 'c': /* finished */
- if (!(flags & LEFT))
- while (--field_width > 0)
- {
- if (str <= end)
- *str = ' ';
- ++str;
- }
- if (qualifier == 'l' || qualifier == 'w')
- {
- if (str <= end)
- *str = (unsigned char)(wchar_t) va_arg(args, int);
- ++str;
- }
- else
- {
- if (str <= end)
- *str = (unsigned char) va_arg(args, int);
- ++str;
- }
- while (--field_width > 0)
- {
- if (str <= end)
- *str = ' ';
- ++str;
- }
- continue;
-
- case 'C': /* finished */
- if (!(flags & LEFT))
- while (--field_width > 0)
- {
- if (str <= end)
- *str = ' ';
- ++str;
- }
- if (qualifier == 'h')
- {
- if (str <= end)
- *str = (unsigned char) va_arg(args, int);
- ++str;
- }
- else
- {
- if (str <= end)
- *str = (unsigned char)(wchar_t) va_arg(args, int);
- ++str;
- }
- while (--field_width > 0)
- {
- if (str <= end)
- *str = ' ';
- ++str;
- }
- continue;
-
- case 's': /* finished */
- if (qualifier == 'l' || qualifier == 'w') {
- /* print unicode string */
- sw = va_arg(args, wchar_t *);
- str = stringw(str, end, sw, -1, field_width, precision, flags);
- } else {
- /* print ascii string */
- s = va_arg(args, char *);
- str = string(str, end, s, -1, field_width, precision, flags);
- }
- continue;
-
- case 'S':
- if (qualifier == 'h') {
- /* print ascii string */
- s = va_arg(args, char *);
- str = string(str, end, s, -1, field_width, precision, flags);
- } else {
- /* print unicode string */
- sw = va_arg(args, wchar_t *);
- str = stringw(str, end, sw, -1, field_width, precision, flags);
- }
- continue;
-
- case 'Z':
- if (qualifier == 'w') {
- /* print counted unicode string */
- PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
- if ((pus == NULL) || (pus->Buffer == NULL)) {
- sw = NULL;
- len = -1;
- } else {
- sw = pus->Buffer;
- len = pus->Length / sizeof(WCHAR);
- }
- str = stringw(str, end, sw, len, field_width, precision, flags);
- } else {
- /* print counted ascii string */
- PANSI_STRING pus = va_arg(args, PANSI_STRING);
- if ((pus == NULL) || (pus->Buffer == NULL)) {
- s = NULL;
- len = -1;
- } else {
- s = pus->Buffer;
- len = pus->Length;
- }
- str = string(str, end, s, len, field_width, precision, flags);
- }
- continue;
-
- case 'p':
- if (field_width == -1) {
- field_width = 2 * sizeof(void *);
- flags |= ZEROPAD;
- }
- str = number(str, end,
- (unsigned long) va_arg(args, void *),
- 16, field_width, precision, flags);
- continue;
-
- case 'n':
- /* FIXME: What does C99 say about the overflow case here? */
- if (qualifier == 'l') {
- long * ip = va_arg(args, long *);
- *ip = (str - buf);
- } else {
- int * ip = va_arg(args, int *);
- *ip = (str - buf);
- }
- continue;
-
- /* integer number formats - set up the flags and "break" */
- case 'o':
- base = 8;
- break;
-
- case 'b':
- base = 2;
- break;
-
- case 'X':
- flags |= LARGE;
- case 'x':
- base = 16;
- break;
-
- case 'd':
- case 'i':
- flags |= SIGN;
- case 'u':
- break;
-
- default:
- if (*fmt != '%')
- {
- if (str <= end)
- *str = '%';
- ++str;
- }
- if (*fmt)
- {
- if (str <= end)
- *str = *fmt;
- ++str;
- }
- else
- --fmt;
- continue;
- }
-
- if (qualifier == 'I')
-#if defined(__GNUC__)
- num = va_arg(args, unsigned long long);
-#else
- num = va_arg(args, unsigned __int64);
-#endif
- else if (qualifier == 'l') {
- if (flags & SIGN)
- num = va_arg(args, long);
- else
- num = va_arg(args, unsigned long);
- }
- else if (qualifier == 'h') {
- if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- }
- else {
- if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- }
- str = number(str, end, num, base, field_width, precision, flags);
- }
-
- if (str <= end)
- *str = '\0';
- else if (cnt > 0)
- /* don't write out a null byte if the buf size is zero */
- *end = '\0';
-
- return str-buf;
-}
-
-
-/*
- * @implemented
- */
-int sprintf(char * buf, const char *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=_vsnprintf(buf,MAXLONG,fmt,args);
- va_end(args);
- return i;
-}
-
-
-/*
- * @implemented
- */
-int _snprintf(char * buf, size_t cnt, const char *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=_vsnprintf(buf,cnt,fmt,args);
- va_end(args);
- return i;
-}
-
-
-/*
- * @implemented
- */
-int vsprintf(char *buf, const char *fmt, va_list args)
-{
- return _vsnprintf(buf,MAXLONG,fmt,args);
-}
-
-/* EOF */
diff --git a/reactos/ntoskrnl/rtl/stdlib.c b/reactos/ntoskrnl/rtl/stdlib.c
deleted file mode 100644
index 92b0da7df12..00000000000
--- a/reactos/ntoskrnl/rtl/stdlib.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/rtl/stdlib.c
- * PURPOSE: Standard library functions
- *
- * PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include
-#include
-
-/* GLOBALS ****************************************************************/
-
-#if defined(__GNUC__)
-static unsigned long long next = 0;
-#else
-static unsigned __int64 next = 0;
-#endif
-
-/* FUNCTIONS ****************************************************************/
-
-int atoi(const char *str)
-{
- return (int)atol (str);
-}
-
-
-/*
- * NOTE: no error
- *
- * @implemented
- */
-long atol(const char *str)
-{
- const char *s = str;
- unsigned long acc;
- int c;
- unsigned long cutoff;
- int neg = 0, any, cutlim;
-
- /*
- * Skip white space and pick up leading +/- sign if any.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-')
- {
- neg = 1;
- c = *s++;
- }
- else if (c == '+')
- c = *s++;
-
- /*
- * Compute the cutoff value between legal numbers and illegal
- * numbers. That is the largest legal value, divided by the
- * base. An input number that is greater than this value, if
- * followed by a legal input character, is too big. One that
- * is equal to this value may be valid or not; the limit
- * between valid and invalid numbers is then based on the last
- * digit. For instance, if the range for longs is
- * [-2147483648..2147483647] and the input base is 10,
- * cutoff will be set to 214748364 and cutlim to either
- * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
- * a value > 214748364, or equal but the next digit is > 7 (or 8),
- * the number is too big, and we will return a range error.
- *
- * Set any if any `digits' consumed; make it negative to indicate
- * overflow.
- */
- cutoff = neg ? -(unsigned long)MINLONG : MAXLONG;
- cutlim = cutoff % (unsigned long)10;
- cutoff /= (unsigned long)10;
- for (acc = 0, any = 0;; c = *s++)
- {
- if (isdigit(c))
- c -= '0';
- else
- break;
- if (c >= 10)
- break;
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
- any = -1;
- else
- {
- any = 1;
- acc *= 10;
- acc += c;
- }
- }
- if (any < 0)
- {
- acc = neg ? MINLONG : MAXLONG;
- }
- else if (neg)
- acc = -acc;
-
- return acc;
-}
-
-
-/*
- * NOTE: no radix range check (valid range: 2 - 36)
- *
- * @implemented
- */
-
-char *_itoa (int value, char *string, int radix)
-{
- char tmp[33];
- char *tp = tmp;
- int i;
- unsigned v;
- int sign;
- char *sp = NULL;
-
- if (string == NULL)
- return NULL;
-
- 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 + '0';
- else
- *tp++ = i + 'a' - 10;
- }
-
- if (sign)
- *sp++ = '-';
-
- while (tp > tmp)
- *sp++ = *--tp;
- *sp = 0;
-
- return string;
-}
-
-/*
- * NOTE: no radix range check (valid range: 2 - 36)
- *
- * @implemented
- */
-
-wchar_t *_itow (int value, wchar_t *string, int radix)
-{
- wchar_t tmp[33];
- wchar_t *tp = tmp;
- int i;
- unsigned v;
- int sign;
- wchar_t *sp = NULL;
-
- if (string == NULL)
- return NULL;
-
- 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 (sign)
- *sp++ = L'-';
-
- while (tp > tmp)
- *sp++ = *--tp;
- *sp = 0;
-
- return string;
-}
-
-
-/*
- * @implemented
- */
-int rand(void)
-{
-#if defined(__GNUC__)
- next = next * 0x5deece66dLL + 11;
-#else
- next = next * 0x5deece66di64 + 11;
-#endif
- return (int)((next >> 16) & RAND_MAX);
-}
-
-
-/*
- * @implemented
- */
-void srand(unsigned seed)
-{
- next = seed;
-}
-
-
-/*
- * @implemented
- */
-int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
-{
- NTSTATUS Status;
- ULONG Size;
-
- if (wchar == NULL)
- return 0;
-
- Status = RtlMultiByteToUnicodeN (wchar,
- sizeof(WCHAR),
- &Size,
- (char *)mbchar,
- count);
- if (!NT_SUCCESS(Status))
- return -1;
-
- return (int)Size;
-}
-
-
-/*
- * @implemented
- */
-size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
-{
- NTSTATUS Status;
- ULONG Size;
- ULONG Length;
-
- Length = strlen (mbstr);
-
- if (wcstr == NULL)
- {
- RtlMultiByteToUnicodeSize (&Size,
- (char *)mbstr,
- Length);
-
- return (size_t)Size;
- }
-
- Status = RtlMultiByteToUnicodeN (wcstr,
- count,
- &Size,
- (char *)mbstr,
- Length);
- if (!NT_SUCCESS(Status))
- return -1;
-
- return (size_t)Size;
-}
-
-
-/*
- * @implemented
- */
-int wctomb (char *mbchar, wchar_t wchar)
-{
- NTSTATUS Status;
- ULONG Size;
-
- if (mbchar == NULL)
- return 0;
-
- Status = RtlUnicodeToMultiByteN (mbchar,
- 1,
- &Size,
- &wchar,
- sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- return -1;
-
- return (int)Size;
-}
-
-
-/*
- * @implemented
- */
-size_t wcstombs (char *mbstr, const wchar_t *wcstr, size_t count)
-{
- NTSTATUS Status;
- ULONG Size;
- ULONG Length;
-
- Length = wcslen (wcstr);
-
- if (mbstr == NULL)
- {
- RtlUnicodeToMultiByteSize (&Size,
- (wchar_t *)wcstr,
- Length * sizeof(WCHAR));
-
- return (size_t)Size;
- }
-
- Status = RtlUnicodeToMultiByteN (mbstr,
- count,
- &Size,
- (wchar_t *)wcstr,
- Length * sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- return -1;
-
- return (size_t)Size;
-}
-
-/* EOF */
diff --git a/reactos/ntoskrnl/rtl/swprintf.c b/reactos/ntoskrnl/rtl/swprintf.c
deleted file mode 100644
index 7d231446992..00000000000
--- a/reactos/ntoskrnl/rtl/swprintf.c
+++ /dev/null
@@ -1,575 +0,0 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/rtl/swprintf.c
- * PURPOSE: Unicode sprintf functions
- *
- * PROGRAMMERS: David Welch
- * Eric Kohl
- */
-
-/*
- * TODO:
- * - Verify the implementation of '%Z'.
- */
-
-/*
- * linux/lib/vsprintf.c
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
-/*
- * Wirzenius wrote this portably, Torvalds fucked it up :-)
- */
-
-#include
-#include
-#define NDEBUG
-#include
-
-
-#if defined(__GNUC__)
-typedef long long SWPRINT_INT64;
-typedef unsigned long long SWPRINT_UINT64;
-#else
-typedef __int64 SWPRINT_INT64;
-typedef unsigned __int64 SWPRINT_UINT64;
-#endif
-
-
-#define ZEROPAD 1 /* pad with zero */
-#define SIGN 2 /* unsigned/signed long */
-#define PLUS 4 /* show plus */
-#define SPACE 8 /* space if plus */
-#define LEFT 16 /* left justified */
-#define SPECIAL 32 /* 0x */
-#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
-
-
-#if defined(__GNUC__)
-
-#define do_div(n,base) ({ \
-int __res; \
-__res = ((SWPRINT_UINT64) n) % (unsigned) base; \
-n = ((SWPRINT_UINT64) n) / (unsigned) base; \
-__res; })
-
-#elif defined(_MSC_VER)
-
-static __inline int do_foo_div(SWPRINT_INT64* n, int base)
-{
- int __res = (int)(((SWPRINT_UINT64) *n) % (unsigned) base);
- *n = (int)(((SWPRINT_UINT64) *n) / (unsigned) base);
- return __res;
-}
-#define do_div(n,base) do_foo_div(&n,base)
-
-#else
-#error Unknown compiler for this special compiler trickery
-#endif
-
-
-
-static int skip_atoi(const wchar_t **s)
-{
- int i=0;
-
- while (iswdigit(**s))
- i = i*10 + *((*s)++) - L'0';
- return i;
-}
-
-
-static wchar_t *
-number(wchar_t * buf, wchar_t * end, SWPRINT_INT64 num, int base, int size, int precision, int type)
-{
- wchar_t c,sign, tmp[66];
- const wchar_t *digits;
- const wchar_t *small_digits = L"0123456789abcdefghijklmnopqrstuvwxyz";
- const wchar_t *large_digits = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- int i;
-
- digits = (type & LARGE) ? large_digits : small_digits;
- if (type & LEFT)
- type &= ~ZEROPAD;
- if (base < 2 || base > 36)
- return 0;
- c = (type & ZEROPAD) ? L'0' : L' ';
- sign = 0;
- if (type & SIGN) {
- if (num < 0) {
- sign = L'-';
- num = -num;
- size--;
- } else if (type & PLUS) {
- sign = L'+';
- size--;
- } else if (type & SPACE) {
- sign = ' ';
- size--;
- }
- }
- if (type & SPECIAL) {
- if (base == 16)
- size -= 2;
- else if (base == 8)
- size--;
- }
- i = 0;
- if (num == 0)
- tmp[i++] = L'0';
- else while (num != 0)
- tmp[i++] = digits[do_div(num,base)];
- if (i > precision)
- precision = i;
- size -= precision;
- if (!(type&(ZEROPAD+LEFT))) {
- while(size-->0) {
- if (buf <= end)
- *buf = L' ';
- ++buf;
- }
- }
- if (sign) {
- if (buf <= end)
- *buf = sign;
- ++buf;
- }
- if (type & SPECIAL) {
- if (base==8) {
- if (buf <= end)
- *buf = L'0';
- ++buf;
- } else if (base==16) {
- if (buf <= end)
- *buf = L'0';
- ++buf;
- if (buf <= end)
- *buf = digits[33];
- ++buf;
- }
- }
- if (!(type & LEFT)) {
- while (size-- > 0) {
- if (buf <= end)
- *buf = c;
- ++buf;
- }
- }
- while (i < precision--) {
- if (buf <= end)
- *buf = L'0';
- ++buf;
- }
- while (i-- > 0) {
- if (buf <= end)
- *buf = tmp[i];
- ++buf;
- }
- while (size-- > 0) {
- if (buf <= end)
- *buf = L' ';
- ++buf;
- }
- return buf;
-}
-
-static wchar_t*
-string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int precision, int flags)
-{
- int i;
- if (s == NULL)
- {
- s = "";
- len = 6;
- }
- else
- {
- if (len == -1)
- {
- len = 0;
- while ((unsigned int)len < (unsigned int)precision && s[len])
- len++;
- }
- else
- {
- if ((unsigned int)len > (unsigned int)precision)
- len = precision;
- }
- }
- if (!(flags & LEFT))
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = L' ';
- ++buf;
- }
- for (i = 0; i < len; ++i)
- {
- if (buf <= end)
- *buf = *s++;
- ++buf;
- }
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = L' ';
- ++buf;
- }
- return buf;
-}
-
-static wchar_t*
-stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
-{
- int i;
- if (sw == NULL)
- {
- sw = L"";
- len = 6;
- }
- else
- {
- if (len == -1)
- {
- len = 0;
- while ((unsigned int)len < (unsigned int)precision && sw[len])
- len++;
- }
- else
- {
- if ((unsigned int)len > (unsigned int)precision)
- len = precision;
- }
- }
- if (!(flags & LEFT))
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = L' ';
- buf++;
- }
- for (i = 0; i < len; ++i)
- {
- if (buf <= end)
- *buf = *sw++;
- buf++;
- }
- while (len < field_width--)
- {
- if (buf <= end)
- *buf = L' ';
- buf++;
- }
- return buf;
-}
-
-int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args)
-{
- int len;
- SWPRINT_UINT64 num;
- int base;
- wchar_t * str, * end;
- const char *s;
- const wchar_t *sw;
-
- int flags; /* flags to number() */
-
- int field_width; /* width of output field */
- int precision; /* min. # of digits for integers; max
- number of chars for from string */
- int qualifier; /* 'h', 'l', 'L', 'w' or 'I' for integer fields */
-
- str = buf;
- end = buf + cnt - 1;
- if (end < buf - 1) {
- end = ((void *) -1);
- cnt = end - buf + 1;
- }
-
- for ( ; *fmt ; ++fmt) {
- if (*fmt != L'%') {
- if (str <= end)
- *str = *fmt;
- ++str;
- continue;
- }
-
- /* process flags */
- flags = 0;
- repeat:
- ++fmt; /* this also skips first '%' */
- switch (*fmt) {
- case L'-': flags |= LEFT; goto repeat;
- case L'+': flags |= PLUS; goto repeat;
- case L' ': flags |= SPACE; goto repeat;
- case L'#': flags |= SPECIAL; goto repeat;
- case L'0': flags |= ZEROPAD; goto repeat;
- }
-
- /* get field width */
- field_width = -1;
- if (iswdigit(*fmt))
- field_width = skip_atoi(&fmt);
- else if (*fmt == L'*') {
- ++fmt;
- /* it's the next argument */
- field_width = va_arg(args, int);
- if (field_width < 0) {
- field_width = -field_width;
- flags |= LEFT;
- }
- }
-
- /* get the precision */
- precision = -1;
- if (*fmt == L'.') {
- ++fmt;
- if (iswdigit(*fmt))
- precision = skip_atoi(&fmt);
- else if (*fmt == L'*') {
- ++fmt;
- /* it's the next argument */
- precision = va_arg(args, int);
- }
- if (precision < 0)
- precision = 0;
- }
-
- /* get the conversion qualifier */
- qualifier = -1;
- if (*fmt == L'h' || *fmt == L'l' || *fmt == L'L' || *fmt == L'w') {
- qualifier = *fmt;
- ++fmt;
- } else if (*fmt == L'I' && *(fmt+1) == L'6' && *(fmt+2) == L'4') {
- qualifier = *fmt;
- fmt += 3;
- }
-
- /* default base */
- base = 10;
-
- switch (*fmt) {
- case L'c':
- if (!(flags & LEFT))
- while (--field_width > 0) {
- if (str <= end)
- *str = L' ';
- ++str;
- }
- if (qualifier == 'h') {
- if (str <= end)
- *str = (wchar_t) va_arg(args, int);
- ++str;
- } else {
- if (str <= end)
- *str = (wchar_t) va_arg(args, int);
- ++str;
- }
- while (--field_width > 0) {
- if (str <= end)
- *str = L' ';
- ++str;
- }
- continue;
-
- case L'C':
- if (!(flags & LEFT))
- while (--field_width > 0) {
- if (str <= end)
- *str = L' ';
- ++str;
- }
- if (qualifier == 'l' || qualifier == 'w') {
- if (str <= end)
- *str = (wchar_t) va_arg(args, int);
- ++str;
- } else {
- if (str <= end)
- *str = (wchar_t) va_arg(args, int);
- ++str;
- }
- while (--field_width > 0) {
- if (str <= end)
- *str = L' ';
- ++str;
- }
- continue;
-
- case L's':
- if (qualifier == 'h') {
- /* print ascii string */
- s = va_arg(args, char *);
- str = string(str, end, s, -1, field_width, precision, flags);
- } else {
- /* print unicode string */
- sw = va_arg(args, wchar_t *);
- str = stringw(str, end, sw, -1, field_width, precision, flags);
- }
- continue;
-
- case L'S':
- if (qualifier == 'l' || qualifier == 'w') {
- /* print unicode string */
- sw = va_arg(args, wchar_t *);
- str = stringw(str, end, sw, -1, field_width, precision, flags);
- } else {
- /* print ascii string */
- s = va_arg(args, char *);
- str = string(str, end, s, -1, field_width, precision, flags);
- }
- continue;
-
- case L'Z':
- if (qualifier == 'h') {
- /* print counted ascii string */
- PANSI_STRING pus = va_arg(args, PANSI_STRING);
- if ((pus == NULL) || (pus->Buffer == NULL)) {
- s = NULL;
- len = -1;
- } else {
- s = pus->Buffer;
- len = pus->Length;
- }
- str = string(str, end, s, len, field_width, precision, flags);
- } else {
- /* print counted unicode string */
- PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
- if ((pus == NULL) || (pus->Buffer == NULL)) {
- sw = NULL;
- len = -1;
- } else {
- sw = pus->Buffer;
- len = pus->Length / sizeof(WCHAR);
- }
- str = stringw(str, end, sw, len, field_width, precision, flags);
- }
- continue;
-
- case L'p':
- if (field_width == -1) {
- field_width = 2*sizeof(void *);
- flags |= ZEROPAD;
- }
- str = number(str, end,
- (unsigned long) va_arg(args, void *), 16,
- field_width, precision, flags);
- continue;
-
- case L'n':
- /* FIXME: What does C99 say about the overflow case here? */
- if (qualifier == 'l') {
- long * ip = va_arg(args, long *);
- *ip = (str - buf);
- } else {
- int * ip = va_arg(args, int *);
- *ip = (str - buf);
- }
- continue;
-
- /* integer number formats - set up the flags and "break" */
- case L'o':
- base = 8;
- break;
-
- case L'b':
- base = 2;
- break;
-
- case L'X':
- flags |= LARGE;
- case L'x':
- base = 16;
- break;
-
- case L'd':
- case L'i':
- flags |= SIGN;
- case L'u':
- break;
-
- default:
- if (*fmt != L'%') {
- if (str <= end)
- *str = L'%';
- ++str;
- }
- if (*fmt) {
- if (str <= end)
- *str = *fmt;
- ++str;
- } else
- --fmt;
- continue;
- }
-
- if (qualifier == L'I')
- num = va_arg(args, SWPRINT_UINT64);
- else if (qualifier == L'l') {
- if (flags & SIGN)
- num = va_arg(args, long);
- else
- num = va_arg(args, unsigned long);
- }
- else if (qualifier == L'h') {
- if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- }
- else {
- if (flags & SIGN)
- num = va_arg(args, int);
- else
- num = va_arg(args, unsigned int);
- }
- str = number(str, end, num, base, field_width, precision, flags);
- }
- if (str <= end)
- *str = L'\0';
- else if (cnt > 0)
- /* don't write out a null byte if the buf size is zero */
- *end = L'\0';
- return str-buf;
-}
-
-
-/*
- * @implemented
- */
-int swprintf(wchar_t *buf, const wchar_t *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=_vsnwprintf(buf,MAXLONG,fmt,args);
- va_end(args);
- return i;
-}
-
-
-/*
- * @implemented
- */
-int _snwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- i=_vsnwprintf(buf,cnt,fmt,args);
- va_end(args);
- return i;
-}
-
-
-int vswprintf(wchar_t *buf, const wchar_t *fmt, va_list args)
-{
- return _vsnwprintf(buf,MAXLONG,fmt,args);
-}
-
-/* EOF */