mirror of
https://github.com/reactos/reactos.git
synced 2025-06-26 02:39:42 +00:00
Create a branch for cmake bringup.
svn path=/branches/cmake-bringup/; revision=48236
This commit is contained in:
parent
a28e798006
commit
c424146e2c
20602 changed files with 0 additions and 1140137 deletions
11
lib/sdk/crt/string/atof.c
Normal file
11
lib/sdk/crt/string/atof.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
double
|
||||
atof(const char *ascii)
|
||||
{
|
||||
return strtod(ascii, 0);
|
||||
}
|
12
lib/sdk/crt/string/atoi.c
Normal file
12
lib/sdk/crt/string/atoi.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <precomp.h>
|
||||
#include <tchar.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int
|
||||
_ttoi(const _TCHAR *str)
|
||||
{
|
||||
return (int)_ttoi64(str);
|
||||
}
|
45
lib/sdk/crt/string/atoi64.c
Normal file
45
lib/sdk/crt/string/atoi64.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
__int64
|
||||
_atoi64(const char *nptr)
|
||||
{
|
||||
char *s = (char *)nptr;
|
||||
__int64 acc = 0;
|
||||
int neg = 0;
|
||||
|
||||
if (nptr == NULL)
|
||||
return 0;
|
||||
|
||||
while(isspace((int)*s))
|
||||
s++;
|
||||
if (*s == '-')
|
||||
{
|
||||
neg = 1;
|
||||
s++;
|
||||
}
|
||||
else if (*s == '+')
|
||||
s++;
|
||||
|
||||
while (isdigit((int)*s))
|
||||
{
|
||||
acc = 10 * acc + ((int)*s - '0');
|
||||
s++;
|
||||
}
|
||||
|
||||
if (neg)
|
||||
acc *= -1;
|
||||
return acc;
|
||||
}
|
19
lib/sdk/crt/string/atol.c
Normal file
19
lib/sdk/crt/string/atol.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
long
|
||||
_ttol(const _TCHAR *str)
|
||||
{
|
||||
return (long)_ttoi64(str);
|
||||
}
|
||||
|
||||
int _atoldbl(_LDOUBLE *value, char *str)
|
||||
{
|
||||
/* FIXME needs error checking for huge/small values */
|
||||
//*value = strtold(str,0);
|
||||
return -1;
|
||||
}
|
883
lib/sdk/crt/string/ctype.c
Normal file
883
lib/sdk/crt/string/ctype.c
Normal file
|
@ -0,0 +1,883 @@
|
|||
#include <string.h>
|
||||
#undef __MINGW_IMPORT
|
||||
#define __MINGW_IMPORT
|
||||
#include <ctype.h>
|
||||
|
||||
#undef _pctype
|
||||
#undef _pwctype
|
||||
|
||||
/* MS's CRT header defines all that, and we actually implement that */
|
||||
#undef iswalnum
|
||||
#undef __isascii
|
||||
#undef iswascii
|
||||
#undef __iscsym
|
||||
#undef __iscsymf
|
||||
#undef iswalpha
|
||||
#undef iswcntrl
|
||||
#undef iswdigit
|
||||
#undef iswgraph
|
||||
#undef iswprint
|
||||
#undef iswpunct
|
||||
#undef iswlower
|
||||
#undef iswupper
|
||||
#undef iswspace
|
||||
#undef iswxdigit
|
||||
#undef __toascii
|
||||
#undef _tolower
|
||||
#undef _toupper
|
||||
|
||||
#define upalpha ('A' - 'a')
|
||||
|
||||
|
||||
const 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 */
|
||||
};
|
||||
|
||||
const unsigned short _wctype[] = {
|
||||
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 */
|
||||
_BLANK | _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 */
|
||||
0x0100 | _UPPER | _HEX, /* `A', 0x41 */
|
||||
0x0100 | _UPPER | _HEX, /* `B', 0x42 */
|
||||
0x0100 | _UPPER | _HEX, /* `C', 0x43 */
|
||||
0x0100 | _UPPER | _HEX, /* `D', 0x44 */
|
||||
0x0100 | _UPPER | _HEX, /* `E', 0x45 */
|
||||
0x0100 | _UPPER | _HEX, /* `F', 0x46 */
|
||||
0x0100 | _UPPER, /* `G', 0x47 */
|
||||
0x0100 | _UPPER, /* `H', 0x48 */
|
||||
0x0100 | _UPPER, /* `I', 0x49 */
|
||||
0x0100 | _UPPER, /* `J', 0x4a */
|
||||
0x0100 | _UPPER, /* `K', 0x4b */
|
||||
0x0100 | _UPPER, /* `L', 0x4c */
|
||||
0x0100 | _UPPER, /* `M', 0x4d */
|
||||
0x0100 | _UPPER, /* `N', 0x4e */
|
||||
0x0100 | _UPPER, /* `O', 0x4f */
|
||||
0x0100 | _UPPER, /* `P', 0x50 */
|
||||
0x0100 | _UPPER, /* `Q', 0x51 */
|
||||
0x0100 | _UPPER, /* `R', 0x52 */
|
||||
0x0100 | _UPPER, /* `S', 0x53 */
|
||||
0x0100 | _UPPER, /* `T', 0x54 */
|
||||
0x0100 | _UPPER, /* `U', 0x55 */
|
||||
0x0100 | _UPPER, /* `V', 0x56 */
|
||||
0x0100 | _UPPER, /* `W', 0x57 */
|
||||
0x0100 | _UPPER, /* `X', 0x58 */
|
||||
0x0100 | _UPPER, /* `Y', 0x59 */
|
||||
0x0100 | _UPPER, /* `Z', 0x5a */
|
||||
_PUNCT, /* `[', 0x5b */
|
||||
_PUNCT, /* 0x5c */
|
||||
_PUNCT, /* `]', 0x5d */
|
||||
_PUNCT, /* `^', 0x5e */
|
||||
_PUNCT, /* `_', 0x5f */
|
||||
_PUNCT, /* 0x60 */
|
||||
0x0100 | _LOWER | _HEX, /* `a', 0x61 */
|
||||
0x0100 | _LOWER | _HEX, /* `b', 0x62 */
|
||||
0x0100 | _LOWER | _HEX, /* `c', 0x63 */
|
||||
0x0100 | _LOWER | _HEX, /* `d', 0x64 */
|
||||
0x0100 | _LOWER | _HEX, /* `e', 0x65 */
|
||||
0x0100 | _LOWER | _HEX, /* `f', 0x66 */
|
||||
0x0100 | _LOWER, /* `g', 0x67 */
|
||||
0x0100 | _LOWER, /* `h', 0x68 */
|
||||
0x0100 | _LOWER, /* `i', 0x69 */
|
||||
0x0100 | _LOWER, /* `j', 0x6a */
|
||||
0x0100 | _LOWER, /* `k', 0x6b */
|
||||
0x0100 | _LOWER, /* `l', 0x6c */
|
||||
0x0100 | _LOWER, /* `m', 0x6d */
|
||||
0x0100 | _LOWER, /* `n', 0x6e */
|
||||
0x0100 | _LOWER, /* `o', 0x6f */
|
||||
0x0100 | _LOWER, /* `p', 0x70 */
|
||||
0x0100 | _LOWER, /* `q', 0x71 */
|
||||
0x0100 | _LOWER, /* `r', 0x72 */
|
||||
0x0100 | _LOWER, /* `s', 0x73 */
|
||||
0x0100 | _LOWER, /* `t', 0x74 */
|
||||
0x0100 | _LOWER, /* `u', 0x75 */
|
||||
0x0100 | _LOWER, /* `v', 0x76 */
|
||||
0x0100 | _LOWER, /* `w', 0x77 */
|
||||
0x0100 | _LOWER, /* `x', 0x78 */
|
||||
0x0100 | _LOWER, /* `y', 0x79 */
|
||||
0x0100 | _LOWER, /* `z', 0x7a */
|
||||
_PUNCT, /* `{', 0x7b */
|
||||
_PUNCT, /* `|', 0x7c */
|
||||
_PUNCT, /* `}', 0x7d */
|
||||
_PUNCT, /* `~', 0x7e */
|
||||
_CONTROL, /* 0x7f */
|
||||
_CONTROL, /* 0x80 */
|
||||
_CONTROL, /* 0x81 */
|
||||
_CONTROL, /* 0x82 */
|
||||
_CONTROL, /* 0x83 */
|
||||
_CONTROL, /* 0x84 */
|
||||
_CONTROL, /* 0x85 */
|
||||
_CONTROL, /* 0x86 */
|
||||
_CONTROL, /* 0x87 */
|
||||
_CONTROL, /* 0x88 */
|
||||
_CONTROL, /* 0x89 */
|
||||
_CONTROL, /* 0x8a */
|
||||
_CONTROL, /* 0x8b */
|
||||
_CONTROL, /* 0x8c */
|
||||
_CONTROL, /* 0x8d */
|
||||
_CONTROL, /* 0x8e */
|
||||
_CONTROL, /* 0x8f */
|
||||
_CONTROL, /* 0x90 */
|
||||
_CONTROL, /* 0x91 */
|
||||
_CONTROL, /* 0x92 */
|
||||
_CONTROL, /* 0x93 */
|
||||
_CONTROL, /* 0x94 */
|
||||
_CONTROL, /* 0x95 */
|
||||
_CONTROL, /* 0x96 */
|
||||
_CONTROL, /* 0x97 */
|
||||
_CONTROL, /* 0x98 */
|
||||
_CONTROL, /* 0x99 */
|
||||
_CONTROL, /* 0x9a */
|
||||
_CONTROL, /* 0x9b */
|
||||
_CONTROL, /* 0x9c */
|
||||
_CONTROL, /* 0x9d */
|
||||
_CONTROL, /* 0x9e */
|
||||
_CONTROL, /* 0x9f */
|
||||
_BLANK | _SPACE, /* 0xa0 */
|
||||
_PUNCT, /* 0xa1 */
|
||||
_PUNCT, /* 0xa2 */
|
||||
_PUNCT, /* 0xa3 */
|
||||
_PUNCT, /* 0xa4 */
|
||||
_PUNCT, /* 0xa5 */
|
||||
_PUNCT, /* 0xa6 */
|
||||
_PUNCT, /* 0xa7 */
|
||||
_PUNCT, /* 0xa8 */
|
||||
_PUNCT, /* 0xa9 */
|
||||
_PUNCT, /* 0xaa */
|
||||
_PUNCT, /* 0xab */
|
||||
_PUNCT, /* 0xac */
|
||||
_PUNCT, /* 0xad */
|
||||
_PUNCT, /* 0xae */
|
||||
_PUNCT, /* 0xaf */
|
||||
_PUNCT, /* 0xb0 */
|
||||
_PUNCT, /* 0xb1 */
|
||||
_PUNCT | _DIGIT, /* 0xb2 */
|
||||
_PUNCT | _DIGIT, /* 0xb3 */
|
||||
_PUNCT, /* 0xb4 */
|
||||
_PUNCT, /* 0xb5 */
|
||||
_PUNCT, /* 0xb6 */
|
||||
_PUNCT, /* 0xb7 */
|
||||
_PUNCT, /* 0xb8 */
|
||||
_PUNCT | _DIGIT, /* 0xb9 */
|
||||
_PUNCT, /* 0xba */
|
||||
_PUNCT, /* 0xbb */
|
||||
_PUNCT, /* 0xbc */
|
||||
_PUNCT, /* 0xbd */
|
||||
_PUNCT, /* 0xbe */
|
||||
_PUNCT, /* 0xbf */
|
||||
0x0100 | _UPPER, /* 0xc0 */
|
||||
0x0100 | _UPPER, /* 0xc1 */
|
||||
0x0100 | _UPPER, /* 0xc2 */
|
||||
0x0100 | _UPPER, /* 0xc3 */
|
||||
0x0100 | _UPPER, /* 0xc4 */
|
||||
0x0100 | _UPPER, /* 0xc5 */
|
||||
0x0100 | _UPPER, /* 0xc6 */
|
||||
0x0100 | _UPPER, /* 0xc7 */
|
||||
0x0100 | _UPPER, /* 0xc8 */
|
||||
0x0100 | _UPPER, /* 0xc9 */
|
||||
0x0100 | _UPPER, /* 0xca */
|
||||
0x0100 | _UPPER, /* 0xcb */
|
||||
0x0100 | _UPPER, /* 0xcc */
|
||||
0x0100 | _UPPER, /* 0xcd */
|
||||
0x0100 | _UPPER, /* 0xce */
|
||||
0x0100 | _UPPER, /* 0xcf */
|
||||
0x0100 | _UPPER, /* 0xd0 */
|
||||
0x0100 | _UPPER, /* 0xd1 */
|
||||
0x0100 | _UPPER, /* 0xd2 */
|
||||
0x0100 | _UPPER, /* 0xd3 */
|
||||
0x0100 | _UPPER, /* 0xd4 */
|
||||
0x0100 | _UPPER, /* 0xd5 */
|
||||
0x0100 | _UPPER, /* 0xd6 */
|
||||
_PUNCT, /* 0xd7 */
|
||||
0x0100 | _UPPER, /* 0xd8 */
|
||||
0x0100 | _UPPER, /* 0xd9 */
|
||||
0x0100 | _UPPER, /* 0xda */
|
||||
0x0100 | _UPPER, /* 0xdb */
|
||||
0x0100 | _UPPER, /* 0xdc */
|
||||
0x0100 | _UPPER, /* 0xdd */
|
||||
0x0100 | _UPPER, /* 0xde */
|
||||
0x0100 | _LOWER, /* 0xdf */
|
||||
0x0100 | _LOWER, /* 0xe0 */
|
||||
0x0100 | _LOWER, /* 0xe1 */
|
||||
0x0100 | _LOWER, /* 0xe2 */
|
||||
0x0100 | _LOWER, /* 0xe3 */
|
||||
0x0100 | _LOWER, /* 0xe4 */
|
||||
0x0100 | _LOWER, /* 0xe5 */
|
||||
0x0100 | _LOWER, /* 0xe6 */
|
||||
0x0100 | _LOWER, /* 0xe7 */
|
||||
0x0100 | _LOWER, /* 0xe8 */
|
||||
0x0100 | _LOWER, /* 0xe9 */
|
||||
0x0100 | _LOWER, /* 0xea */
|
||||
0x0100 | _LOWER, /* 0xeb */
|
||||
0x0100 | _LOWER, /* 0xec */
|
||||
0x0100 | _LOWER, /* 0xed */
|
||||
0x0100 | _LOWER, /* 0xee */
|
||||
0x0100 | _LOWER, /* 0xef */
|
||||
0x0100 | _LOWER, /* 0xf0 */
|
||||
0x0100 | _LOWER, /* 0xf1 */
|
||||
0x0100 | _LOWER, /* 0xf2 */
|
||||
0x0100 | _LOWER, /* 0xf3 */
|
||||
0x0100 | _LOWER, /* 0xf4 */
|
||||
0x0100 | _LOWER, /* 0xf5 */
|
||||
0x0100 | _LOWER, /* 0xf6 */
|
||||
_PUNCT, /* 0xf7 */
|
||||
0x0100 | _LOWER, /* 0xf8 */
|
||||
0x0100 | _LOWER, /* 0xf9 */
|
||||
0x0100 | _LOWER, /* 0xfa */
|
||||
0x0100 | _LOWER, /* 0xfb */
|
||||
0x0100 | _LOWER, /* 0xfc */
|
||||
0x0100 | _LOWER, /* 0xfd */
|
||||
0x0100 | _LOWER, /* 0xfe */
|
||||
0x0100 | _LOWER /* 0xff */
|
||||
};
|
||||
const unsigned short *_pctype = _ctype + 1;
|
||||
const unsigned short *_pwctype = _wctype + 1;
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
const unsigned short **__p__pctype(void)
|
||||
{
|
||||
return &_pctype;
|
||||
}
|
||||
|
||||
const unsigned short* __cdecl __pctype_func(void)
|
||||
{
|
||||
return _pctype;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
const unsigned short **__p__pwctype(void)
|
||||
{
|
||||
return &_pwctype;
|
||||
}
|
||||
|
||||
const unsigned short* __cdecl __pwctype_func(void)
|
||||
{
|
||||
return _pwctype;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int isalpha(int c)
|
||||
{
|
||||
return(_isctype(c, _ALPHA));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int isalnum(int c)
|
||||
{
|
||||
return(_isctype(c, _ALPHA | _DIGIT));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int iswalnum(wint_t c)
|
||||
{
|
||||
return iswctype(c, _ALPHA | _DIGIT);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __isascii(int c)
|
||||
{
|
||||
return ((unsigned char)c <= 0x7f);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int iswascii(wint_t c)
|
||||
{
|
||||
return __isascii(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int iscntrl(int c)
|
||||
{
|
||||
return(_isctype(c, _CONTROL));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __iscsym(int c)
|
||||
{
|
||||
return (c < 127 && (isalnum(c) || (c == '_')));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __iscsymf(int c)
|
||||
{
|
||||
return (c < 127 && (isalpha(c) || (c == '_')));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int isdigit(int c)
|
||||
{
|
||||
return(_isctype(c, _DIGIT));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int iswalpha(wint_t c)
|
||||
{
|
||||
return (iswctype (c, _ALPHA));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int iswcntrl(wint_t c)
|
||||
{
|
||||
return iswctype(c, _CONTROL);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
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
|
||||
*/
|
||||
int iswlower(wint_t c)
|
||||
{
|
||||
return (iswctype (c, _LOWER));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int iswupper(wint_t c)
|
||||
{
|
||||
return iswctype(c, _UPPER);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int iswspace(wint_t c)
|
||||
{
|
||||
return (iswctype (c, _SPACE));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int iswxdigit(wint_t c)
|
||||
{
|
||||
return (iswctype (c, _HEX));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __toascii(int c)
|
||||
{
|
||||
return((unsigned int)(c) & 0x7f);
|
||||
}
|
||||
|
||||
/*
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
wint_t towlower(wint_t c)
|
||||
{
|
||||
if (iswctype (c, _UPPER))
|
||||
return (c - upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
wint_t towupper(wint_t c)
|
||||
{
|
||||
if (iswctype (c, _LOWER))
|
||||
return (c + upalpha);
|
||||
return(c);
|
||||
}
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strcat_asm.s
Normal file
6
lib/sdk/crt/string/i386/strcat_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcscat.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strchr_asm.s
Normal file
6
lib/sdk/crt/string/i386/strchr_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcschr.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strcmp_asm.s
Normal file
6
lib/sdk/crt/string/i386/strcmp_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcscmp.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strcpy_asm.s
Normal file
6
lib/sdk/crt/string/i386/strcpy_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcscpy.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strlen_asm.s
Normal file
6
lib/sdk/crt/string/i386/strlen_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcslen.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strncat_asm.s
Normal file
6
lib/sdk/crt/string/i386/strncat_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsncat.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strncmp_asm.s
Normal file
6
lib/sdk/crt/string/i386/strncmp_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsncmp.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strncpy_asm.s
Normal file
6
lib/sdk/crt/string/i386/strncpy_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsncpy.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strnlen_asm.s
Normal file
6
lib/sdk/crt/string/i386/strnlen_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsnlen.h"
|
||||
|
||||
/* EOF */
|
6
lib/sdk/crt/string/i386/strrchr_asm.s
Normal file
6
lib/sdk/crt/string/i386/strrchr_asm.s
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tcsrchr.h"
|
||||
|
||||
/* EOF */
|
59
lib/sdk/crt/string/i386/tchar.h
Normal file
59
lib/sdk/crt/string/i386/tchar.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __TCHAR_INC_S__
|
||||
#define __TCHAR_INC_S__
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
||||
#define _tcscat _wcscat
|
||||
#define _tcschr _wcschr
|
||||
#define _tcscmp _wcscmp
|
||||
#define _tcscpy _wcscpy
|
||||
#define _tcslen _wcslen
|
||||
#define _tcsncat _wcsncat
|
||||
#define _tcsncmp _wcsncmp
|
||||
#define _tcsncpy _wcsncpy
|
||||
#define _tcsnlen _wcsnlen
|
||||
#define _tcsrchr _wcsrchr
|
||||
|
||||
#define _tscas scasw
|
||||
#define _tlods lodsw
|
||||
#define _tstos stosw
|
||||
|
||||
#define _tsize $2
|
||||
|
||||
#define _treg(_O_) _O_ ## x
|
||||
|
||||
#define _tdec(_O_) sub $2, _O_
|
||||
#define _tinc(_O_) add $2, _O_
|
||||
|
||||
#else
|
||||
|
||||
#define _tcscat _strcat
|
||||
#define _tcschr _strchr
|
||||
#define _tcscmp _strcmp
|
||||
#define _tcscpy _strcpy
|
||||
#define _tcslen _strlen
|
||||
#define _tcsncat _strncat
|
||||
#define _tcsncmp _strncmp
|
||||
#define _tcsncpy _strncpy
|
||||
#define _tcsnlen _strnlen
|
||||
#define _tcsrchr _strrchr
|
||||
|
||||
#define _tscas scasb
|
||||
#define _tlods lodsb
|
||||
#define _tstos stosb
|
||||
|
||||
#define _tsize $1
|
||||
|
||||
#define _treg(_O_) _O_ ## l
|
||||
|
||||
#define _tdec(_O_) dec _O_
|
||||
#define _tinc(_O_) inc _O_
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* EOF */
|
32
lib/sdk/crt/string/i386/tcscat.h
Normal file
32
lib/sdk/crt/string/i386/tcscat.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcscat
|
||||
|
||||
_tcscat:
|
||||
push %esi
|
||||
push %edi
|
||||
mov 0x0C(%esp), %edi
|
||||
mov 0x10(%esp), %esi
|
||||
|
||||
xor %eax, %eax
|
||||
mov $-1, %ecx
|
||||
cld
|
||||
|
||||
repne _tscas
|
||||
_tdec(%edi)
|
||||
|
||||
.L1:
|
||||
_tlods
|
||||
_tstos
|
||||
test %_treg(a), %_treg(a)
|
||||
jnz .L1
|
||||
|
||||
mov 0x0C(%esp), %eax
|
||||
pop %edi
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
/* EOF */
|
30
lib/sdk/crt/string/i386/tcschr.h
Normal file
30
lib/sdk/crt/string/i386/tcschr.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcschr
|
||||
|
||||
_tcschr:
|
||||
push %esi
|
||||
mov 0x8(%esp), %esi
|
||||
mov 0xC(%esp), %edx
|
||||
|
||||
cld
|
||||
|
||||
.L1:
|
||||
_tlods
|
||||
cmp %_treg(a), %_treg(d)
|
||||
je .L2
|
||||
test %_treg(a), %_treg(a)
|
||||
jnz .L1
|
||||
mov _tsize, %esi
|
||||
|
||||
.L2:
|
||||
mov %esi, %eax
|
||||
_tdec(%eax)
|
||||
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
/* EOF */
|
34
lib/sdk/crt/string/i386/tcscmp.h
Normal file
34
lib/sdk/crt/string/i386/tcscmp.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcscmp
|
||||
|
||||
_tcscmp:
|
||||
push %esi
|
||||
push %edi
|
||||
mov 0x0C(%esp), %esi
|
||||
mov 0x10(%esp), %edi
|
||||
xor %eax, %eax
|
||||
cld
|
||||
|
||||
.L1:
|
||||
_tlods
|
||||
_tscas
|
||||
jne .L2
|
||||
test %eax, %eax
|
||||
jne .L1
|
||||
xor %eax, %eax
|
||||
jmp .L3
|
||||
|
||||
.L2:
|
||||
sbb %eax, %eax
|
||||
or $1, %al
|
||||
|
||||
.L3:
|
||||
pop %edi
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
/* EOF */
|
27
lib/sdk/crt/string/i386/tcscpy.h
Normal file
27
lib/sdk/crt/string/i386/tcscpy.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcscpy
|
||||
|
||||
_tcscpy:
|
||||
push %esi
|
||||
push %edi
|
||||
mov 0x0C(%esp), %edi
|
||||
mov 0x10(%esp), %esi
|
||||
cld
|
||||
|
||||
.L1:
|
||||
_tlods
|
||||
_tstos
|
||||
test %_treg(a), %_treg(a)
|
||||
jnz .L1
|
||||
|
||||
mov 0x0C(%esp), %eax
|
||||
|
||||
pop %edi
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
/* EOF */
|
29
lib/sdk/crt/string/i386/tcslen.h
Normal file
29
lib/sdk/crt/string/i386/tcslen.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcslen
|
||||
|
||||
_tcslen:
|
||||
push %edi
|
||||
mov 0x8(%esp), %edi
|
||||
xor %eax, %eax
|
||||
test %edi,%edi
|
||||
jz _tcslen_end
|
||||
|
||||
mov $-1, %ecx
|
||||
cld
|
||||
|
||||
repne _tscas
|
||||
|
||||
not %ecx
|
||||
dec %ecx
|
||||
|
||||
mov %ecx, %eax
|
||||
|
||||
_tcslen_end:
|
||||
pop %edi
|
||||
ret
|
||||
|
||||
/* EOF */
|
42
lib/sdk/crt/string/i386/tcsncat.h
Normal file
42
lib/sdk/crt/string/i386/tcsncat.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcsncat
|
||||
|
||||
_tcsncat:
|
||||
push %esi
|
||||
push %edi
|
||||
mov 0x0C(%esp), %edi
|
||||
mov 0x10(%esp), %esi
|
||||
cld
|
||||
|
||||
xor %eax, %eax
|
||||
mov $-1, %ecx
|
||||
repne _tscas
|
||||
_tdec(%edi)
|
||||
|
||||
mov 0x14(%esp),%ecx
|
||||
|
||||
.L1:
|
||||
dec %ecx
|
||||
js .L2
|
||||
_tlods
|
||||
_tstos
|
||||
test %_treg(a), %_treg(a)
|
||||
jne .L1
|
||||
jmp .L3
|
||||
|
||||
.L2:
|
||||
xor %eax, %eax
|
||||
_tstos
|
||||
|
||||
.L3:
|
||||
mov 0x0C(%esp), %eax
|
||||
pop %edi
|
||||
pop %esi
|
||||
|
||||
ret
|
||||
|
||||
/* EOF */
|
40
lib/sdk/crt/string/i386/tcsncmp.h
Normal file
40
lib/sdk/crt/string/i386/tcsncmp.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcsncmp
|
||||
|
||||
_tcsncmp:
|
||||
push %esi
|
||||
push %edi
|
||||
mov 0x0C(%esp), %esi /* s1 */
|
||||
mov 0x10(%esp), %edi /* s2 */
|
||||
mov 0x14(%esp), %ecx /* n */
|
||||
|
||||
xor %eax,%eax
|
||||
cld
|
||||
|
||||
.L1:
|
||||
dec %ecx
|
||||
js .L2
|
||||
_tlods
|
||||
_tscas
|
||||
jne .L3
|
||||
test %eax, %eax
|
||||
jne .L1
|
||||
|
||||
.L2:
|
||||
xor %eax, %eax
|
||||
jmp .L4
|
||||
|
||||
.L3:
|
||||
sbb %eax, %eax
|
||||
or $1, %al
|
||||
|
||||
.L4:
|
||||
pop %edi
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
/* EOF */
|
34
lib/sdk/crt/string/i386/tcsncpy.h
Normal file
34
lib/sdk/crt/string/i386/tcsncpy.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcsncpy
|
||||
|
||||
_tcsncpy:
|
||||
push %esi
|
||||
push %edi
|
||||
mov 0x0C(%esp), %edi /* s1 */
|
||||
mov 0x10(%esp), %esi /* s2 */
|
||||
mov 0x14(%esp), %ecx /* n */
|
||||
|
||||
xor %eax, %eax
|
||||
cld
|
||||
|
||||
.L1:
|
||||
dec %ecx
|
||||
js .L2
|
||||
_tlods
|
||||
_tstos
|
||||
test %_treg(a), %_treg(a)
|
||||
jnz .L1
|
||||
rep _tstos
|
||||
|
||||
.L2:
|
||||
mov 0x0C(%esp), %eax
|
||||
|
||||
pop %edi
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
/* EOF */
|
30
lib/sdk/crt/string/i386/tcsnlen.h
Normal file
30
lib/sdk/crt/string/i386/tcsnlen.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcsnlen
|
||||
|
||||
_tcsnlen:
|
||||
push %edi
|
||||
mov 0x8(%esp), %edi
|
||||
mov 0xC(%esp), %ecx
|
||||
xor %eax, %eax
|
||||
test %ecx, %ecx
|
||||
jz .L1
|
||||
mov %ecx, %edx
|
||||
|
||||
cld
|
||||
|
||||
repne _tscas
|
||||
|
||||
sete %al
|
||||
sub %ecx, %edx
|
||||
sub %eax, %edx
|
||||
mov %edx, %eax
|
||||
|
||||
.L1:
|
||||
pop %edi
|
||||
ret
|
||||
|
||||
/* EOF */
|
31
lib/sdk/crt/string/i386/tcsrchr.h
Normal file
31
lib/sdk/crt/string/i386/tcsrchr.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include "tchar.h"
|
||||
|
||||
.globl _tcsrchr
|
||||
|
||||
_tcsrchr:
|
||||
push %esi
|
||||
mov 0x8(%esp), %esi
|
||||
mov 0xC(%esp), %edx
|
||||
|
||||
cld
|
||||
mov _tsize, %ecx
|
||||
|
||||
.L1:
|
||||
_tlods
|
||||
cmp %_treg(a), %_treg(d)
|
||||
jne .L2
|
||||
mov %esi, %ecx
|
||||
|
||||
.L2:
|
||||
test %_treg(a), %_treg(a)
|
||||
jnz .L1
|
||||
|
||||
mov %ecx, %eax
|
||||
_tdec(%eax)
|
||||
pop %esi
|
||||
ret
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcscat_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcscat_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcscat.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcschr_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcschr_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcschr.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcscmp_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcscmp_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcscmp.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcscpy_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcscpy_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcscpy.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcslen_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcslen_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcslen.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcsncat_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcsncat_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcsncat.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcsncmp_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcsncmp_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcsncmp.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcsncpy_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcsncpy_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcsncpy.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcsnlen_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcsnlen_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcsnlen.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/i386/wcsrchr_asm.s
Normal file
7
lib/sdk/crt/string/i386/wcsrchr_asm.s
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include "tcsrchr.h"
|
||||
|
||||
/* EOF */
|
168
lib/sdk/crt/string/itoa.c
Normal file
168
lib/sdk/crt/string/itoa.c
Normal file
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* copy _i64toa from wine cvs 2006 month 05 day 21
|
||||
*/
|
||||
char *
|
||||
_i64toa(__int64 value, char *string, int radix)
|
||||
{
|
||||
ULONGLONG val;
|
||||
int negative;
|
||||
char buffer[65];
|
||||
char *pos;
|
||||
int digit;
|
||||
|
||||
if (value < 0 && radix == 10) {
|
||||
negative = 1;
|
||||
val = -value;
|
||||
} else {
|
||||
negative = 0;
|
||||
val = value;
|
||||
} /* if */
|
||||
|
||||
pos = &buffer[64];
|
||||
*pos = '\0';
|
||||
|
||||
do {
|
||||
digit = val % radix;
|
||||
val = val / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (val != 0L);
|
||||
|
||||
if (negative) {
|
||||
*--pos = '-';
|
||||
} /* if */
|
||||
|
||||
memcpy(string, pos, &buffer[64] - pos + 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* copy _i64toa from wine cvs 2006 month 05 day 21
|
||||
*/
|
||||
char *
|
||||
_ui64toa(unsigned __int64 value, char *string, int radix)
|
||||
{
|
||||
char buffer[65];
|
||||
char *pos;
|
||||
int digit;
|
||||
|
||||
pos = &buffer[64];
|
||||
*pos = '\0';
|
||||
|
||||
do {
|
||||
digit = value % radix;
|
||||
value = value / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (value != 0L);
|
||||
|
||||
memcpy(string, pos, &buffer[64] - pos + 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *
|
||||
_itoa(int value, char *string, int radix)
|
||||
{
|
||||
return _ltoa(value, string, radix);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *
|
||||
_ltoa(long value, char *string, int radix)
|
||||
{
|
||||
unsigned long val;
|
||||
int negative;
|
||||
char buffer[33];
|
||||
char *pos;
|
||||
int digit;
|
||||
|
||||
if (value < 0 && radix == 10) {
|
||||
negative = 1;
|
||||
val = -value;
|
||||
} else {
|
||||
negative = 0;
|
||||
val = value;
|
||||
} /* if */
|
||||
|
||||
pos = &buffer[32];
|
||||
*pos = '\0';
|
||||
|
||||
do {
|
||||
digit = val % radix;
|
||||
val = val / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (val != 0L);
|
||||
|
||||
if (negative) {
|
||||
*--pos = '-';
|
||||
} /* if */
|
||||
|
||||
memcpy(string, pos, &buffer[32] - pos + 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* copy it from wine 0.9.0 with small modifcations do check for NULL
|
||||
*/
|
||||
char *
|
||||
_ultoa(unsigned long value, char *string, int radix)
|
||||
{
|
||||
char buffer[33];
|
||||
char *pos;
|
||||
int digit;
|
||||
|
||||
pos = &buffer[32];
|
||||
*pos = '\0';
|
||||
|
||||
if (string == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
do {
|
||||
digit = value % radix;
|
||||
value = value / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (value != 0L);
|
||||
|
||||
memcpy(string, pos, &buffer[32] - pos + 1);
|
||||
|
||||
return string;
|
||||
}
|
171
lib/sdk/crt/string/itow.c
Normal file
171
lib/sdk/crt/string/itow.c
Normal file
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/sdk/crt/itow.c
|
||||
* PURPOSE: converts a integer to wchar_t
|
||||
* PROGRAMER:
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* from wine cvs 2006-05-21
|
||||
*/
|
||||
wchar_t *
|
||||
_i64tow(__int64 value, wchar_t *string, int radix)
|
||||
{
|
||||
ULONGLONG val;
|
||||
int negative;
|
||||
WCHAR buffer[65];
|
||||
PWCHAR pos;
|
||||
WCHAR digit;
|
||||
|
||||
if (value < 0 && radix == 10) {
|
||||
negative = 1;
|
||||
val = -value;
|
||||
} else {
|
||||
negative = 0;
|
||||
val = value;
|
||||
} /* if */
|
||||
|
||||
pos = &buffer[64];
|
||||
*pos = '\0';
|
||||
|
||||
do {
|
||||
digit = val % radix;
|
||||
val = val / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (val != 0L);
|
||||
|
||||
if (negative) {
|
||||
*--pos = '-';
|
||||
} /* if */
|
||||
|
||||
if (string != NULL) {
|
||||
memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR));
|
||||
} /* if */
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
wchar_t *
|
||||
_ui64tow(unsigned __int64 value, wchar_t *string, int radix)
|
||||
{
|
||||
WCHAR buffer[65];
|
||||
PWCHAR pos;
|
||||
WCHAR digit;
|
||||
|
||||
pos = &buffer[64];
|
||||
*pos = '\0';
|
||||
|
||||
do {
|
||||
digit = value % radix;
|
||||
value = value / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (value != 0L);
|
||||
|
||||
if (string != NULL) {
|
||||
memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR));
|
||||
} /* if */
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* from wine cvs 2006-05-21
|
||||
*/
|
||||
wchar_t *
|
||||
_itow(int value, wchar_t *string, int radix)
|
||||
{
|
||||
return _ltow(value, string, radix);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* from wine cvs 2006-05-21
|
||||
*/
|
||||
wchar_t *
|
||||
_ltow(long value, wchar_t *string, int radix)
|
||||
{
|
||||
unsigned long val;
|
||||
int negative;
|
||||
WCHAR buffer[33];
|
||||
PWCHAR pos;
|
||||
WCHAR digit;
|
||||
|
||||
if (value < 0 && radix == 10) {
|
||||
negative = 1;
|
||||
val = -value;
|
||||
} else {
|
||||
negative = 0;
|
||||
val = value;
|
||||
} /* if */
|
||||
|
||||
pos = &buffer[32];
|
||||
*pos = '\0';
|
||||
|
||||
do {
|
||||
digit = val % radix;
|
||||
val = val / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (val != 0L);
|
||||
|
||||
if (negative) {
|
||||
*--pos = '-';
|
||||
} /* if */
|
||||
|
||||
if (string != NULL) {
|
||||
memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR));
|
||||
} /* if */
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* from wine cvs 2006-05-21
|
||||
*/
|
||||
wchar_t *
|
||||
_ultow(unsigned long value, wchar_t *string, int radix)
|
||||
{
|
||||
WCHAR buffer[33];
|
||||
PWCHAR pos;
|
||||
WCHAR digit;
|
||||
|
||||
pos = &buffer[32];
|
||||
*pos = '\0';
|
||||
|
||||
do {
|
||||
digit = value % radix;
|
||||
value = value / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (value != 0L);
|
||||
|
||||
if (string != NULL) {
|
||||
memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR));
|
||||
} /* if */
|
||||
return string;
|
||||
}
|
26
lib/sdk/crt/string/lasttok.c
Normal file
26
lib/sdk/crt/string/lasttok.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
#include <precomp.h>
|
||||
|
||||
#include <internal/tls.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* This is an MSVCRT internal function to return the lasttoken
|
||||
* bit of data used by strtok. The reason for it's existence is
|
||||
* so that CRTDLL can use the strtok source code in the same
|
||||
* file.
|
||||
*/
|
||||
char** _lasttoken()
|
||||
{
|
||||
PTHREADDATA ptd = GetThreadData();
|
||||
assert(ptd);
|
||||
return &(ptd->lasttoken);
|
||||
}
|
60
lib/sdk/crt/string/mbstowcs_nt.c
Normal file
60
lib/sdk/crt/string/mbstowcs_nt.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#include <ndk/umtypes.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* @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,
|
||||
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,
|
||||
mbstr,
|
||||
Length);
|
||||
|
||||
return (size_t)Size;
|
||||
}
|
||||
|
||||
Status = RtlMultiByteToUnicodeN (wcstr,
|
||||
count * sizeof(WCHAR),
|
||||
&Size,
|
||||
mbstr,
|
||||
Length);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return -1;
|
||||
|
||||
return (size_t)Size;
|
||||
}
|
||||
|
||||
/* EOF */
|
194
lib/sdk/crt/string/scanf.c
Normal file
194
lib/sdk/crt/string/scanf.c
Normal file
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* general implementation of scanf used by scanf, sscanf, fscanf,
|
||||
* _cscanf, wscanf, swscanf and fwscanf
|
||||
*
|
||||
* Copyright 1996,1998 Marcus Meissner
|
||||
* Copyright 1996 Jukka Iivonen
|
||||
* Copyright 1997,2000 Uwe Bonnes
|
||||
* Copyright 2000 Jon Griffiths
|
||||
* Copyright 2002 Daniel Gudbjartsson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
#include <ctype.h>
|
||||
|
||||
// HACK for LIBCNT
|
||||
#ifndef debugstr_a
|
||||
#define debugstr_a
|
||||
#endif
|
||||
|
||||
//extern FILE _iob[];
|
||||
|
||||
/* helper function for *scanf. Returns the value of character c in the
|
||||
* given base, or -1 if the given character is not a digit of the base.
|
||||
*/
|
||||
static int char2digit(char c, int base) {
|
||||
if ((c>='0') && (c<='9') && (c<='0'+base-1)) return (c-'0');
|
||||
if (base<=10) return -1;
|
||||
if ((c>='A') && (c<='Z') && (c<='A'+base-11)) return (c-'A'+10);
|
||||
if ((c>='a') && (c<='z') && (c<='a'+base-11)) return (c-'a'+10);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* helper function for *wscanf. Returns the value of character c in the
|
||||
* given base, or -1 if the given character is not a digit of the base.
|
||||
*/
|
||||
static int wchar2digit(wchar_t c, int base) {
|
||||
if ((c>='0') && (c<='9') && (c<='0'+base-1)) return (c-'0');
|
||||
if (base<=10) return -1;
|
||||
if ((c>='A') && (c<='Z') && (c<='A'+base-11)) return (c-'A'+10);
|
||||
if ((c>='a') && (c<='z') && (c<='a'+base-11)) return (c-'a'+10);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef _LIBCNT_
|
||||
/* vfscanf */
|
||||
#undef WIDE_SCANF
|
||||
#undef CONSOLE
|
||||
#undef STRING
|
||||
#include "scanf.h"
|
||||
|
||||
/* vfwscanf */
|
||||
#define WIDE_SCANF 1
|
||||
#undef CONSOLE
|
||||
#undef STRING
|
||||
#include "scanf.h"
|
||||
#endif
|
||||
|
||||
/* vsscanf */
|
||||
#undef WIDE_SCANF
|
||||
#undef CONSOLE
|
||||
#define STRING 1
|
||||
#include "scanf.h"
|
||||
|
||||
/* vswscanf */
|
||||
#define WIDE_SCANF 1
|
||||
#undef CONSOLE
|
||||
#define STRING 1
|
||||
#include "scanf.h"
|
||||
|
||||
#ifndef _LIBCNT_
|
||||
/* vcscanf */
|
||||
#undef WIDE_SCANF
|
||||
#define CONSOLE 1
|
||||
#undef STRING
|
||||
#include "scanf.h"
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* fscanf (MSVCRT.@)
|
||||
*/
|
||||
int fscanf(FILE *file, const char *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
|
||||
va_start(valist, format);
|
||||
res = vfscanf(file, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* scanf (MSVCRT.@)
|
||||
*/
|
||||
int scanf(const char *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
|
||||
va_start(valist, format);
|
||||
res = vfscanf(stdin, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* fwscanf (MSVCRT.@)
|
||||
*/
|
||||
int fwscanf(FILE *file, const wchar_t *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
|
||||
va_start(valist, format);
|
||||
res = vfwscanf(file, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* wscanf (MSVCRT.@)
|
||||
*/
|
||||
int wscanf(const wchar_t *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
|
||||
va_start(valist, format);
|
||||
res = vfwscanf(stdin, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* sscanf (MSVCRT.@)
|
||||
*/
|
||||
int sscanf(const char *str, const char *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
|
||||
va_start(valist, format);
|
||||
res = vsscanf(str, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* swscanf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL swscanf(const wchar_t *str, const wchar_t *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
|
||||
va_start(valist, format);
|
||||
res = vswscanf(str, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifndef _LIBCNT_
|
||||
/*********************************************************************
|
||||
* _cscanf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL _cscanf(const char *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
|
||||
va_start(valist, format);
|
||||
res = vcscanf(format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
#endif
|
543
lib/sdk/crt/string/scanf.h
Normal file
543
lib/sdk/crt/string/scanf.h
Normal file
|
@ -0,0 +1,543 @@
|
|||
/*
|
||||
* general implementation of scanf used by scanf, sscanf, fscanf,
|
||||
* _cscanf, wscanf, swscanf and fwscanf
|
||||
*
|
||||
* Copyright 1996,1998 Marcus Meissner
|
||||
* Copyright 1996 Jukka Iivonen
|
||||
* Copyright 1997,2000, 2003 Uwe Bonnes
|
||||
* Copyright 2000 Jon Griffiths
|
||||
* Copyright 2002 Daniel Gudbjartsson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifdef WIDE_SCANF
|
||||
#define _CHAR_ wchar_t
|
||||
#define _EOF_ WEOF
|
||||
#define _EOF_RET WEOF
|
||||
#define _ISSPACE_(c) iswspace(c)
|
||||
#define _ISDIGIT_(c) iswdigit(c)
|
||||
#define _WIDE2SUPPORTED_(c) c /* No conversion needed (wide to wide) */
|
||||
#define _CHAR2SUPPORTED_(c) c /* FIXME: convert char to wide char */
|
||||
#define _CHAR2DIGIT_(c, base) wchar2digit((c), (base))
|
||||
#define _BITMAPSIZE_ 256*256
|
||||
#else /* WIDE_SCANF */
|
||||
#define _CHAR_ char
|
||||
#define _EOF_ EOF
|
||||
#define _EOF_RET EOF
|
||||
#define _ISSPACE_(c) isspace(c)
|
||||
#define _ISDIGIT_(c) isdigit(c)
|
||||
#define _WIDE2SUPPORTED_(c) c /* FIXME: convert wide char to char */
|
||||
#define _CHAR2SUPPORTED_(c) c /* No conversion needed (char to char) */
|
||||
#define _CHAR2DIGIT_(c, base) char2digit((c), (base))
|
||||
#define _BITMAPSIZE_ 256
|
||||
#endif /* WIDE_SCANF */
|
||||
|
||||
#ifdef CONSOLE
|
||||
#define _GETC_(file) (consumed++, _getch())
|
||||
#define _UNGETC_(nch, file) do { _ungetch(nch); consumed--; } while(0)
|
||||
#define _FUNCTION_ int vcscanf(const char *format, va_list ap)
|
||||
#else
|
||||
#ifdef STRING
|
||||
#undef _EOF_
|
||||
#define _EOF_ 0
|
||||
#define _GETC_(file) (consumed++, *file++)
|
||||
#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
|
||||
#ifdef WIDE_SCANF
|
||||
#define _FUNCTION_ int vswscanf(const wchar_t *file, const wchar_t *format, va_list ap)
|
||||
#else /* WIDE_SCANF */
|
||||
#define _FUNCTION_ int vsscanf(const char *file, const char *format, va_list ap)
|
||||
#endif /* WIDE_SCANF */
|
||||
#else /* STRING */
|
||||
#ifdef WIDE_SCANF
|
||||
#define _GETC_(file) (consumed++, fgetwc(file))
|
||||
#define _UNGETC_(nch, file) do { ungetwc(nch, file); consumed--; } while(0)
|
||||
#define _FUNCTION_ int vfwscanf(FILE* file, const wchar_t *format, va_list ap)
|
||||
#else /* WIDE_SCANF */
|
||||
#define _GETC_(file) (consumed++, fgetc(file))
|
||||
#define _UNGETC_(nch, file) do { ungetc(nch, file); consumed--; } while(0)
|
||||
#define _FUNCTION_ int vfscanf(FILE* file, const char *format, va_list ap)
|
||||
#endif /* WIDE_SCANF */
|
||||
#endif /* STRING */
|
||||
#endif /* CONSOLE */
|
||||
|
||||
_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;
|
||||
|
||||
while (*format) {
|
||||
/* a whitespace character in the format string causes scanf to read,
|
||||
* but not store, all consecutive white-space characters in the input
|
||||
* up to the next non-white-space character. One white space character
|
||||
* in the input matches any number (including zero) and combination of
|
||||
* white-space characters in the input. */
|
||||
if (_ISSPACE_(*format)) {
|
||||
/* skip whitespace */
|
||||
while ((nch!=_EOF_) && _ISSPACE_(nch))
|
||||
nch = _GETC_(file);
|
||||
}
|
||||
/* a format specification causes scanf to read and convert characters
|
||||
* in the input into values of a specified type. The value is assigned
|
||||
* to an argument in the argument list. Format specifications have
|
||||
* the form %[*][width][{h | l | I64 | L}]type */
|
||||
else if (*format == '%') {
|
||||
int st = 0; int suppress = 0; int width = 0;
|
||||
int base;
|
||||
int h_prefix = 0;
|
||||
int l_prefix = 0;
|
||||
int L_prefix = 0;
|
||||
int w_prefix = 0;
|
||||
int prefix_finished = 0;
|
||||
int I64_prefix = 0;
|
||||
format++;
|
||||
/* look for leading asterisk, which means 'suppress assignment of
|
||||
* this field'. */
|
||||
if (*format=='*') {
|
||||
format++;
|
||||
suppress=1;
|
||||
}
|
||||
/* look for width specification */
|
||||
while (_ISDIGIT_(*format)) {
|
||||
width*=10;
|
||||
width+=*format++ - '0';
|
||||
}
|
||||
if (width==0) width=-1; /* no width spec seen */
|
||||
/* read prefix (if any) */
|
||||
while (!prefix_finished) {
|
||||
switch(*format) {
|
||||
case 'h': h_prefix = 1; break;
|
||||
case 'l': l_prefix = 1; break;
|
||||
case 'w': w_prefix = 1; break;
|
||||
case 'L': L_prefix = 1; break;
|
||||
case 'I':
|
||||
if (*(format + 1) == '6' &&
|
||||
*(format + 2) == '4') {
|
||||
I64_prefix = 1;
|
||||
format += 2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
prefix_finished = 1;
|
||||
}
|
||||
if (!prefix_finished) format++;
|
||||
}
|
||||
/* read type */
|
||||
switch(*format) {
|
||||
case 'p':
|
||||
case 'P': /* pointer. */
|
||||
if (sizeof(void *) == sizeof(LONGLONG)) I64_prefix = 1;
|
||||
/* fall through */
|
||||
case 'x':
|
||||
case 'X': /* hexadecimal integer. */
|
||||
base = 16;
|
||||
goto number;
|
||||
case 'o': /* octal integer */
|
||||
base = 8;
|
||||
goto number;
|
||||
case 'u': /* unsigned decimal integer */
|
||||
base = 10;
|
||||
goto number;
|
||||
case 'd': /* signed decimal integer */
|
||||
base = 10;
|
||||
goto number;
|
||||
case 'i': /* generic integer */
|
||||
base = 0;
|
||||
number: {
|
||||
/* read an integer */
|
||||
ULONGLONG cur = 0;
|
||||
int negative = 0;
|
||||
int seendigit=0;
|
||||
/* skip initial whitespace */
|
||||
while ((nch!=_EOF_) && _ISSPACE_(nch))
|
||||
nch = _GETC_(file);
|
||||
/* get sign */
|
||||
if (nch == '-' || nch == '+') {
|
||||
negative = (nch=='-');
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
}
|
||||
/* look for leading indication of base */
|
||||
if (width!=0 && nch == '0' && *format != 'p' && *format != 'P') {
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
seendigit=1;
|
||||
if (width!=0 && (nch=='x' || nch=='X')) {
|
||||
if (base==0)
|
||||
base=16;
|
||||
if (base==16) {
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
seendigit=0;
|
||||
}
|
||||
} else if (base==0)
|
||||
base = 8;
|
||||
}
|
||||
/* format %i without indication of base */
|
||||
if (base==0)
|
||||
base = 10;
|
||||
/* throw away leading zeros */
|
||||
while (width!=0 && nch=='0') {
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
seendigit=1;
|
||||
}
|
||||
if (width!=0 && _CHAR2DIGIT_(nch, base)!=-1) {
|
||||
cur = _CHAR2DIGIT_(nch, base);
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
seendigit=1;
|
||||
}
|
||||
/* read until no more digits */
|
||||
while (width!=0 && (nch!=_EOF_) && _CHAR2DIGIT_(nch, base)!=-1) {
|
||||
cur = cur*base + _CHAR2DIGIT_(nch, base);
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
seendigit=1;
|
||||
}
|
||||
/* okay, done! */
|
||||
if (!seendigit) break; /* not a valid number */
|
||||
st = 1;
|
||||
if (!suppress) {
|
||||
#define _SET_NUMBER_(type) *va_arg(ap, type*) = negative ? -cur : cur
|
||||
if (I64_prefix) _SET_NUMBER_(LONGLONG);
|
||||
else if (l_prefix) _SET_NUMBER_(LONG);
|
||||
else if (h_prefix) _SET_NUMBER_(short int);
|
||||
else _SET_NUMBER_(int);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'G': { /* read a float */
|
||||
long double cur = 0;
|
||||
int negative = 0;
|
||||
/* skip initial whitespace */
|
||||
while ((nch!=_EOF_) && _ISSPACE_(nch))
|
||||
nch = _GETC_(file);
|
||||
/* get sign. */
|
||||
if (nch == '-' || nch == '+') {
|
||||
negative = (nch=='-');
|
||||
if (width>0) width--;
|
||||
if (width==0) break;
|
||||
nch = _GETC_(file);
|
||||
}
|
||||
/* get first digit. */
|
||||
if ('.' != nch) {
|
||||
if (!_ISDIGIT_(nch)) break;
|
||||
cur = (nch - '0');
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
/* read until no more digits */
|
||||
while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) {
|
||||
cur = cur*10 + (nch - '0');
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
}
|
||||
} else {
|
||||
cur = 0; /* MaxPayneDemo Fix: .8 -> 0.8 */
|
||||
}
|
||||
/* handle decimals */
|
||||
if (width!=0 && nch == '.') {
|
||||
long double dec = 1;
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) {
|
||||
dec /= 10;
|
||||
cur += dec * (nch - '0');
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
}
|
||||
}
|
||||
/* handle exponent */
|
||||
if (width!=0 && (nch == 'e' || nch == 'E')) {
|
||||
int exponent = 0, negexp = 0;
|
||||
float expcnt;
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
/* possible sign on the exponent */
|
||||
if (width!=0 && (nch=='+' || nch=='-')) {
|
||||
negexp = (nch=='-');
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
}
|
||||
/* exponent digits */
|
||||
while (width!=0 && (nch!=_EOF_) && _ISDIGIT_(nch)) {
|
||||
exponent *= 10;
|
||||
exponent += (nch - '0');
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
}
|
||||
/* update 'cur' with this exponent. */
|
||||
expcnt = negexp ? .1 : 10;
|
||||
while (exponent!=0) {
|
||||
if (exponent&1)
|
||||
cur*=expcnt;
|
||||
exponent/=2;
|
||||
expcnt=expcnt*expcnt;
|
||||
}
|
||||
}
|
||||
st = 1;
|
||||
if (!suppress) {
|
||||
if (L_prefix) _SET_NUMBER_(long double);
|
||||
else if (l_prefix) _SET_NUMBER_(double);
|
||||
else _SET_NUMBER_(float);
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* According to msdn,
|
||||
* 's' reads a character string in a call to fscanf
|
||||
* and 'S' a wide character string and vice versa in a
|
||||
* call to fwscanf. The 'h', 'w' and 'l' prefixes override
|
||||
* this behaviour. 'h' forces reading char * but 'l' and 'w'
|
||||
* force reading WCHAR. */
|
||||
case 's':
|
||||
if (w_prefix || l_prefix) goto widecharstring;
|
||||
else if (h_prefix) goto charstring;
|
||||
#ifdef WIDE_SCANF
|
||||
else goto widecharstring;
|
||||
#else /* WIDE_SCANF */
|
||||
else goto charstring;
|
||||
#endif /* WIDE_SCANF */
|
||||
case 'S':
|
||||
if (w_prefix || l_prefix) goto widecharstring;
|
||||
else if (h_prefix) goto charstring;
|
||||
#ifdef WIDE_SCANF
|
||||
else goto charstring;
|
||||
#else /* WIDE_SCANF */
|
||||
else goto widecharstring;
|
||||
#endif /* WIDE_SCANF */
|
||||
charstring: { /* read a word into a char */
|
||||
char *sptr = suppress ? NULL : va_arg(ap, char*);
|
||||
/* skip initial whitespace */
|
||||
while ((nch!=_EOF_) && _ISSPACE_(nch))
|
||||
nch = _GETC_(file);
|
||||
/* read until whitespace */
|
||||
while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
|
||||
if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch);
|
||||
st++;
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
}
|
||||
/* terminate */
|
||||
if (!suppress) *sptr = 0;
|
||||
}
|
||||
break;
|
||||
widecharstring: { /* read a word into a wchar_t* */
|
||||
wchar_t *sptr = suppress ? NULL : va_arg(ap, wchar_t*);
|
||||
/* skip initial whitespace */
|
||||
while ((nch!=_EOF_) && _ISSPACE_(nch))
|
||||
nch = _GETC_(file);
|
||||
/* read until whitespace */
|
||||
while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
|
||||
if (!suppress) *sptr++ = _WIDE2SUPPORTED_(nch);
|
||||
st++;
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
}
|
||||
/* terminate */
|
||||
if (!suppress) *sptr = 0;
|
||||
}
|
||||
break;
|
||||
/* 'c' and 'C work analogously to 's' and 'S' as described
|
||||
* above */
|
||||
case 'c':
|
||||
if (w_prefix || l_prefix) goto widecharacter;
|
||||
else if (h_prefix) goto character;
|
||||
#ifdef WIDE_SCANF
|
||||
else goto widecharacter;
|
||||
#else /* WIDE_SCANF */
|
||||
else goto character;
|
||||
#endif /* WIDE_SCANF */
|
||||
case 'C':
|
||||
if (w_prefix || l_prefix) goto widecharacter;
|
||||
else if (h_prefix) goto character;
|
||||
#ifdef WIDE_SCANF
|
||||
else goto character;
|
||||
#else /* WIDE_SCANF */
|
||||
else goto widecharacter;
|
||||
#endif /* WIDE_SCANF */
|
||||
character: { /* read single character into char */
|
||||
char *str = suppress ? NULL : va_arg(ap, char*);
|
||||
if (width == -1) width = 1;
|
||||
while ((width != 0) && (nch != _EOF_))
|
||||
{
|
||||
if (!suppress) *str++ = _CHAR2SUPPORTED_(nch);
|
||||
st++;
|
||||
width--;
|
||||
nch = _GETC_(file);
|
||||
}
|
||||
}
|
||||
break;
|
||||
widecharacter: { /* read single character into a wchar_t */
|
||||
wchar_t *str = suppress ? NULL : va_arg(ap, wchar_t*);
|
||||
if (width == -1) width = 1;
|
||||
while ((width != 0) && (nch != _EOF_))
|
||||
{
|
||||
if (!suppress) *str++ = _WIDE2SUPPORTED_(nch);
|
||||
st++;
|
||||
width--;
|
||||
nch = _GETC_(file);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'n': {
|
||||
if (!suppress) {
|
||||
int*n = va_arg(ap, int*);
|
||||
*n = consumed - 1;
|
||||
}
|
||||
/* This is an odd one: according to the standard,
|
||||
* "Execution of a %n directive does not increment the
|
||||
* assignment count returned at the completion of
|
||||
* execution" even if it wasn't suppressed with the
|
||||
* '*' flag. The Corrigendum to the standard seems
|
||||
* to contradict this (comment out the assignment to
|
||||
* suppress below if you want to implement these
|
||||
* alternate semantics) but the windows program I'm
|
||||
* looking at expects the behavior I've coded here
|
||||
* (which happens to be what glibc does as well).
|
||||
*/
|
||||
suppress = 1;
|
||||
st = 1;
|
||||
}
|
||||
break;
|
||||
case '[': {
|
||||
_CHAR_ *str = suppress ? NULL : va_arg(ap, _CHAR_*);
|
||||
_CHAR_ *sptr = str;
|
||||
RTL_BITMAP bitMask;
|
||||
ULONG *Mask;
|
||||
int invert = 0; /* Set if we are NOT to find the chars */
|
||||
|
||||
/* Init our bitmap */
|
||||
#ifdef _LIBCNT_
|
||||
Mask = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, _BITMAPSIZE_/8);
|
||||
#else
|
||||
Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, _BITMAPSIZE_/8);
|
||||
#endif
|
||||
RtlInitializeBitMap(&bitMask, Mask, _BITMAPSIZE_);
|
||||
|
||||
/* Read the format */
|
||||
format++;
|
||||
if(*format == '^') {
|
||||
invert = 1;
|
||||
format++;
|
||||
}
|
||||
if(*format == ']') {
|
||||
RtlSetBits(&bitMask, ']', 1);
|
||||
format++;
|
||||
}
|
||||
while(*format && (*format != ']')) {
|
||||
/* According to msdn:
|
||||
* "Note that %[a-z] and %[z-a] are interpreted as equivalent to %[abcde...z]." */
|
||||
if((*format == '-') && (*(format + 1) != ']')) {
|
||||
if ((*(format - 1)) < *(format + 1))
|
||||
RtlSetBits(&bitMask, *(format - 1) +1 , *(format + 1) - *(format - 1));
|
||||
else
|
||||
RtlSetBits(&bitMask, *(format + 1) , *(format - 1) - *(format + 1));
|
||||
format++;
|
||||
} else
|
||||
RtlSetBits(&bitMask, *format, 1);
|
||||
format++;
|
||||
}
|
||||
/* read until char is not suitable */
|
||||
while ((width != 0) && (nch != _EOF_)) {
|
||||
if(!invert) {
|
||||
if(RtlAreBitsSet(&bitMask, nch, 1)) {
|
||||
if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch);
|
||||
} else
|
||||
break;
|
||||
} else {
|
||||
if(RtlAreBitsClear(&bitMask, nch, 1)) {
|
||||
if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
st++;
|
||||
nch = _GETC_(file);
|
||||
if (width>0) width--;
|
||||
}
|
||||
/* terminate */
|
||||
if (!suppress) *sptr = 0;
|
||||
#ifdef _LIBCNT_
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Mask);
|
||||
#else
|
||||
HeapFree(GetProcessHeap(), 0, Mask);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* From spec: "if a percent sign is followed by a character
|
||||
* that has no meaning as a format-control character, that
|
||||
* character and the following characters are treated as
|
||||
* an ordinary sequence of characters, that is, a sequence
|
||||
* of characters that must match the input. For example,
|
||||
* to specify that a percent-sign character is to be input,
|
||||
* use %%." */
|
||||
while ((nch!=_EOF_) && _ISSPACE_(nch))
|
||||
nch = _GETC_(file);
|
||||
if (nch==*format) {
|
||||
suppress = 1; /* whoops no field to be read */
|
||||
st = 1; /* but we got what we expected */
|
||||
nch = _GETC_(file);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (st && !suppress) rd++;
|
||||
else if (!st) break;
|
||||
}
|
||||
/* a non-white-space character causes scanf to read, but not store,
|
||||
* a matching non-white-space character. */
|
||||
else {
|
||||
/* check for character match */
|
||||
if (nch == *format) {
|
||||
nch = _GETC_(file);
|
||||
} else break;
|
||||
}
|
||||
format++;
|
||||
}
|
||||
if (nch!=_EOF_) {
|
||||
_UNGETC_(nch, file);
|
||||
}
|
||||
TRACE("returning %d\n", rd);
|
||||
return rd;
|
||||
}
|
||||
|
||||
#undef _CHAR_
|
||||
#undef _EOF_
|
||||
#undef _EOF_RET
|
||||
#undef _ISSPACE_
|
||||
#undef _ISDIGIT_
|
||||
#undef _CHAR2SUPPORTED_
|
||||
#undef _WIDE2SUPPORTED_
|
||||
#undef _CHAR2DIGIT_
|
||||
#undef _GETC_
|
||||
#undef _UNGETC_
|
||||
#undef _FUNCTION_
|
||||
#undef _BITMAPSIZE_
|
69
lib/sdk/crt/string/splitp.c
Normal file
69
lib/sdk/crt/string/splitp.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
#include <precomp.h>
|
||||
#include <tchar.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
void _tsplitpath(const _TCHAR* path, _TCHAR* drive, _TCHAR* dir, _TCHAR* fname, _TCHAR* ext)
|
||||
{
|
||||
_TCHAR* tmp_drive = NULL;
|
||||
_TCHAR* tmp_dir = NULL;
|
||||
_TCHAR* tmp_ext = NULL;
|
||||
|
||||
tmp_drive = (_TCHAR*)_tcschr(path,':');
|
||||
if (drive)
|
||||
{
|
||||
if (tmp_drive)
|
||||
{
|
||||
_tcsncpy(drive,tmp_drive-1,2);
|
||||
*(drive+2) = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*drive = 0;
|
||||
}
|
||||
}
|
||||
if (!tmp_drive)
|
||||
{
|
||||
tmp_drive = (_TCHAR*)path - 1;
|
||||
}
|
||||
|
||||
tmp_dir = (_TCHAR*)_tcsrchr(path,'\\');
|
||||
if (dir)
|
||||
{
|
||||
if (tmp_dir)
|
||||
{
|
||||
_tcsncpy(dir,tmp_drive+1,tmp_dir-tmp_drive);
|
||||
*(dir+(tmp_dir-tmp_drive)) = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dir =0;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the dot is before the last dir separator, it's part
|
||||
* of a directory name, not the start of the extension */
|
||||
if (!tmp_ext || tmp_ext < tmp_dir)
|
||||
{
|
||||
tmp_ext = (_TCHAR*)path+_tcslen(path);
|
||||
}
|
||||
if (ext)
|
||||
{
|
||||
_tcscpy(ext,tmp_ext);
|
||||
}
|
||||
|
||||
if (fname)
|
||||
{
|
||||
if (tmp_dir)
|
||||
{
|
||||
_tcsncpy(fname,tmp_dir+1,tmp_ext-tmp_dir-1);
|
||||
*(fname+(tmp_ext-tmp_dir-1)) = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_tcsncpy(fname,tmp_drive+1,tmp_ext-tmp_drive-1);
|
||||
*(fname+(tmp_ext-path))=0;
|
||||
}
|
||||
}
|
||||
}
|
7
lib/sdk/crt/string/strcat.c
Normal file
7
lib/sdk/crt/string/strcat.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "tcscat.h"
|
||||
|
||||
/* EOF */
|
8
lib/sdk/crt/string/strchr.c
Normal file
8
lib/sdk/crt/string/strchr.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _XINT int
|
||||
#include <string.h>
|
||||
#include "tcschr.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/strcmp.c
Normal file
7
lib/sdk/crt/string/strcmp.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "tcscmp.h"
|
||||
|
||||
/* EOF */
|
45
lib/sdk/crt/string/strcoll.c
Normal file
45
lib/sdk/crt/string/strcoll.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/* Compare S1 and S2, returning less than, equal to or
|
||||
greater than zero if the collated form of S1 is lexicographically
|
||||
less than, equal to or greater than the collated form of S2. */
|
||||
|
||||
#if 1
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
int strcoll(const char* s1, const char* s2)
|
||||
{
|
||||
return strcmp(s1, s2);
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
int _stricoll(const char* s1, const char* s2)
|
||||
{
|
||||
return _stricmp(s1, s2);
|
||||
}
|
||||
|
||||
#else
|
||||
int strcoll (const char* s1,const char* s2)
|
||||
{
|
||||
int ret;
|
||||
ret = CompareStringA(LOCALE_USER_DEFAULT,0,s1,strlen(s1),s2,strlen(s2));
|
||||
if (ret == 0)
|
||||
return 0;
|
||||
else
|
||||
return ret - 2;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
7
lib/sdk/crt/string/strcpy.c
Normal file
7
lib/sdk/crt/string/strcpy.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "tcscpy.h"
|
||||
|
||||
/* EOF */
|
9
lib/sdk/crt/string/strcspn.c
Normal file
9
lib/sdk/crt/string/strcspn.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _x(_X_) (_X_)
|
||||
#define _strxspn strcspn
|
||||
#include <string.h>
|
||||
#include "strxspn.h"
|
||||
|
||||
/* EOF */
|
17
lib/sdk/crt/string/strdup.c
Normal file
17
lib/sdk/crt/string/strdup.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *_strdup(const char *_s)
|
||||
{
|
||||
char *rv;
|
||||
if (_s == 0)
|
||||
return 0;
|
||||
rv = (char *)malloc(strlen(_s) + 1);
|
||||
if (rv == 0)
|
||||
return 0;
|
||||
strcpy(rv, _s);
|
||||
return rv;
|
||||
}
|
111
lib/sdk/crt/string/strerror.c
Normal file
111
lib/sdk/crt/string/strerror.c
Normal file
|
@ -0,0 +1,111 @@
|
|||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <precomp.h>
|
||||
|
||||
char __syserr00[] = "No Error";
|
||||
char __syserr01[] = "Operation not permitted (EPERM)";
|
||||
char __syserr02[] = "No such file or directory (ENOENT)";
|
||||
char __syserr03[] = "No such process (ESRCH)";
|
||||
char __syserr04[] = "Interrupted system call (EINTR)";
|
||||
char __syserr05[] = "Input or output error (EIO)";
|
||||
char __syserr06[] = "No such device or address (ENXIO)";
|
||||
char __syserr07[] = "Argument list too long (E2BIG)";
|
||||
char __syserr08[] = "Unable to execute file (ENOEXEC)";
|
||||
char __syserr09[] = "Bad file descriptor (EBADF)";
|
||||
char __syserr10[] = "No child processes (ECHILD)";
|
||||
char __syserr11[] = "Resource temporarily unavailable (EAGAIN)";
|
||||
char __syserr12[] = "Not enough memory (ENOMEM)";
|
||||
char __syserr13[] = "Permission denied (EACCES)";
|
||||
char __syserr14[] = "Bad address (EFAULT)";
|
||||
char __syserr15[] = "Unknown Error: 15";
|
||||
char __syserr16[] = "Resource busy (EBUSY)";
|
||||
char __syserr17[] = "File exists (EEXIST)";
|
||||
char __syserr18[] = "Improper link (EXDEV)";
|
||||
char __syserr19[] = "No such device (ENODEV)";
|
||||
char __syserr20[] = "Not a directory (ENOTDIR)";
|
||||
char __syserr21[] = "Is a directory (EISDIR)";
|
||||
char __syserr22[] = "Invalid argument (EINVAL)";
|
||||
char __syserr23[] = "Too many open files in system (ENFILE)";
|
||||
char __syserr24[] = "Too many open files (EMFILE)";
|
||||
char __syserr25[] = "Inappropriate I/O control operation (ENOTTY)";
|
||||
char __syserr26[] = "Unknown error: 26";
|
||||
char __syserr27[] = "File too large (EFBIG)";
|
||||
char __syserr28[] = "No space left on drive (ENOSPC)";
|
||||
char __syserr29[] = "Invalid seek (ESPIPE)";
|
||||
char __syserr30[] = "Read-only file system (EROFS)";
|
||||
char __syserr31[] = "Too many links (EMLINK)";
|
||||
char __syserr32[] = "Broken pipe (EPIPE)";
|
||||
char __syserr33[] = "Input to function out of range (EDOM)";
|
||||
char __syserr34[] = "Output of function out of range (ERANGE)";
|
||||
char __syserr35[] = "Unknown error: 35";
|
||||
char __syserr36[] = "Resource deadlock avoided (EDEADLK)";
|
||||
char __syserr37[] = "Unknown error: 37";
|
||||
char __syserr38[] = "File name too long (ENAMETOOLONG)";
|
||||
char __syserr39[] = "No locks available (ENOLCK)";
|
||||
char __syserr40[] = "Function not implemented (ENOSYS)";
|
||||
char __syserr41[] = "Directory not empty (ENOTEMPTY)";
|
||||
char __syserr42[] = "Illegal byte sequence (EILSEQ)";
|
||||
|
||||
|
||||
|
||||
|
||||
char *_sys_errlist[] = {
|
||||
__syserr00, __syserr01, __syserr02, __syserr03, __syserr04,
|
||||
__syserr05, __syserr06, __syserr07, __syserr08, __syserr09,
|
||||
__syserr10, __syserr11, __syserr12, __syserr13, __syserr14,
|
||||
__syserr15, __syserr16, __syserr17, __syserr18, __syserr19,
|
||||
__syserr20, __syserr21, __syserr22, __syserr23, __syserr24,
|
||||
__syserr25, __syserr26, __syserr27, __syserr28, __syserr29,
|
||||
__syserr30, __syserr31, __syserr32, __syserr33, __syserr34,
|
||||
__syserr35, __syserr36, __syserr37, __syserr38, __syserr39,
|
||||
__syserr40, __syserr41, __syserr42
|
||||
};
|
||||
|
||||
//int __sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]);
|
||||
|
||||
int/***/ _sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]);//&__sys_nerr;
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *strerror(int errnum)
|
||||
{
|
||||
static char ebuf[40]; /* 64-bit number + slop */
|
||||
char *cp;
|
||||
int v=1000000, lz=0;
|
||||
|
||||
if (errnum >= 0 && errnum < _sys_nerr)
|
||||
return((char *)_sys_errlist[errnum]);
|
||||
|
||||
strcpy(ebuf, "Unknown error: ");
|
||||
cp = ebuf + 15;
|
||||
if (errnum < 0)
|
||||
{
|
||||
*cp++ = '-';
|
||||
errnum = -errnum;
|
||||
}
|
||||
while (v)
|
||||
{
|
||||
int d = errnum / v;
|
||||
if (d || lz || (v == 1))
|
||||
{
|
||||
*cp++ = d+'0';
|
||||
lz = 1;
|
||||
}
|
||||
errnum %= v;
|
||||
v /= 10;
|
||||
}
|
||||
|
||||
return ebuf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *_strerror(const char *s)
|
||||
{
|
||||
if ( s == NULL )
|
||||
return strerror(*_errno());
|
||||
|
||||
return strerror(atoi(s));
|
||||
}
|
26
lib/sdk/crt/string/stricmp.c
Normal file
26
lib/sdk/crt/string/stricmp.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int
|
||||
_stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (toupper(*s1) == toupper(*s2))
|
||||
{
|
||||
if (*s1 == 0)
|
||||
return 0;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int
|
||||
_strcmpi(const char *s1, const char *s2)
|
||||
{
|
||||
return _stricmp(s1,s2);
|
||||
}
|
87
lib/sdk/crt/string/string.c
Normal file
87
lib/sdk/crt/string/string.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* PROJECT: ReactOS CRT library
|
||||
* LICENSE: LGPL - See COPYING in the top level directory
|
||||
* FILE: lib/sdk/crt/string/string.c
|
||||
* PURPOSE: string CRT functions
|
||||
* PROGRAMMERS: Wine team
|
||||
* Ported to ReactOS by Christoph von Wittich (christoph_vw@reactos.org)
|
||||
*/
|
||||
|
||||
/*
|
||||
* msvcrt.dll string functions
|
||||
*
|
||||
* Copyright 1996,1998 Marcus Meissner
|
||||
* Copyright 1996 Jukka Iivonen
|
||||
* Copyright 1997,2000 Uwe Bonnes
|
||||
* Copyright 2000 Jon Griffiths
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* strcat_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL strcat_s( char* dst, size_t elem, const char* src )
|
||||
{
|
||||
size_t i, j;
|
||||
if(!dst) return EINVAL;
|
||||
if(elem == 0) return EINVAL;
|
||||
if(!src)
|
||||
{
|
||||
dst[0] = '\0';
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
for(i = 0; i < elem; i++)
|
||||
{
|
||||
if(dst[i] == '\0')
|
||||
{
|
||||
for(j = 0; (j + i) < elem; j++)
|
||||
{
|
||||
if((dst[j + i] = src[j]) == '\0') return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Set the first element to 0, not the first element after the skipped part */
|
||||
dst[0] = '\0';
|
||||
return ERANGE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* strcpy_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL strcpy_s( char* dst, size_t elem, const char* src )
|
||||
{
|
||||
size_t i;
|
||||
if(!elem) return EINVAL;
|
||||
if(!dst) return EINVAL;
|
||||
if(!src)
|
||||
{
|
||||
dst[0] = '\0';
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
for(i = 0; i < elem; i++)
|
||||
{
|
||||
if((dst[i] = src[i]) == '\0') return 0;
|
||||
}
|
||||
dst[0] = '\0';
|
||||
return ERANGE;
|
||||
}
|
||||
|
7
lib/sdk/crt/string/strlen.c
Normal file
7
lib/sdk/crt/string/strlen.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "tcslen.h"
|
||||
|
||||
/* EOF */
|
16
lib/sdk/crt/string/strlwr.c
Normal file
16
lib/sdk/crt/string/strlwr.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char * _strlwr(char *x)
|
||||
{
|
||||
char *y=x;
|
||||
|
||||
while (*y) {
|
||||
*y=tolower(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
7
lib/sdk/crt/string/strncat.c
Normal file
7
lib/sdk/crt/string/strncat.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "tcsncat.h"
|
||||
|
||||
/* EOF */
|
7
lib/sdk/crt/string/strncmp.c
Normal file
7
lib/sdk/crt/string/strncmp.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "tcsncmp.h"
|
||||
|
||||
/* EOF */
|
23
lib/sdk/crt/string/strncoll.c
Normal file
23
lib/sdk/crt/string/strncoll.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <precomp.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Compare S1 and S2, returning less than, equal to or
|
||||
greater than zero if the collated form of S1 is lexicographically
|
||||
less than, equal to or greater than the collated form of S2. */
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
int _strncoll(const char* s1, const char* s2, size_t c)
|
||||
{
|
||||
return strncmp(s1, s2, c);
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
int _strnicoll(const char* s1, const char* s2, size_t c)
|
||||
{
|
||||
return _strnicmp(s1, s2, c);
|
||||
}
|
6
lib/sdk/crt/string/strncpy.c
Normal file
6
lib/sdk/crt/string/strncpy.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* $Id$
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "tcsncpy.h"
|
||||
|
||||
/* EOF */
|
18
lib/sdk/crt/string/strnicmp.c
Normal file
18
lib/sdk/crt/string/strnicmp.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _strnicmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
do {
|
||||
if (toupper(*s1) != toupper(*s2++))
|
||||
return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)--s2);
|
||||
if (*s1++ == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
return 0;
|
||||
}
|
7
lib/sdk/crt/string/strnlen.c
Normal file
7
lib/sdk/crt/string/strnlen.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "tcsnlen.h"
|
||||
|
||||
/* EOF */
|
54
lib/sdk/crt/string/strpbrk.c
Normal file
54
lib/sdk/crt/string/strpbrk.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* $Id$
|
||||
*/
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BIT_SIZE (CHAR_BIT * sizeof(unsigned long) / sizeof(char))
|
||||
|
||||
char* strpbrk(const char *s1, const char *s2)
|
||||
{
|
||||
if (*s2 == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (*(s2+1) == 0)
|
||||
{
|
||||
return strchr(s1, *s2);
|
||||
}
|
||||
else if (*(s2+2) == 0)
|
||||
{
|
||||
char *s3, *s4;
|
||||
s3 = strchr(s1, *s2);
|
||||
s4 = strchr(s1, *(s2+1));
|
||||
if (s3 == 0)
|
||||
{
|
||||
return s4;
|
||||
}
|
||||
else if (s4 == 0)
|
||||
{
|
||||
return s3;
|
||||
}
|
||||
return s3 < s4 ? s3 : s4;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long char_map[(1 << CHAR_BIT) / BIT_SIZE] = {0, };
|
||||
const unsigned char* str = (const unsigned char*)s1;
|
||||
while (*s2)
|
||||
{
|
||||
char_map[*(const unsigned char*)s2 / BIT_SIZE] |= (1 << (*(const unsigned char*)s2 % BIT_SIZE));
|
||||
s2++;
|
||||
}
|
||||
while (*str)
|
||||
{
|
||||
if (char_map[*str / BIT_SIZE] & (1 << (*str % BIT_SIZE)))
|
||||
{
|
||||
return (char*)((size_t)str);
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
8
lib/sdk/crt/string/strrchr.c
Normal file
8
lib/sdk/crt/string/strrchr.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _XINT int
|
||||
#include <string.h>
|
||||
#include "tcsrchr.h"
|
||||
|
||||
/* EOF */
|
32
lib/sdk/crt/string/strrev.c
Normal file
32
lib/sdk/crt/string/strrev.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char * _strrev(char *s)
|
||||
{
|
||||
char a, *b, *e;
|
||||
b=e=s;
|
||||
while (*e)
|
||||
e++;
|
||||
e--; /* start at last char, not NULL char */
|
||||
while ( b < e )
|
||||
{
|
||||
a=*b;
|
||||
*b=*e;
|
||||
*e=a;
|
||||
b++;
|
||||
e--;
|
||||
}
|
||||
return s; /* return ptr to beginning of string */
|
||||
}
|
51
lib/sdk/crt/string/strset.c
Normal file
51
lib/sdk/crt/string/strset.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/strset.c
|
||||
* PURPOSE: Implementation of _strnset and _strset
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#define __int64 long long
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
typedef unsigned __int64 size_t;
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char* _strnset(char* szToFill, int szFill, size_t sizeMaxFill)
|
||||
{
|
||||
char *t = szToFill;
|
||||
int i = 0;
|
||||
while (*szToFill != 0 && i < (int) sizeMaxFill)
|
||||
{
|
||||
*szToFill = szFill;
|
||||
szToFill++;
|
||||
i++;
|
||||
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char* _strset(char* szToFill, int szFill)
|
||||
{
|
||||
char *t = szToFill;
|
||||
while (*szToFill != 0)
|
||||
{
|
||||
*szToFill = szFill;
|
||||
szToFill++;
|
||||
|
||||
}
|
||||
return t;
|
||||
}
|
9
lib/sdk/crt/string/strspn.c
Normal file
9
lib/sdk/crt/string/strspn.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _x(_X_) (!(_X_))
|
||||
#define _strxspn strspn
|
||||
#include <string.h>
|
||||
#include "strxspn.h"
|
||||
|
||||
/* EOF */
|
33
lib/sdk/crt/string/strstr.c
Normal file
33
lib/sdk/crt/string/strstr.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *
|
||||
strstr(const char *s, const char *find)
|
||||
{
|
||||
char c, sc;
|
||||
size_t len;
|
||||
|
||||
if ((c = *find++) != 0)
|
||||
{
|
||||
len = strlen(find);
|
||||
do {
|
||||
do {
|
||||
if ((sc = *s++) == 0)
|
||||
return 0;
|
||||
} while (sc != c);
|
||||
} while (strncmp(s, find, len) != 0);
|
||||
s--;
|
||||
}
|
||||
return (char *)((size_t)s);
|
||||
}
|
103
lib/sdk/crt/string/strtod.c
Normal file
103
lib/sdk/crt/string/strtod.c
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
double
|
||||
strtod(const char *s, char **sret)
|
||||
{
|
||||
long double r; /* result */
|
||||
int e; /* exponent */
|
||||
long double d; /* scale */
|
||||
int sign; /* +- 1.0 */
|
||||
int esign;
|
||||
int i;
|
||||
int flags=0;
|
||||
|
||||
r = 0.0;
|
||||
sign = 1;
|
||||
e = 0;
|
||||
esign = 1;
|
||||
|
||||
if (s == NULL)
|
||||
return r;
|
||||
|
||||
|
||||
while ((*s == ' ') || (*s == '\t'))
|
||||
s++;
|
||||
|
||||
if (*s == '+')
|
||||
s++;
|
||||
else if (*s == '-')
|
||||
{
|
||||
sign = -1;
|
||||
s++;
|
||||
}
|
||||
|
||||
while ((*s >= '0') && (*s <= '9'))
|
||||
{
|
||||
flags |= 1;
|
||||
r *= 10.0;
|
||||
r += *s - '0';
|
||||
s++;
|
||||
}
|
||||
|
||||
if (*s == '.')
|
||||
{
|
||||
d = 0.1L;
|
||||
s++;
|
||||
while ((*s >= '0') && (*s <= '9'))
|
||||
{
|
||||
flags |= 2;
|
||||
r += d * (*s - '0');
|
||||
s++;
|
||||
d *= 0.1L;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags == 0)
|
||||
{
|
||||
if (sret)
|
||||
*sret = (char *)s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((*s == 'e') || (*s == 'E'))
|
||||
{
|
||||
s++;
|
||||
if (*s == '+')
|
||||
s++;
|
||||
else if (*s == '-')
|
||||
{
|
||||
s++;
|
||||
esign = -1;
|
||||
}
|
||||
if ((*s < '0') || (*s > '9'))
|
||||
{
|
||||
if (sret)
|
||||
*sret = (char *)s;
|
||||
return r;
|
||||
}
|
||||
|
||||
while ((*s >= '0') && (*s <= '9'))
|
||||
{
|
||||
e *= 10;
|
||||
e += *s - '0';
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
if (esign < 0)
|
||||
for (i = 1; i <= e; i++)
|
||||
r *= 0.1L;
|
||||
else
|
||||
for (i = 1; i <= e; i++)
|
||||
r *= 10.0;
|
||||
|
||||
if (sret)
|
||||
*sret = (char *)s;
|
||||
return r * sign;
|
||||
}
|
12
lib/sdk/crt/string/strtoi64.c
Normal file
12
lib/sdk/crt/string/strtoi64.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <precomp.h>
|
||||
|
||||
|
||||
__int64
|
||||
_strtoi64(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
TRACE("_strtoi64 is UNIMPLEMENTED\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
62
lib/sdk/crt/string/strtok.c
Normal file
62
lib/sdk/crt/string/strtok.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <precomp.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <internal/tls.h>
|
||||
|
||||
char** _lasttoken(); /* lasttok.c */
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char* strtok(char* s, const char* delim)
|
||||
{
|
||||
const char *spanp;
|
||||
int c, sc;
|
||||
char *tok;
|
||||
#if 1
|
||||
char ** lasttoken = _lasttoken();
|
||||
#else
|
||||
PTHREADDATA ThreadData = GetThreadData();
|
||||
char ** lasttoken = &ThreadData->lasttoken;
|
||||
#endif
|
||||
|
||||
if (s == NULL && (s = *lasttoken) == NULL)
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
|
||||
*/
|
||||
cont:
|
||||
c = *s++;
|
||||
for (spanp = delim; (sc = *spanp++) != 0;) {
|
||||
if (c == sc)
|
||||
goto cont;
|
||||
}
|
||||
|
||||
if (c == 0) { /* no non-delimiter characters */
|
||||
*lasttoken = NULL;
|
||||
return (NULL);
|
||||
}
|
||||
tok = s - 1;
|
||||
|
||||
/*
|
||||
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
|
||||
* Note that delim must have one NUL; we stop if we see that, too.
|
||||
*/
|
||||
for (;;) {
|
||||
c = *s++;
|
||||
spanp = delim;
|
||||
do {
|
||||
if ((sc = *spanp++) == c) {
|
||||
if (c == 0)
|
||||
s = NULL;
|
||||
else
|
||||
s[-1] = 0;
|
||||
*lasttoken = s;
|
||||
return (tok);
|
||||
}
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
91
lib/sdk/crt/string/strtol.c
Normal file
91
lib/sdk/crt/string/strtol.c
Normal file
|
@ -0,0 +1,91 @@
|
|||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
long
|
||||
strtol(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
* If base is 0, allow 0x for hex and 0 for octal, else
|
||||
* assume decimal; if base is already 16, allow 0x.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == '+')
|
||||
c = *s++;
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X'))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
|
||||
/*
|
||||
* 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)LONG_MIN : LONG_MAX;
|
||||
cutlim = cutoff % (unsigned long)base;
|
||||
cutoff /= (unsigned long)base;
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else
|
||||
{
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0)
|
||||
{
|
||||
acc = neg ? LONG_MIN : LONG_MAX;
|
||||
#ifndef _LIBCNT_
|
||||
__set_errno(ERANGE);
|
||||
#endif
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != 0)
|
||||
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
|
||||
return acc;
|
||||
}
|
125
lib/sdk/crt/string/strtold.c
Normal file
125
lib/sdk/crt/string/strtold.c
Normal file
|
@ -0,0 +1,125 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
|
||||
static double powten[] =
|
||||
{
|
||||
1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L,
|
||||
#ifdef __GNUC__
|
||||
1e512L, 1e512L*1e512L, 1e2048L, 1e4096L
|
||||
#else
|
||||
1e256L, 1e256L, 1e256L, 1e256L
|
||||
#endif
|
||||
};
|
||||
|
||||
long double
|
||||
_strtold(const char *s, char **sret)
|
||||
{
|
||||
double r; /* result */
|
||||
int e, ne; /* exponent */
|
||||
int sign; /* +- 1.0 */
|
||||
int esign;
|
||||
int flags=0;
|
||||
int l2powm1;
|
||||
|
||||
r = 0.0L;
|
||||
sign = 1;
|
||||
e = ne = 0;
|
||||
esign = 1;
|
||||
|
||||
while(*s && isspace(*s))
|
||||
s++;
|
||||
|
||||
if (*s == '+')
|
||||
s++;
|
||||
else if (*s == '-')
|
||||
{
|
||||
sign = -1;
|
||||
s++;
|
||||
}
|
||||
|
||||
while ((*s >= '0') && (*s <= '9'))
|
||||
{
|
||||
flags |= 1;
|
||||
r *= 10.0L;
|
||||
r += *s - '0';
|
||||
s++;
|
||||
}
|
||||
|
||||
if (*s == '.')
|
||||
{
|
||||
s++;
|
||||
while ((*s >= '0') && (*s <= '9'))
|
||||
{
|
||||
flags |= 2;
|
||||
r *= 10.0L;
|
||||
r += *s - '0';
|
||||
s++;
|
||||
ne++;
|
||||
}
|
||||
}
|
||||
if (flags == 0)
|
||||
{
|
||||
if (sret)
|
||||
*sret = (char *)s;
|
||||
return 0.0L;
|
||||
}
|
||||
|
||||
if ((*s == 'e') || (*s == 'E'))
|
||||
{
|
||||
s++;
|
||||
if (*s == '+')
|
||||
s++;
|
||||
else if (*s == '-')
|
||||
{
|
||||
s++;
|
||||
esign = -1;
|
||||
}
|
||||
while ((*s >= '0') && (*s <= '9'))
|
||||
{
|
||||
e *= 10;
|
||||
e += *s - '0';
|
||||
s++;
|
||||
}
|
||||
}
|
||||
if (esign < 0)
|
||||
{
|
||||
esign = -esign;
|
||||
e = -e;
|
||||
}
|
||||
e = e - ne;
|
||||
if (e < -4096)
|
||||
{
|
||||
/* possibly subnormal number, 10^e would overflow */
|
||||
r *= 1.0e-2048L;
|
||||
e += 2048;
|
||||
}
|
||||
if (e < 0)
|
||||
{
|
||||
e = -e;
|
||||
esign = -esign;
|
||||
}
|
||||
if (e >= 8192)
|
||||
e = 8191;
|
||||
if (e)
|
||||
{
|
||||
double d = 1.0L;
|
||||
l2powm1 = 0;
|
||||
while (e)
|
||||
{
|
||||
if (e & 1)
|
||||
d *= powten[l2powm1];
|
||||
e >>= 1;
|
||||
l2powm1++;
|
||||
}
|
||||
if (esign > 0)
|
||||
r *= d;
|
||||
else
|
||||
r /= d;
|
||||
}
|
||||
if (sret)
|
||||
*sret = (char *)s;
|
||||
return r * sign;
|
||||
|
||||
return 0;
|
||||
}
|
75
lib/sdk/crt/string/strtoul.c
Normal file
75
lib/sdk/crt/string/strtoul.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include <precomp.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/*
|
||||
* Convert a string to an unsigned long integer.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
unsigned long
|
||||
strtoul(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == '+')
|
||||
c = *s++;
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X'))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
|
||||
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0)
|
||||
{
|
||||
acc = ULONG_MAX;
|
||||
#ifndef _LIBCNT_
|
||||
__set_errno(ERANGE);
|
||||
#endif
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != 0)
|
||||
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
|
||||
return acc;
|
||||
}
|
63
lib/sdk/crt/string/strtoull.c
Normal file
63
lib/sdk/crt/string/strtoull.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include <precomp.h>
|
||||
|
||||
unsigned long long
|
||||
strtoull(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long long acc;
|
||||
int c;
|
||||
unsigned long long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == '+')
|
||||
c = *s++;
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X'))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
cutoff = (unsigned long long)ULLONG_MAX / (unsigned long long)base;
|
||||
cutlim = (unsigned long long)ULLONG_MAX % (unsigned long long)base;
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0)
|
||||
{
|
||||
acc = ULLONG_MAX;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != 0)
|
||||
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
|
||||
return acc;
|
||||
}
|
25
lib/sdk/crt/string/strupr.c
Normal file
25
lib/sdk/crt/string/strupr.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* The C RunTime DLL
|
||||
*
|
||||
* Implements C run-time functionality as known from UNIX.
|
||||
*
|
||||
* Copyright 1996,1998 Marcus Meissner
|
||||
* Copyright 1996 Jukka Iivonen
|
||||
* Copyright 1997 Uwe Bonnes
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *_strupr(char *x)
|
||||
{
|
||||
char *y=x;
|
||||
|
||||
while (*y) {
|
||||
*y=toupper(*y);
|
||||
y++;
|
||||
}
|
||||
return x;
|
||||
}
|
33
lib/sdk/crt/string/strxfrm.c
Normal file
33
lib/sdk/crt/string/strxfrm.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
#if 1
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
size_t strxfrm( char *dest, const char *src, size_t n )
|
||||
{
|
||||
strncpy(dest, src, n);
|
||||
return (strlen(dest));
|
||||
}
|
||||
#else
|
||||
size_t strxfrm( char *dest, const char *src, size_t n )
|
||||
{
|
||||
int ret = LCMapStringA(LOCALE_USER_DEFAULT,LCMAP_LOWERCASE,
|
||||
src, strlen(src), dest, strlen(dest));
|
||||
|
||||
if ( ret == 0 )
|
||||
return -1;
|
||||
return ret;
|
||||
|
||||
}
|
||||
#endif
|
24
lib/sdk/crt/string/strxspn.h
Normal file
24
lib/sdk/crt/string/strxspn.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
size_t _strxspn(const char *s1, const char *s2)
|
||||
{
|
||||
unsigned char char_map[1 << CHAR_BIT * sizeof(char)];
|
||||
const unsigned char * us2 = (const unsigned char *)s2;
|
||||
const unsigned char * str = (const unsigned char *)s1;
|
||||
|
||||
memset(char_map, 0, sizeof(char_map));
|
||||
|
||||
for(; *us2; ++ us2)
|
||||
char_map[*us2 / CHAR_BIT] |= (1 << (*us2 % CHAR_BIT));
|
||||
|
||||
for(; *str; ++ str)
|
||||
if(_x(char_map[*str / CHAR_BIT] & (1 << (*str % CHAR_BIT)))) break;
|
||||
|
||||
return (size_t)str - (size_t)s1;
|
||||
}
|
||||
|
||||
/* EOF */
|
17
lib/sdk/crt/string/tcscat.h
Normal file
17
lib/sdk/crt/string/tcscat.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
_TCHAR * _tcscat(_TCHAR * s, const _TCHAR * append)
|
||||
{
|
||||
_TCHAR * save = s;
|
||||
|
||||
for(; *s; ++s);
|
||||
|
||||
while((*s++ = *append++));
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
/* EOF */
|
22
lib/sdk/crt/string/tcschr.h
Normal file
22
lib/sdk/crt/string/tcschr.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
_TCHAR * _tcschr(const _TCHAR * s, _XINT c)
|
||||
{
|
||||
_TCHAR cc = c;
|
||||
|
||||
while(*s)
|
||||
{
|
||||
if(*s == cc) return (_TCHAR *)s;
|
||||
|
||||
s++;
|
||||
}
|
||||
|
||||
if(cc == 0) return (_TCHAR *)s;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
19
lib/sdk/crt/string/tcscmp.h
Normal file
19
lib/sdk/crt/string/tcscmp.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
int _tcscmp(const _TCHAR* s1, const _TCHAR* s2)
|
||||
{
|
||||
while(*s1 == *s2)
|
||||
{
|
||||
if(*s1 == 0) return 0;
|
||||
|
||||
s1 ++;
|
||||
s2 ++;
|
||||
}
|
||||
|
||||
return *s1 - *s2;
|
||||
}
|
||||
|
||||
/* EOF */
|
13
lib/sdk/crt/string/tcscpy.h
Normal file
13
lib/sdk/crt/string/tcscpy.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
_TCHAR * _tcscpy(_TCHAR * to, const _TCHAR * from)
|
||||
{
|
||||
_TCHAR *save = to;
|
||||
|
||||
for (; (*to = *from); ++from, ++to);
|
||||
|
||||
return save;
|
||||
}
|
18
lib/sdk/crt/string/tcslen.h
Normal file
18
lib/sdk/crt/string/tcslen.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <tchar.h>
|
||||
|
||||
size_t _tcslen(const _TCHAR * str)
|
||||
{
|
||||
const _TCHAR * s;
|
||||
|
||||
if(str == 0) return 0;
|
||||
|
||||
for(s = str; *s; ++ s);
|
||||
|
||||
return s - str;
|
||||
}
|
||||
|
||||
/* EOF */
|
30
lib/sdk/crt/string/tcsncat.h
Normal file
30
lib/sdk/crt/string/tcsncat.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <tchar.h>
|
||||
|
||||
_TCHAR * _tcsncat(_TCHAR * dst, const _TCHAR * src, size_t n)
|
||||
{
|
||||
if(n != 0)
|
||||
{
|
||||
_TCHAR * d = dst;
|
||||
const _TCHAR * s = src;
|
||||
|
||||
while(*d != 0) ++ d;
|
||||
|
||||
do
|
||||
{
|
||||
if((*d = *s++) == 0) break;
|
||||
|
||||
++ d;
|
||||
}
|
||||
while (--n != 0);
|
||||
|
||||
*d = 0;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/* EOF */
|
21
lib/sdk/crt/string/tcsncmp.h
Normal file
21
lib/sdk/crt/string/tcsncmp.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <tchar.h>
|
||||
|
||||
int _tcsncmp(const _TCHAR * s1, const _TCHAR * s2, size_t n)
|
||||
{
|
||||
if(n == 0) return 0;
|
||||
|
||||
do
|
||||
{
|
||||
if(*s1 != *s2 ++) return *s1 - *-- s2;
|
||||
if(*s1 ++ == 0) break;
|
||||
}
|
||||
while (-- n != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
28
lib/sdk/crt/string/tcsncpy.h
Normal file
28
lib/sdk/crt/string/tcsncpy.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <tchar.h>
|
||||
|
||||
_TCHAR * _tcsncpy(_TCHAR * dst, const _TCHAR * src, size_t n)
|
||||
{
|
||||
if(n != 0)
|
||||
{
|
||||
_TCHAR * d = dst;
|
||||
const _TCHAR * s = src;
|
||||
|
||||
do
|
||||
{
|
||||
if((*d ++ = *s ++) == 0)
|
||||
{
|
||||
while (-- n != 0) *d ++ = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(-- n != 0);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/* EOF */
|
18
lib/sdk/crt/string/tcsnlen.h
Normal file
18
lib/sdk/crt/string/tcsnlen.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <tchar.h>
|
||||
|
||||
size_t _tcsnlen(const _TCHAR * str, size_t count)
|
||||
{
|
||||
const _TCHAR * s;
|
||||
|
||||
if(str == 0) return 0;
|
||||
|
||||
for(s = str; *s && count; ++ s, -- count);
|
||||
|
||||
return s - str;
|
||||
}
|
||||
|
||||
/* EOF */
|
22
lib/sdk/crt/string/tcsrchr.h
Normal file
22
lib/sdk/crt/string/tcsrchr.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
_TCHAR * _tcsrchr(const _TCHAR * s, _XINT c)
|
||||
{
|
||||
_TCHAR cc = c;
|
||||
const _TCHAR * sp = (_TCHAR *)0;
|
||||
|
||||
while(*s)
|
||||
{
|
||||
if(*s == cc) sp = s;
|
||||
s ++;
|
||||
}
|
||||
|
||||
if(cc == 0) sp = s;
|
||||
|
||||
return (_TCHAR *)sp;
|
||||
}
|
||||
|
||||
/* EOF */
|
1200
lib/sdk/crt/string/wcs.c
Normal file
1200
lib/sdk/crt/string/wcs.c
Normal file
File diff suppressed because it is too large
Load diff
8
lib/sdk/crt/string/wcscat.c
Normal file
8
lib/sdk/crt/string/wcscat.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include <wchar.h>
|
||||
#include "tcscat.h"
|
||||
|
||||
/* EOF */
|
9
lib/sdk/crt/string/wcschr.c
Normal file
9
lib/sdk/crt/string/wcschr.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#define _XINT wchar_t
|
||||
#include <wchar.h>
|
||||
#include "tcschr.h"
|
||||
|
||||
/* EOF */
|
8
lib/sdk/crt/string/wcscmp.c
Normal file
8
lib/sdk/crt/string/wcscmp.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include <wchar.h>
|
||||
#include "tcscmp.h"
|
||||
|
||||
/* EOF */
|
8
lib/sdk/crt/string/wcscpy.c
Normal file
8
lib/sdk/crt/string/wcscpy.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include <wchar.h>
|
||||
#include "tcscpy.h"
|
||||
|
||||
/* EOF */
|
8
lib/sdk/crt/string/wcslen.c
Normal file
8
lib/sdk/crt/string/wcslen.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include <wchar.h>
|
||||
#include "tcslen.h"
|
||||
|
||||
/* EOF */
|
8
lib/sdk/crt/string/wcsncat.c
Normal file
8
lib/sdk/crt/string/wcsncat.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include <wchar.h>
|
||||
#include "tcsncat.h"
|
||||
|
||||
/* EOF */
|
8
lib/sdk/crt/string/wcsncmp.c
Normal file
8
lib/sdk/crt/string/wcsncmp.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include <wchar.h>
|
||||
#include "tcsncmp.h"
|
||||
|
||||
/* EOF */
|
8
lib/sdk/crt/string/wcsncpy.c
Normal file
8
lib/sdk/crt/string/wcsncpy.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include <wchar.h>
|
||||
#include "tcsncpy.h"
|
||||
|
||||
/* EOF */
|
8
lib/sdk/crt/string/wcsnlen.c
Normal file
8
lib/sdk/crt/string/wcsnlen.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#include <wchar.h>
|
||||
#include "tcsnlen.h"
|
||||
|
||||
/* EOF */
|
9
lib/sdk/crt/string/wcsrchr.c
Normal file
9
lib/sdk/crt/string/wcsrchr.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* $Id$
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#define _XINT wchar_t
|
||||
#include <wchar.h>
|
||||
#include "tcsrchr.h"
|
||||
|
||||
/* EOF */
|
100
lib/sdk/crt/string/wcstod.c
Normal file
100
lib/sdk/crt/string/wcstod.c
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
#if 0 //FIXME: Compare with wcstod in wcs.c
|
||||
double wcstod(const wchar_t *s, wchar_t **sret)
|
||||
{
|
||||
long double r; /* result */
|
||||
int e; /* exponent */
|
||||
long double d; /* scale */
|
||||
int sign; /* +- 1.0 */
|
||||
int esign;
|
||||
int i;
|
||||
int flags=0;
|
||||
|
||||
r = 0.0;
|
||||
sign = 1;
|
||||
e = 0;
|
||||
esign = 1;
|
||||
|
||||
while ((*s == L' ') || (*s == L'\t'))
|
||||
s++;
|
||||
|
||||
if (*s == L'+')
|
||||
s++;
|
||||
else if (*s == L'-')
|
||||
{
|
||||
sign = -1;
|
||||
s++;
|
||||
}
|
||||
|
||||
while ((*s >= L'0') && (*s <= L'9'))
|
||||
{
|
||||
flags |= 1;
|
||||
r *= 10.0;
|
||||
r += *s - L'0';
|
||||
s++;
|
||||
}
|
||||
|
||||
if (*s == L'.')
|
||||
{
|
||||
d = 0.1L;
|
||||
s++;
|
||||
while ((*s >= L'0') && (*s <= L'9'))
|
||||
{
|
||||
flags |= 2;
|
||||
r += d * (*s - L'0');
|
||||
s++;
|
||||
d *= 0.1L;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags == 0)
|
||||
{
|
||||
if (sret)
|
||||
*sret = (wchar_t *)s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((*s == L'e') || (*s == L'E'))
|
||||
{
|
||||
s++;
|
||||
if (*s == L'+')
|
||||
s++;
|
||||
else if (*s == L'-')
|
||||
{
|
||||
s++;
|
||||
esign = -1;
|
||||
}
|
||||
if ((*s < L'0') || (*s > L'9'))
|
||||
{
|
||||
if (sret)
|
||||
*sret = (wchar_t *)s;
|
||||
return r;
|
||||
}
|
||||
|
||||
while ((*s >= L'0') && (*s <= L'9'))
|
||||
{
|
||||
e *= 10;
|
||||
e += *s - L'0';
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
if (esign < 0)
|
||||
for (i = 1; i <= e; i++)
|
||||
r *= 0.1L;
|
||||
else
|
||||
for (i = 1; i <= e; i++)
|
||||
r *= 10.0;
|
||||
|
||||
if (sret)
|
||||
*sret = (wchar_t *)s;
|
||||
return r * sign;
|
||||
}
|
||||
#endif
|
97
lib/sdk/crt/string/wcstol.c
Normal file
97
lib/sdk/crt/string/wcstol.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
long
|
||||
wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
|
||||
{
|
||||
const wchar_t *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
* If base is 0, allow 0x for hex and 0 for octal, else
|
||||
* assume decimal; if base is already 16, allow 0x.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (iswctype(c, _SPACE));
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == L'+')
|
||||
c = *s++;
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == L'0' && (*s == L'x' || *s == L'X'))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == L'0' ? 8 : 10;
|
||||
|
||||
/*
|
||||
* 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)LONG_MIN : LONG_MAX;
|
||||
cutlim = cutoff % (unsigned long)base;
|
||||
cutoff /= (unsigned long)base;
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (iswctype(c, _DIGIT))
|
||||
c -= L'0';
|
||||
else if (iswctype(c, _ALPHA))
|
||||
c -= iswctype(c, _UPPER) ? L'A' - 10 : L'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else
|
||||
{
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0)
|
||||
{
|
||||
acc = neg ? LONG_MIN : LONG_MAX;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != 0)
|
||||
*endptr = any ? (wchar_t *)((size_t)(s - 1)) : (wchar_t *)((size_t)nptr);
|
||||
return acc;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue