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:
Jeff Johnston 2001-06-11 19:25:59 +00:00
parent 13a01ce06a
commit 371b76ef3e
2 changed files with 71 additions and 16 deletions

View File

@ -1,3 +1,12 @@
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.
2001-06-08 Jonathan Larmour <jlarmour@redhat.com>
* libc/stdlib/mbtowc_r.c (_mbtowc_r): Avoid dereferencing

View File

@ -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