aboutsummaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2001-06-11 19:25:59 +0000
committerJeff Johnston <jjohnstn@redhat.com>2001-06-11 19:25:59 +0000
commit371b76ef3e221248c7df49906014037c66292901 (patch)
treef6f631ae0352a0efa1fa873e703e4dccca6a9b9e /newlib
parent13a01ce06a38f291e2221eabf2a2330c3c50a0b7 (diff)
downloadnewlib-371b76ef3e221248c7df49906014037c66292901.zip
newlib-371b76ef3e221248c7df49906014037c66292901.tar.gz
newlib-371b76ef3e221248c7df49906014037c66292901.tar.bz2
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.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog9
-rw-r--r--newlib/libc/ctype/ctype_.c78
2 files changed, 71 insertions, 16 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 81b62e4..c568283 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -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
diff --git a/newlib/libc/ctype/ctype_.c b/newlib/libc/ctype/ctype_.c
index 45fcaa7..90a1694 100644
--- a/newlib/libc/ctype/ctype_.c
+++ b/newlib/libc/ctype/ctype_.c
@@ -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