2001-06-11 Egor Duda <deo@logos-m.ru>
* libc/ctype/ctype_.c: When compiled with gcc on platforms with signed char, make _ctype_[-128] ... _ctype[-1] refer to initialized memory region. Platform can define COMPACT_CTYPE to avoid allocation of the additional 128 bytes of data. Add pointer to _ctype_ array. Always initialize all _ctype_ array elements.
This commit is contained in:
@ -37,26 +37,72 @@ static char sccsid[] = "@(#)ctype_.c 5.6 (Berkeley) 6/1/90";
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define _CTYPE_DATA_0_127 \
|
||||
_C, _C, _C, _C, _C, _C, _C, _C, \
|
||||
_C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, \
|
||||
_C, _C, _C, _C, _C, _C, _C, _C, \
|
||||
_C, _C, _C, _C, _C, _C, _C, _C, \
|
||||
_S|_B, _P, _P, _P, _P, _P, _P, _P, \
|
||||
_P, _P, _P, _P, _P, _P, _P, _P, \
|
||||
_N, _N, _N, _N, _N, _N, _N, _N, \
|
||||
_N, _N, _P, _P, _P, _P, _P, _P, \
|
||||
_P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, \
|
||||
_U, _U, _U, _U, _U, _U, _U, _U, \
|
||||
_U, _U, _U, _U, _U, _U, _U, _U, \
|
||||
_U, _U, _U, _P, _P, _P, _P, _P, \
|
||||
_P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, \
|
||||
_L, _L, _L, _L, _L, _L, _L, _L, \
|
||||
_L, _L, _L, _L, _L, _L, _L, _L, \
|
||||
_L, _L, _L, _P, _P, _P, _P, _C
|
||||
|
||||
#define _CTYPE_DATA_128_256 \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
|
||||
#if defined(__GNUC__) && !defined(__CHAR_UNSIGNED__) && !defined(COMPACT_CTYPE)
|
||||
#define ALLOW_NEGATIVE_CTYPE_INDEX
|
||||
#endif
|
||||
|
||||
#if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
|
||||
static _CONST char _ctype_b[128 + 256] = {
|
||||
_CTYPE_DATA_128_256,
|
||||
_CTYPE_DATA_0_127,
|
||||
_CTYPE_DATA_128_256
|
||||
};
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__CYGWIN32__)
|
||||
extern _CONST char __declspec(dllexport) _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127")));
|
||||
_CONST char __declspec(dllexport) *__ctype_ptr = _ctype_b + 128;
|
||||
#else
|
||||
extern _CONST char _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127")));
|
||||
_CONST char *__ctype_ptr = _ctype_b + 128;
|
||||
#endif
|
||||
|
||||
#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__CYGWIN32__)
|
||||
_CONST char __declspec(dllexport) _ctype_[1 + 256] = {
|
||||
#else
|
||||
_CONST char _ctype_[1 + 256] = {
|
||||
#endif
|
||||
0,
|
||||
_C, _C, _C, _C, _C, _C, _C, _C,
|
||||
_C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C,
|
||||
_C, _C, _C, _C, _C, _C, _C, _C,
|
||||
_C, _C, _C, _C, _C, _C, _C, _C,
|
||||
_S|_B, _P, _P, _P, _P, _P, _P, _P,
|
||||
_P, _P, _P, _P, _P, _P, _P, _P,
|
||||
_N, _N, _N, _N, _N, _N, _N, _N,
|
||||
_N, _N, _P, _P, _P, _P, _P, _P,
|
||||
_P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
|
||||
_U, _U, _U, _U, _U, _U, _U, _U,
|
||||
_U, _U, _U, _U, _U, _U, _U, _U,
|
||||
_U, _U, _U, _P, _P, _P, _P, _P,
|
||||
_P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
|
||||
_L, _L, _L, _L, _L, _L, _L, _L,
|
||||
_L, _L, _L, _L, _L, _L, _L, _L,
|
||||
_L, _L, _L, _P, _P, _P, _P, _C
|
||||
_CTYPE_DATA_0_127,
|
||||
_CTYPE_DATA_128_256
|
||||
};
|
||||
|
||||
_CONST char *__ctype_ptr = _ctype_ + 1;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user