mirror of
https://github.com/reactos/reactos.git
synced 2024-08-02 09:30:55 +00:00
- Move s(w)printf to rtl (cannot be shared in string because of differences with the CRT implementation). - Fix build errors due to previous commits (sorry).
svn path=/trunk/; revision=17735
This commit is contained in:
parent
48fe1fb84b
commit
659c21724b
|
@ -2013,4 +2013,29 @@ NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
|
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
|
#endif
|
||||||
|
|
|
@ -4350,29 +4350,4 @@ ZwYieldExecution(
|
||||||
VOID
|
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
|
#endif
|
||||||
|
|
|
@ -22,17 +22,6 @@
|
||||||
<file>putch.c</file>
|
<file>putch.c</file>
|
||||||
<file>ungetch.c</file>
|
<file>ungetch.c</file>
|
||||||
</directory>
|
</directory>
|
||||||
<directory name="ctype">
|
|
||||||
<file>ctype.c</file>
|
|
||||||
<file>isalnum.c</file>
|
|
||||||
<file>isascii.c</file>
|
|
||||||
<file>iscntrl.c</file>
|
|
||||||
<file>isgraph.c</file>
|
|
||||||
<file>isprint.c</file>
|
|
||||||
<file>ispunct.c</file>
|
|
||||||
<file>isupper.c</file>
|
|
||||||
<file>isctype.c</file>
|
|
||||||
</directory>
|
|
||||||
<directory name="direct">
|
<directory name="direct">
|
||||||
<file>chdir.c</file>
|
<file>chdir.c</file>
|
||||||
<file>chdrive.c</file>
|
<file>chdrive.c</file>
|
||||||
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
unsigned short _ctype[] = {
|
|
||||||
0, /* <EOF>, 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 */
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
#undef isalpha
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int isalpha(int c)
|
|
||||||
{
|
|
||||||
return _isctype(c, _ALPHA);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef iswalpha
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswalpha(wint_t c)
|
|
||||||
{
|
|
||||||
return iswctype(c, _ALPHA);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int __isascii(int c)
|
|
||||||
{
|
|
||||||
return (!((c)&(~0x7f)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswascii(wint_t c)
|
|
||||||
{
|
|
||||||
return __isascii(c);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
#undef iscntrl
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iscntrl(int c)
|
|
||||||
{
|
|
||||||
return _isctype(c, _CONTROL);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef iswcntrl
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswcntrl(wint_t c)
|
|
||||||
{
|
|
||||||
return iswctype(c, _CONTROL);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int __iscsymf(int c)
|
|
||||||
{
|
|
||||||
return (isalpha(c) || ( c == '_' )) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int __iscsym(int c)
|
|
||||||
{
|
|
||||||
return (isalnum(c) || ( c == '_' )) ;
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
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 */
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
#undef isdigit
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int isdigit(int c)
|
|
||||||
{
|
|
||||||
return _isctype(c, _DIGIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef iswdigit
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswdigit(wint_t c)
|
|
||||||
{
|
|
||||||
return iswctype(c, _DIGIT);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
#undef islower
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int islower(int c)
|
|
||||||
{
|
|
||||||
return _isctype(c, _LOWER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswlower(wint_t c)
|
|
||||||
{
|
|
||||||
return iswctype(c, _LOWER);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
#undef ispunct
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int ispunct(int c)
|
|
||||||
{
|
|
||||||
return _isctype(c, _PUNCT);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef iswpunct
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswpunct(wint_t c)
|
|
||||||
{
|
|
||||||
return iswctype(c, _PUNCT);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
#undef isspace
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int isspace(int c)
|
|
||||||
{
|
|
||||||
return _isctype(c,_SPACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef iswspace
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswspace(wint_t c)
|
|
||||||
{
|
|
||||||
return iswctype(c,_SPACE);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
#undef isupper
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int isupper(int c)
|
|
||||||
{
|
|
||||||
return _isctype(c, _UPPER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswupper(wint_t c)
|
|
||||||
{
|
|
||||||
return iswctype(c, _UPPER);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
#undef isxdigit
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int isxdigit(int c)
|
|
||||||
{
|
|
||||||
return _isctype(c, _HEX);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef iswxdigit
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int iswxdigit(wint_t c)
|
|
||||||
{
|
|
||||||
return iswctype(c, _HEX);
|
|
||||||
}
|
|
||||||
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
int __toascii(int c)
|
|
||||||
{
|
|
||||||
return((unsigned)(c) & 0x7F);
|
|
||||||
}
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
#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'));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
|
@ -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 <ctype.h>
|
|
||||||
|
|
||||||
#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'));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
@ -37,11 +37,6 @@
|
||||||
<file>libsupp.c</file>
|
<file>libsupp.c</file>
|
||||||
<file>version.c</file>
|
<file>version.c</file>
|
||||||
</directory>
|
</directory>
|
||||||
<directory name="stdio">
|
|
||||||
<file>sprintf.c</file>
|
|
||||||
<file>sscanf.c</file>
|
|
||||||
<file>swprintf.c</file>
|
|
||||||
</directory>
|
|
||||||
<directory name="def">
|
<directory name="def">
|
||||||
<file>ntdll.rc</file>
|
<file>ntdll.rc</file>
|
||||||
</directory>
|
</directory>
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
<file>sd.c</file>
|
<file>sd.c</file>
|
||||||
<file>security.c</file>
|
<file>security.c</file>
|
||||||
<file>sid.c</file>
|
<file>sid.c</file>
|
||||||
|
<file>sprintf.c</file>
|
||||||
|
<file>swprintf.c</file>
|
||||||
<file>splaytree.c</file>
|
<file>splaytree.c</file>
|
||||||
<file>thread.c</file>
|
<file>thread.c</file>
|
||||||
<file>time.c</file>
|
<file>time.c</file>
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -269,6 +269,22 @@ unsigned short _ctype[] = {
|
||||||
unsigned short *_pctype = _ctype + 1;
|
unsigned short *_pctype = _ctype + 1;
|
||||||
unsigned short *_pwctype = _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)
|
int _isctype (int c, int ctypeFlags)
|
||||||
{
|
{
|
||||||
return (_pctype[(unsigned char)(c & 0xFF)] & 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);
|
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
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -298,6 +324,14 @@ int isalnum(int c)
|
||||||
return(_isctype(c, _ALPHA | _DIGIT));
|
return(_isctype(c, _ALPHA | _DIGIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
int iswalnum(wint_t c)
|
||||||
|
{
|
||||||
|
return iswctype(c, _ALPHA | _DIGIT);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -306,6 +340,14 @@ int __isascii(int c)
|
||||||
return ((unsigned char)c <= 0x7f);
|
return ((unsigned char)c <= 0x7f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
int iswascii(wint_t c)
|
||||||
|
{
|
||||||
|
return __isascii(c);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -403,6 +445,14 @@ int iswalpha(wint_t c)
|
||||||
return (iswctype (c, _ALPHA));
|
return (iswctype (c, _ALPHA));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
int iswcntrl(wint_t c)
|
||||||
|
{
|
||||||
|
return iswctype(c, _CONTROL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -411,6 +461,31 @@ int iswdigit(wint_t c)
|
||||||
return (iswctype (c, _DIGIT));
|
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
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -419,6 +494,15 @@ int iswlower(wint_t c)
|
||||||
return (iswctype (c, _LOWER));
|
return (iswctype (c, _LOWER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
int iswupper(wint_t c)
|
||||||
|
{
|
||||||
|
return iswctype(c, _UPPER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -83,17 +83,6 @@ _FUNCTION_ {
|
||||||
int rd = 0, consumed = 0;
|
int rd = 0, consumed = 0;
|
||||||
int nch;
|
int nch;
|
||||||
if (!*format) return 0;
|
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);
|
nch = _GETC_(file);
|
||||||
if (nch == _EOF_) return _EOF_RET;
|
if (nch == _EOF_) return _EOF_RET;
|
||||||
|
|
||||||
|
@ -232,7 +221,6 @@ _FUNCTION_ {
|
||||||
else _SET_NUMBER_(int);
|
else _SET_NUMBER_(int);
|
||||||
} else {
|
} else {
|
||||||
if (negative) {
|
if (negative) {
|
||||||
WARN("Dropping sign in reading a negative number into an unsigned value");
|
|
||||||
negative = 0;
|
negative = 0;
|
||||||
}
|
}
|
||||||
if (I64_prefix) _SET_NUMBER_(ULONGLONG);
|
if (I64_prefix) _SET_NUMBER_(ULONGLONG);
|
||||||
|
@ -542,7 +530,6 @@ _FUNCTION_ {
|
||||||
if (nch!=_EOF_) {
|
if (nch!=_EOF_) {
|
||||||
_UNGETC_(nch, file);
|
_UNGETC_(nch, file);
|
||||||
}
|
}
|
||||||
TRACE("returning %d\n", rd);
|
|
||||||
return rd;
|
return rd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
#include <ntdll.h>
|
#include <windows.h>
|
||||||
#define NDEBUG
|
#define NTOS_MODE_USER
|
||||||
#include <debug.h>
|
#define _NTSYSTEM_
|
||||||
|
#include <ndk/umtypes.h>
|
||||||
|
#include <ndk/rtlfuncs.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* helper function for *scanf. Returns the value of character c in the
|
/* 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define debugstr_a(a) (a)
|
|
||||||
#define TRACE DPRINT
|
|
||||||
#define WARN DPRINT1
|
|
||||||
|
|
||||||
/* vsscanf */
|
/* vsscanf */
|
||||||
#undef WIDE_SCANF
|
#undef WIDE_SCANF
|
||||||
#undef CONSOLE
|
#undef CONSOLE
|
|
@ -96,4 +96,5 @@
|
||||||
<file>wtoi.c</file>
|
<file>wtoi.c</file>
|
||||||
<file>wtol.c</file>
|
<file>wtol.c</file>
|
||||||
<file>rand.c</file>
|
<file>rand.c</file>
|
||||||
|
<file>sscanf.c</file>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -320,9 +320,7 @@
|
||||||
<file>nls.c</file>
|
<file>nls.c</file>
|
||||||
<file>purecall.c</file>
|
<file>purecall.c</file>
|
||||||
<file>regio.c</file>
|
<file>regio.c</file>
|
||||||
<file>sprintf.c</file>
|
|
||||||
<file>strtok.c</file>
|
<file>strtok.c</file>
|
||||||
<file>swprintf.c</file>
|
|
||||||
</directory>
|
</directory>
|
||||||
<directory name="se">
|
<directory name="se">
|
||||||
<file>access.c</file>
|
<file>access.c</file>
|
||||||
|
|
|
@ -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 <internal/ctype.h>
|
|
||||||
|
|
||||||
#undef _pctype
|
|
||||||
|
|
||||||
#define upalpha ('A' - 'a')
|
|
||||||
|
|
||||||
|
|
||||||
unsigned short _ctype[] = {
|
|
||||||
0, /* <EOF>, 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 */
|
|
|
@ -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 <ntoskrnl.h>
|
|
||||||
#include <internal/ctype.h>
|
|
||||||
#include <internal/debug.h>
|
|
||||||
|
|
||||||
|
|
||||||
#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 = "<NULL>";
|
|
||||||
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"<NULL>";
|
|
||||||
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 */
|
|
|
@ -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 <ntoskrnl.h>
|
|
||||||
#include <internal/ctype.h>
|
|
||||||
|
|
||||||
/* 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 */
|
|
|
@ -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 <ntoskrnl.h>
|
|
||||||
#include <internal/ctype.h>
|
|
||||||
#define NDEBUG
|
|
||||||
#include <internal/debug.h>
|
|
||||||
|
|
||||||
|
|
||||||
#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 = "<NULL>";
|
|
||||||
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"<NULL>";
|
|
||||||
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 */
|
|
Loading…
Reference in a new issue