tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: 16bit ctype table
On Tue, Sep 25, 2012 at 04:05:59PM +0000, Christos Zoulas wrote:
> In article <20120925133938.GA29951%britannica.bec.de@localhost>,
> Joerg Sonnenberger <joerg%britannica.bec.de@localhost> wrote:
> >>
> >> __BUILDOLDC might be better since __BUILDCOLD parses as __BUILD-COLD
> >
> >I didn't invent the name, I'm just going with what libc/Makefile already
> >uses.
>
> I meant it as a joke (dead and cold), and it was not exposed outside
> the Makefile. It is confusing...
Attached patch includes renaming it to BUILD_LEGACY.
Joerg
Index: external/gpl3/gcc/dist/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
===================================================================
RCS file:
/home/joerg/repo/netbsd/src/external/gpl3/gcc/dist/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h,v
retrieving revision 1.2
diff -u -p -r1.2 ctype_base.h
--- external/gpl3/gcc/dist/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
21 Jun 2011 02:41:39 -0000 1.2
+++ external/gpl3/gcc/dist/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
23 Sep 2012 22:40:16 -0000
@@ -41,18 +41,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
- typedef unsigned char mask;
+ typedef unsigned short mask;
static const mask upper = _CTYPE_U;
static const mask lower = _CTYPE_L;
- static const mask alpha = _CTYPE_U | _CTYPE_L;
+ static const mask alpha = _CTYPE_A;
static const mask digit = _CTYPE_N;
- static const mask xdigit = _CTYPE_N | _CTYPE_X;
+ static const mask xdigit = _CTYPE_X;
static const mask space = _CTYPE_S;
- static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N |
_CTYPE_B;
- static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N;
+ static const mask print = _CTYPE_R;
+ static const mask graph = _CTYPE_G;
static const mask cntrl = _CTYPE_C;
static const mask punct = _CTYPE_P;
- static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
+ static const mask alnum = _CTYPE_A | _CTYPE_N;
};
_GLIBCXX_END_NAMESPACE
Index:
external/gpl3/gcc/dist/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h
===================================================================
RCS file:
/home/joerg/repo/netbsd/src/external/gpl3/gcc/dist/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 ctype_noninline.h
--- external/gpl3/gcc/dist/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h
21 Jun 2011 01:24:50 -0000 1.1.1.1
+++ external/gpl3/gcc/dist/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h
23 Sep 2012 22:40:16 -0000
@@ -33,11 +33,11 @@
// Information as gleaned from /usr/include/ctype.h
- extern "C" const u_int8_t _C_ctype_[];
+ extern "C" const unsigned short _C_ctype2_[];
const ctype_base::mask*
ctype<char>::classic_table() throw()
- { return _C_ctype_ + 1; }
+ { return _C_ctype2_ + 1; }
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
Index: gnu/dist/gcc4/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
===================================================================
RCS file:
/home/joerg/repo/netbsd/src/gnu/dist/gcc4/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h,v
retrieving revision 1.2
diff -u -p -r1.2 ctype_base.h
--- gnu/dist/gcc4/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h 14 Dec
2010 02:28:57 -0000 1.2
+++ gnu/dist/gcc4/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h 23 Sep
2012 22:40:16 -0000
@@ -43,16 +43,16 @@
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
- typedef unsigned char mask;
+ typedef unsigned short mask;
static const mask upper = _CTYPE_U;
static const mask lower = _CTYPE_L;
- static const mask alpha = _CTYPE_U | _CTYPE_L;
+ static const mask alpha = _CTYPE_A;
static const mask digit = _CTYPE_N;
- static const mask xdigit = _CTYPE_N | _CTYPE_X;
+ static const mask xdigit = _CTYPE_X;
static const mask space = _CTYPE_S;
- static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N |
_CTYPE_B;
- static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N;
+ static const mask print = _CTYPE_R;
+ static const mask graph = _CTYPE_P;
static const mask cntrl = _CTYPE_C;
static const mask punct = _CTYPE_P;
- static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
+ static const mask alnum = _CTYPE_A | _CTYPE_N;
};
Index: gnu/dist/gcc4/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h
===================================================================
RCS file:
/home/joerg/repo/netbsd/src/gnu/dist/gcc4/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 ctype_noninline.h
--- gnu/dist/gcc4/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h 20 Apr
2006 10:16:24 -0000 1.1.1.1
+++ gnu/dist/gcc4/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h 23 Sep
2012 22:40:16 -0000
@@ -33,11 +33,11 @@
// Information as gleaned from /usr/include/ctype.h
- extern "C" const u_int8_t _C_ctype_[];
+ extern "C" const unsigned short _C_ctype2_[];
const ctype_base::mask*
ctype<char>::classic_table() throw()
- { return _C_ctype_ + 1; }
+ { return _C_ctype2_ + 1; }
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
Index: lib/libc/Makefile
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/Makefile,v
retrieving revision 1.149
diff -u -p -r1.149 Makefile
--- lib/libc/Makefile 20 Jan 2012 16:31:29 -0000 1.149
+++ lib/libc/Makefile 4 Oct 2012 20:15:46 -0000
@@ -42,12 +42,14 @@ assym.h: ${ARCHDIR}/genassym.cf
.endif
# The following controls how to build compatibility code for old NetBSD
-# binaries. If BUILDCOLD is yes, then we build a separate library; otherwise
+# binaries. If BUILD_LEGACY is yes, then we build a separate library; otherwise
# we include the code in libc.
-BUILDCOLD?= no
-.if "${BUILDCOLD}" == "yes"
+BUILD_LEGACY?= no
+.if "${BUILD_LEGACY}" == "yes"
SUBDIR=compat
.include <bsd.subdir.mk>
+# Marker for compat code that can't be easily isolated
+CPPFLAGS+= -D__BUILD_LEGACY
.else
COMPATDIR=${.CURDIR}/compat
.include "${.CURDIR}/compat/Makefile.inc"
Index: lib/libc/shlib_version
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/shlib_version,v
retrieving revision 1.235
diff -u -p -r1.235 shlib_version
--- lib/libc/shlib_version 24 Aug 2012 06:12:52 -0000 1.235
+++ lib/libc/shlib_version 4 Oct 2012 20:15:49 -0000
@@ -1,5 +1,7 @@
# $NetBSD: shlib_version,v 1.235 2012/08/24 06:12:52 dholland Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
+# things done by setting BUILD_LEGACY to be removed on next major version bump:
+# - drop _ctype_ and runetype_to_ctype.
#
# things we wish to do on next major version bump:
# - libc/net/rcmd.c: make __ivaliduser() and __ivaliduser_sa() static
@@ -28,9 +30,6 @@
# for example in assembler code.
# - kill sigcontext: never request version 0 or 1 signal trampoline.
# always request version 2 trampoline. (on vax, 3).
-# - change _ctype_ table in ctype.h and gen/ctype_.c 8bit -> 16 or 32bit.
-# it's insufficient bitwidth to implement all ctype class.
-# see isblank's comment in ctype.h.
# - remove gets(); it is finally dead in c11.
# - make __cerror (spelled CERROR) hidden again
# - remove ruserok() and friends to libcompat (or entirely)
Index: lib/libc/citrus/citrus_lc_ctype.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/citrus/citrus_lc_ctype.c,v
retrieving revision 1.10
diff -u -p -r1.10 citrus_lc_ctype.c
--- lib/libc/citrus/citrus_lc_ctype.c 4 Mar 2012 21:14:55 -0000 1.10
+++ lib/libc/citrus/citrus_lc_ctype.c 4 Oct 2012 20:15:54 -0000
@@ -103,7 +103,10 @@ _PREFIX(build_cache)(struct _locale_cach
_DIAGASSERT(cache->items != NULL);
_DIAGASSERT(data != NULL);
+#ifndef __BUILD_LEGACY
cache->ctype_tab = data->rl_ctype_tab;
+#endif
+ cache->ctype2_tab = data->rl_ctype2_tab;
cache->tolower_tab = data->rl_tolower_tab;
cache->toupper_tab = data->rl_toupper_tab;
cache->mb_cur_max = _citrus_ctype_get_mb_cur_max(data->rl_citrus_ctype);
@@ -116,7 +119,10 @@ _PREFIX(fixup)(_RuneLocale *data)
_DIAGASSERT(data != NULL);
__mb_cur_max = _citrus_ctype_get_mb_cur_max(data->rl_citrus_ctype);
+#ifndef __BUILD_LEGACY
_ctype_ = data->rl_ctype_tab;
+#endif
+ _ctype2_ = data->rl_ctype2_tab;
_tolower_tab_ = data->rl_tolower_tab;
_toupper_tab_ = data->rl_toupper_tab;
_CurrentRuneLocale = data;
Index: lib/libc/gen/ctype_.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/gen/ctype_.c,v
retrieving revision 1.19
diff -u -p -r1.19 ctype_.c
--- lib/libc/gen/ctype_.c 14 Dec 2010 02:28:57 -0000 1.19
+++ lib/libc/gen/ctype_.c 4 Oct 2012 20:15:57 -0000
@@ -51,15 +51,18 @@ __RCSID("$NetBSD: ctype_.c,v 1.19 2010/1
#error "EOF != -1"
#endif
-#define _U _CTYPE_U
-#define _L _CTYPE_L
-#define _N _CTYPE_N
-#define _S _CTYPE_S
-#define _P _CTYPE_P
-#define _C _CTYPE_C
-#define _X _CTYPE_X
-#define _B _CTYPE_B
+#ifndef __BUILD_LEGACY
+
+#define _U _COMPAT_CTYPE_U
+#define _L _COMPAT_CTYPE_L
+#define _N _COMPAT_CTYPE_N
+#define _S _COMPAT_CTYPE_S
+#define _P _COMPAT_CTYPE_P
+#define _C _COMPAT_CTYPE_C
+#define _X _COMPAT_CTYPE_X
+#define _B _COMPAT_CTYPE_B
+/* Note: this uses _B as printable and not graph, not as blank! */
const unsigned char _C_ctype_[1 + _CTYPE_NUM_CHARS] = {
0,
_C, _C, _C, _C, _C, _C, _C, _C,
@@ -81,3 +84,64 @@ const unsigned char _C_ctype_[1 + _CTYPE
};
const unsigned char *_ctype_ = &_C_ctype_[0];
+
+#undef _U
+#undef _L
+#undef _N
+#undef _S
+#undef _P
+#undef _C
+#undef _X
+#undef _B
+
+#endif /* __BUILD_LEGACY */
+
+#define _U _CTYPE_U
+#define _L _CTYPE_L
+#define _N _CTYPE_N
+#define _S _CTYPE_S
+#define _P _CTYPE_P
+#define _C _CTYPE_C
+#define _X _CTYPE_X
+#define _B _CTYPE_BL
+#define _R _CTYPE_R
+#define _G _CTYPE_G
+#define _A _CTYPE_A
+
+const unsigned short _C_ctype2_[1 + _CTYPE_NUM_CHARS] = {
+ 0,
+ _C, _C, _C, _C,
+ _C, _C, _C, _C,
+ _C, _S|_P|_C|_B, _S|_P|_C, _S|_P|_C,
+ _S|_P|_C, _S|_P|_C, _C, _C,
+ _C, _C, _C, _C,
+ _C, _C, _C, _C,
+ _C, _C, _C, _C,
+ _C, _C, _C, _C,
+ _S|_P|_B|_R, _G|_R, _G|_R, _G|_R,
+ _G|_R, _G|_R, _G|_R, _G|_R,
+ _G|_R, _G|_R, _G|_R, _G|_R,
+ _G|_R, _G|_R, _G|_R, _G|_R,
+ _N|_X|_G|_R, _N|_X|_G|_R, _N|_X|_G|_R, _N|_X|_G|_R,
+ _N|_X|_G|_R, _N|_X|_G|_R, _N|_X|_G|_R, _N|_X|_G|_R,
+ _N|_X|_G|_R, _N|_X|_G|_R, _G|_R, _G|_R,
+ _G|_R, _G|_R, _G|_R, _G|_R,
+ _G|_R, _U|_X|_A|_G|_R, _U|_X|_A|_G|_R, _U|_X|_A|_G|_R,
+ _U|_X|_A|_G|_R, _U|_X|_A|_G|_R, _U|_X|_A|_G|_R, _U|_A|_G|_R,
+ _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R,
+ _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R,
+ _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R,
+ _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R,
+ _U|_A|_G|_R, _U|_A|_G|_R, _U|_A|_G|_R, _G|_R,
+ _G|_R, _G|_R, _G|_R, _G|_R,
+ _G|_R, _L|_X|_A|_G|_R, _L|_X|_A|_G|_R, _L|_X|_A|_G|_R,
+ _L|_X|_A|_G|_R, _L|_X|_A|_G|_R, _L|_X|_A|_G|_R, _L|_A|_G|_R,
+ _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R,
+ _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R,
+ _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R,
+ _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R,
+ _L|_A|_G|_R, _L|_A|_G|_R, _L|_A|_G|_R, _G|_R,
+ _G|_R, _G|_R, _G|_R, _C,
+};
+
+const unsigned short *_ctype2_ = &_C_ctype2_[0];
Index: lib/libc/gen/isctype.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/gen/isctype.c,v
retrieving revision 1.21
diff -u -p -r1.21 isctype.c
--- lib/libc/gen/isctype.c 14 Dec 2010 02:28:57 -0000 1.21
+++ lib/libc/gen/isctype.c 23 Sep 2012 22:40:16 -0000
@@ -52,27 +52,21 @@ __RCSID("$NetBSD: isctype.c,v 1.21 2010/
int \
is##name(int c) \
{ \
- return (int)(_CTYPE_TAB(ctype_tab, c) & (bit)); \
+ return (int)(_CTYPE_TAB(ctype2_tab, c) & (bit)); \
}
-_ISCTYPE_FUNC(alnum, _CTYPE_U|_CTYPE_L|_CTYPE_N )
-_ISCTYPE_FUNC(alpha, _CTYPE_U|_CTYPE_L )
-_ISCTYPE_FUNC(cntrl, _CTYPE_C )
-_ISCTYPE_FUNC(digit, _CTYPE_N )
-_ISCTYPE_FUNC(graph, _CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N )
-_ISCTYPE_FUNC(lower, _CTYPE_L )
-_ISCTYPE_FUNC(print, _CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)
-_ISCTYPE_FUNC(punct, _CTYPE_P )
-_ISCTYPE_FUNC(space, _CTYPE_S )
-_ISCTYPE_FUNC(upper, _CTYPE_U )
-_ISCTYPE_FUNC(xdigit, _CTYPE_N|_CTYPE_X )
-
-int
-isblank(int c)
-{
- /* XXX: FIXME */
- return c == ' ' || c == '\t';
-}
+_ISCTYPE_FUNC(alnum, _CTYPE_A|_CTYPE_N)
+_ISCTYPE_FUNC(alpha, _CTYPE_A )
+_ISCTYPE_FUNC(blank, _CTYPE_BL )
+_ISCTYPE_FUNC(cntrl, _CTYPE_C )
+_ISCTYPE_FUNC(digit, _CTYPE_N )
+_ISCTYPE_FUNC(graph, _CTYPE_G )
+_ISCTYPE_FUNC(lower, _CTYPE_L )
+_ISCTYPE_FUNC(print, _CTYPE_R )
+_ISCTYPE_FUNC(punct, _CTYPE_P )
+_ISCTYPE_FUNC(space, _CTYPE_S )
+_ISCTYPE_FUNC(upper, _CTYPE_U )
+_ISCTYPE_FUNC(xdigit, _CTYPE_X )
int
toupper(int c)
Index: lib/libc/locale/ctype_local.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/ctype_local.h,v
retrieving revision 1.4
diff -u -p -r1.4 ctype_local.h
--- lib/libc/locale/ctype_local.h 13 Jun 2010 04:14:57 -0000 1.4
+++ lib/libc/locale/ctype_local.h 4 Oct 2012 20:16:00 -0000
@@ -33,7 +33,20 @@
#define _CTYPE_NUM_CHARS (1 << CHAR_BIT)
#define _CTYPE_CACHE_SIZE (1 << 8)
+#ifndef __BUILD_LEGACY
+#define _COMPAT_CTYPE_U 0x01
+#define _COMPAT_CTYPE_L 0x02
+#define _COMPAT_CTYPE_N 0x04
+#define _COMPAT_CTYPE_S 0x08
+#define _COMPAT_CTYPE_P 0x10
+#define _COMPAT_CTYPE_C 0x20
+#define _COMPAT_CTYPE_X 0x40
+#define _COMPAT_CTYPE_B 0x80
+
extern const unsigned char _C_ctype_[];
+#endif /* __BUILD_LEGACY */
+
+extern const unsigned short _C_ctype2_[];
extern const short _C_toupper_[];
extern const short _C_tolower_[];
Index: lib/libc/locale/global_locale.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/global_locale.c,v
retrieving revision 1.13
diff -u -p -r1.13 global_locale.c
--- lib/libc/locale/global_locale.c 21 Mar 2012 14:11:24 -0000 1.13
+++ lib/libc/locale/global_locale.c 4 Oct 2012 20:16:03 -0000
@@ -135,7 +135,10 @@ static const char *_global_items[(size_t
};
static struct _locale_cache_t _global_cache = {
+#ifndef __BUILD_LEGACY
.ctype_tab = (const unsigned char *)&_C_ctype_[0],
+#endif
+ .ctype2_tab = (const unsigned short *)&_C_ctype2_[0],
.tolower_tab = (const short *)&_C_tolower_[0],
.toupper_tab = (const short *)&_C_toupper_[0],
.mb_cur_max = (size_t)1,
Index: lib/libc/locale/rune.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/rune.c,v
retrieving revision 1.45
diff -u -p -r1.45 rune.c
--- lib/libc/locale/rune.c 8 Aug 2012 20:16:50 -0000 1.45
+++ lib/libc/locale/rune.c 4 Oct 2012 20:16:08 -0000
@@ -54,7 +54,10 @@
typedef struct {
_RuneLocale rl;
+#ifndef __BUILD_LEGACY
unsigned char rlp_ctype_tab [_CTYPE_NUM_CHARS + 1];
+#endif
+ unsigned short rlp_ctype2_tab [_CTYPE_NUM_CHARS + 1];
short rlp_tolower_tab[_CTYPE_NUM_CHARS + 1];
short rlp_toupper_tab[_CTYPE_NUM_CHARS + 1];
char rlp_codeset[33]; /* XXX */
@@ -85,16 +88,25 @@ _rune_init_priv(_RuneLocalePriv *rlp)
int i;
for (i = _CTYPE_CACHE_SIZE; i < _CTYPE_NUM_CHARS; ++i) {
+#ifndef __BUILD_LEGACY
rlp->rlp_ctype_tab [i + 1] = 0;
+#endif
+ rlp->rlp_ctype2_tab [i + 1] = 0;
rlp->rlp_tolower_tab[i + 1] = i;
rlp->rlp_toupper_tab[i + 1] = i;
}
#endif
+#ifndef __BUILD_LEGACY
rlp->rlp_ctype_tab [0] = 0;
+#endif
+ rlp->rlp_ctype2_tab [0] = 0;
rlp->rlp_tolower_tab[0] = EOF;
rlp->rlp_toupper_tab[0] = EOF;
+#ifndef __BUILD_LEGACY
rlp->rl.rl_ctype_tab = (const unsigned char *)&rlp->rlp_ctype_tab[0];
+#endif
+ rlp->rl.rl_ctype2_tab = (const unsigned short
*)&rlp->rlp_ctype2_tab[0];
rlp->rl.rl_tolower_tab = (const short *)&rlp->rlp_tolower_tab[0];
rlp->rl.rl_toupper_tab = (const short *)&rlp->rlp_toupper_tab[0];
rlp->rl.rl_codeset = (const char *)&rlp->rlp_codeset[0];
@@ -129,6 +141,35 @@ _rune_find_codeset(char *s, size_t n,
*s = '\0';
}
+#ifndef __BUILD_LEGACY
+static __inline int
+_runetype_to_ctype(_RuneType bits)
+{
+ int ret;
+
+ if (bits == (_RuneType)0)
+ return 0;
+ ret = 0;
+ if (bits & _RUNETYPE_U)
+ ret |= _COMPAT_CTYPE_U;
+ if (bits & _RUNETYPE_L)
+ ret |= _COMPAT_CTYPE_L;
+ if (bits & _RUNETYPE_D)
+ ret |= _COMPAT_CTYPE_N;
+ if (bits & _RUNETYPE_S)
+ ret |= _COMPAT_CTYPE_S;
+ if (bits & _RUNETYPE_P)
+ ret |= _COMPAT_CTYPE_P;
+ if (bits & _RUNETYPE_C)
+ ret |= _COMPAT_CTYPE_C;
+ if ((bits & (_RUNETYPE_X | _RUNETYPE_D)) == _RUNETYPE_X)
+ ret |= _COMPAT_CTYPE_X;
+ if ((bits & (_RUNETYPE_R | _RUNETYPE_G)) == _RUNETYPE_R)
+ ret |= _COMPAT_CTYPE_B;
+ return ret;
+}
+#endif /* __BUILD_LEGACY */
+
static __inline int
_rune_read_file(const char * __restrict var, size_t lenvar,
_RuneLocale ** __restrict prl)
@@ -247,12 +288,19 @@ do {
\
if (ret)
goto err;
if (wc == WEOF) {
+#ifndef __BUILD_LEGACY
rlp->rlp_ctype_tab[i + 1] = 0;
+#endif
+ rlp->rlp_ctype2_tab[i + 1] = 0;
rlp->rlp_tolower_tab[i + 1] = i;
rlp->rlp_toupper_tab[i + 1] = i;
} else {
- rlp->rlp_ctype_tab[i + 1] = (unsigned char)
+ rlp->rlp_ctype2_tab[i + 1] =
+ (unsigned short)(_runetype_priv(rl, wc) >> 8);
+#ifndef __BUILD_LEGACY
+ rlp->rlp_ctype_tab[i + 1] =
_runetype_to_ctype(_runetype_priv(rl, wc));
+#endif
#define CONVERT_MAP(name) \
do { \
Index: lib/libc/locale/runetable.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/runetable.c,v
retrieving revision 1.27
diff -u -p -r1.27 runetable.c
--- lib/libc/locale/runetable.c 19 Jun 2010 13:26:52 -0000 1.27
+++ lib/libc/locale/runetable.c 4 Oct 2012 20:16:11 -0000
@@ -343,7 +343,10 @@ const _RuneLocale _DefaultRuneLocale = {
{ "upper", _RUNETYPE_U },
{ "xdigit", _RUNETYPE_X },
},
+#ifndef __BUILD_LEGACY
_C_ctype_,
+#endif
+ _C_ctype2_,
_C_tolower_,
_C_toupper_
};
Index: lib/libc/locale/runetype_local.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/runetype_local.h,v
retrieving revision 1.12
diff -u -p -r1.12 runetype_local.h
--- lib/libc/locale/runetype_local.h 20 Jun 2010 02:23:15 -0000 1.12
+++ lib/libc/locale/runetype_local.h 4 Oct 2012 20:16:14 -0000
@@ -38,11 +38,11 @@
#ifndef _RUNETYPE_LOCAL_H_
#define _RUNETYPE_LOCAL_H_
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
-#include "runetype_misc.h"
+#include <sys/ctype_bits.h>
+#include "runetype_file.h"
#define _RUNE_ISCACHED(c) ((c)>=0 && (c)<_CTYPE_CACHE_SIZE)
@@ -123,7 +123,10 @@ typedef struct _RuneLocale {
_WCTransEntry rl_wctrans[_WCTRANS_NINDEXES];
_WCTypeEntry rl_wctype[_WCTYPE_NINDEXES];
+#ifndef __BUILD_LEGACY
const unsigned char *rl_ctype_tab;
+#endif
+ const unsigned short *rl_ctype2_tab;
const short *rl_tolower_tab;
const short *rl_toupper_tab;
} _RuneLocale;
Index: lib/libc/locale/runetype_misc.h
===================================================================
RCS file: lib/libc/locale/runetype_misc.h
diff -N lib/libc/locale/runetype_misc.h
--- lib/libc/locale/runetype_misc.h 18 Jan 2012 14:22:27 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-/* $NetBSD: runetype_misc.h,v 1.3 2012/01/18 14:22:27 joerg Exp $ */
-
-/*-
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Paul Borman at Krystal Technologies.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)runetype.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _RUNETYPE_MISC_H_
-#define _RUNETYPE_MISC_H_
-
-#include <sys/ctype_bits.h>
-#include "runetype_file.h"
-
-static __inline int
-_runetype_to_ctype(_RuneType bits)
-{
- int ret;
-
- if (bits == (_RuneType)0)
- return 0;
- ret = 0;
- if (bits & _RUNETYPE_U)
- ret |= _CTYPE_U;
- if (bits & _RUNETYPE_L)
- ret |= _CTYPE_L;
- if (bits & _RUNETYPE_D)
- ret |= _CTYPE_N;
- if (bits & _RUNETYPE_S)
- ret |= _CTYPE_S;
- if (bits & _RUNETYPE_P)
- ret |= _CTYPE_P;
- if (bits & _RUNETYPE_C)
- ret |= _CTYPE_C;
- if (bits & _RUNETYPE_X)
- ret |= _CTYPE_X;
- /*
- * TWEAK! _B has been used incorrectly (or with older
- * declaration) in ctype.h isprint() macro.
- * _B does not mean isblank, it means "isprint && !isgraph".
- * the following is okay since isblank() was hardcoded in
- * function (i.e. isblank() is inherently locale unfriendly).
- */
-#if 1
- if ((bits & (_RUNETYPE_R | _RUNETYPE_G)) == _RUNETYPE_R)
- ret |= _CTYPE_B;
-#else
- if (bits & _RUNETYPE_B)
- ret |= _CTYPE_B;
-#endif
- return ret;
-}
-
-#endif /* !_RUNETYPE_MISC_H_ */
Index: lib/libc/locale/setlocale_local.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/locale/setlocale_local.h,v
retrieving revision 1.8
diff -u -p -r1.8 setlocale_local.h
--- lib/libc/locale/setlocale_local.h 4 Mar 2012 21:14:57 -0000 1.8
+++ lib/libc/locale/setlocale_local.h 4 Oct 2012 20:16:16 -0000
@@ -40,7 +40,10 @@ extern const char *_PathLocale;
typedef void *_locale_part_t;
struct _locale_cache_t {
+#ifndef __BUILD_LEGACY
const unsigned char *ctype_tab;
+#endif
+ const unsigned short *ctype2_tab;
const short *tolower_tab;
const short *toupper_tab;
size_t mb_cur_max;
Index: libexec/ld.elf_so/rtld.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/libexec/ld.elf_so/rtld.c,v
retrieving revision 1.159
diff -u -p -r1.159 rtld.c
--- libexec/ld.elf_so/rtld.c 1 Oct 2012 03:03:46 -0000 1.159
+++ libexec/ld.elf_so/rtld.c 4 Oct 2012 18:08:19 -0000
@@ -447,7 +447,7 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
dbg(("got is at %p, dynamic is at %p", _GLOBAL_OFFSET_TABLE_,
&_DYNAMIC));
#endif
- dbg(("_ctype_ is %p", _ctype_));
+ dbg(("_ctype2_ is %p", _ctype2_));
#endif
sp += 2; /* skip over return argument space */
Index: sys/sys/ctype_bits.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/sys/ctype_bits.h,v
retrieving revision 1.2
diff -u -p -r1.2 ctype_bits.h
--- sys/sys/ctype_bits.h 14 Dec 2010 02:28:57 -0000 1.2
+++ sys/sys/ctype_bits.h 4 Oct 2012 20:16:30 -0000
@@ -40,16 +40,22 @@
#ifndef _SYS_CTYPE_BITS_H_
#define _SYS_CTYPE_BITS_H_
-#define _CTYPE_U 0x01
-#define _CTYPE_L 0x02
-#define _CTYPE_N 0x04
-#define _CTYPE_S 0x08
-#define _CTYPE_P 0x10
-#define _CTYPE_C 0x20
-#define _CTYPE_X 0x40
-#define _CTYPE_B 0x80
+#define _CTYPE_A 0x0001 /* Alpha */
+#define _CTYPE_C 0x0002 /* Control */
+#define _CTYPE_N 0x0004 /* Digit */
+#define _CTYPE_G 0x0008 /* Graph */
+#define _CTYPE_L 0x0010 /* Lower */
+#define _CTYPE_P 0x0020 /* Punct */
+#define _CTYPE_S 0x0040 /* Space */
+#define _CTYPE_U 0x0080 /* Upper */
+#define _CTYPE_X 0x0100 /* X digit */
+#define _CTYPE_BL 0x0200 /* Blank */
+#define _CTYPE_R 0x0400 /* Print */
+#ifndef __BUILD_LEGACY
extern const unsigned char *_ctype_;
+#endif
+extern const unsigned short *_ctype2_;
extern const short *_tolower_tab_;
extern const short *_toupper_tab_;
Index: sys/sys/ctype_inline.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/sys/ctype_inline.h,v
retrieving revision 1.2
diff -u -p -r1.2 ctype_inline.h
--- sys/sys/ctype_inline.h 14 Dec 2010 02:28:57 -0000 1.2
+++ sys/sys/ctype_inline.h 23 Sep 2012 22:40:16 -0000
@@ -45,20 +45,25 @@
#include <sys/ctype_bits.h>
-#define isdigit(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_N))
-#define islower(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_L))
-#define isspace(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_S))
-#define ispunct(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_P))
-#define isupper(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_U))
-#define isalpha(c) ((int)((_ctype_ + 1)[(c)] &
(_CTYPE_U|_CTYPE_L)))
-#define isxdigit(c) ((int)((_ctype_ + 1)[(c)] &
(_CTYPE_N|_CTYPE_X)))
-#define isalnum(c) ((int)((_ctype_ + 1)[(c)] &
(_CTYPE_U|_CTYPE_L|_CTYPE_N)))
-#define isprint(c) ((int)((_ctype_ + 1)[(c)] &
(_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)))
-#define isgraph(c) ((int)((_ctype_ + 1)[(c)] &
(_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N)))
-#define iscntrl(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_C))
+#define isdigit(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_N))
+#define islower(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_L))
+#define isspace(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_S))
+#define ispunct(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_P))
+#define isupper(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_U))
+#define isalpha(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_A))
+#define isxdigit(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_X))
+#define isalnum(c) ((int)((_ctype2_ + 1)[(c)] &
(_CTYPE_A|_CTYPE_N)))
+#define isprint(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_R))
+#define isgraph(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_G))
+#define iscntrl(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_C))
#define tolower(c) ((int)((_tolower_tab_ + 1)[(c)]))
#define toupper(c) ((int)((_toupper_tab_ + 1)[(c)]))
+#if defined(_ISO_C99_SOURCE) || (_POSIX_C_SOURCE - 0) > 200112L || \
+ (_XOPEN_SOURCE - 0) > 600 || defined(_NETBSD_SOURCE)
+#define isblank(c) ((int)((_ctype2_ + 1)[(c)] & _CTYPE_BL))
+#endif
+
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
#define isascii(c) ((unsigned)(c) <= 0177)
#define toascii(c) ((c) & 0177)
@@ -66,17 +71,4 @@
#define _toupper(c) ((c) - 'a' + 'A')
#endif
-#if defined(_ISO_C99_SOURCE) || (_POSIX_C_SOURCE - 0) > 200112L || \
- (_XOPEN_SOURCE - 0) > 600 || defined(_NETBSD_SOURCE)
-
-/*
- * isblank() is implemented as C function, due to insufficient bitwidth in
- * _ctype_. Note that _B does not mean isblank - it means isprint && !isgraph.
- */
-#if 0
-#define isblank(c) ((int)((_ctype_ + 1)[(c)] & _B))
-#endif
-
-#endif
-
#endif /* !_CTYPE_INLINE_H_ */
Home |
Main Index |
Thread Index |
Old Index