Extend ctype classification table to 16bit. Based on patch by

Takehiko Nozaki, with changes to compile fail when using the old names
and to exploit __BUILD_LEGACY
This commit is contained in:
joerg 2013-04-13 10:21:20 +00:00
parent 71e4dd8871
commit e8fa8f4db7
17 changed files with 263 additions and 189 deletions

View File

@ -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 digit = _CTYPE_N;
static const mask xdigit = _CTYPE_N | _CTYPE_X;
static const mask alpha = _CTYPE_A;
static const mask digit = _CTYPE_D;
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_D;
};
_GLIBCXX_END_NAMESPACE

View File

@ -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_ctype_tab_[];
const ctype_base::mask*
ctype<char>::classic_table() throw()
{ return _C_ctype_ + 1; }
{ return _C_ctype_tab_ + 1; }
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)

View File

@ -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 digit = _CTYPE_N;
static const mask xdigit = _CTYPE_N | _CTYPE_X;
static const mask alpha = _CTYPE_A;
static const mask digit = _CTYPE_D;
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_D;
};

View File

@ -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_ctype_tab_[];
const ctype_base::mask*
ctype<char>::classic_table() throw()
{ return _C_ctype_ + 1; }
{ return _C_ctype_tab_ + 1; }
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)

View File

@ -1,4 +1,4 @@
/* $NetBSD: citrus_lc_ctype.c,v 1.10 2012/03/04 21:14:55 tnozaki Exp $ */
/* $NetBSD: citrus_lc_ctype.c,v 1.11 2013/04/13 10:21:20 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.10 2012/03/04 21:14:55 tnozaki Exp $");
__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.11 2013/04/13 10:21:20 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
@ -108,6 +108,10 @@ _PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
cache->toupper_tab = data->rl_toupper_tab;
cache->mb_cur_max = _citrus_ctype_get_mb_cur_max(data->rl_citrus_ctype);
cache->items[(size_t)CODESET] = data->rl_codeset;
#ifdef __BUILD_LEGACY
cache->compat_bsdctype = data->rl_compat_bsdctype;
#endif
}
static __inline void
@ -116,10 +120,14 @@ _PREFIX(fixup)(_RuneLocale *data)
_DIAGASSERT(data != NULL);
__mb_cur_max = _citrus_ctype_get_mb_cur_max(data->rl_citrus_ctype);
_ctype_ = data->rl_ctype_tab;
_ctype_tab_ = data->rl_ctype_tab;
_tolower_tab_ = data->rl_tolower_tab;
_toupper_tab_ = data->rl_toupper_tab;
_CurrentRuneLocale = data;
#ifdef __BUILD_LEGACY
_ctype_ = data->rl_compat_bsdctype;
#endif
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctype_.c,v 1.19 2010/12/14 02:28:57 joerg Exp $ */
/* $NetBSD: ctype_.c,v 1.20 2013/04/13 10:21:20 joerg Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@ -39,7 +39,7 @@
#if 0
/*static char *sccsid = "from: @(#)ctype_.c 5.6 (Berkeley) 6/1/90";*/
#else
__RCSID("$NetBSD: ctype_.c,v 1.19 2010/12/14 02:28:57 joerg Exp $");
__RCSID("$NetBSD: ctype_.c,v 1.20 2013/04/13 10:21:20 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -51,16 +51,17 @@ __RCSID("$NetBSD: ctype_.c,v 1.19 2010/12/14 02:28:57 joerg Exp $");
#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
#ifdef __BUILD_LEGACY
#define _C _COMPAT_C
#define _S _COMPAT_S
#define _U _COMPAT_U
#define _X _COMPAT_X
#define _L _COMPAT_L
#define _P _COMPAT_P
#define _B _COMPAT_B
#define _N _COMPAT_N
const unsigned char _C_ctype_[1 + _CTYPE_NUM_CHARS] = {
const unsigned char _C_compat_bsdctype[1 + _CTYPE_NUM_CHARS] = {
0,
_C, _C, _C, _C, _C, _C, _C, _C,
_C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C,
@ -80,4 +81,80 @@ const unsigned char _C_ctype_[1 + _CTYPE_NUM_CHARS] = {
_L, _L, _L, _P, _P, _P, _P, _C
};
const unsigned char *_ctype_ = &_C_ctype_[0];
#undef _C
#undef _S
#undef _U
#undef _X
#undef _L
#undef _P
#undef _B
#undef _N
#ifdef __weak_alias
__weak_alias(_C_ctype_, _C_compat_bsdctype)
#endif
const unsigned char *_ctype_ = &_C_compat_bsdctype[0];
#endif /* __BUILD_LEGACY */
#define _A _CTYPE_A
#define _BL _CTYPE_BL
#define _C _CTYPE_C
#define _D _CTYPE_D
#define _G _CTYPE_G
#define _L _CTYPE_L
#define _P _CTYPE_P
#define _R _CTYPE_R
#define _S _CTYPE_S
#define _U _CTYPE_U
#define _X _CTYPE_X
const unsigned short _C_ctype_tab_[1 + _CTYPE_NUM_CHARS] = {
0,
_C, _C, _C, _C,
_C, _C, _C, _C,
_C, _BL|_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,
_BL|_R|_S, _G|_R|_P, _G|_R|_P, _G|_R|_P,
_G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P,
_G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P,
_G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P,
_D|_G|_R|_X, _D|_G|_R|_X, _D|_G|_R|_X, _D|_G|_R|_X,
_D|_G|_R|_X, _D|_G|_R|_X, _D|_G|_R|_X, _D|_G|_R|_X,
_D|_G|_R|_X, _D|_G|_R|_X, _G|_R|_P, _G|_R|_P,
_G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P,
_G|_R|_P, _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|_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, _G|_R|_P,
_G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P,
_G|_R|_P, _A|_G|_L|_R|_X, _A|_G|_L|_R|_X, _A|_G|_L|_R|_X,
_A|_G|_L|_R|_X, _A|_G|_L|_R|_X, _A|_G|_L|_R|_X, _A|_G|_L|_R,
_A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R,
_A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R,
_A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R,
_A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R,
_A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _G|_R|_P,
_G|_R|_P, _G|_R|_P, _G|_R|_P, _C,
};
#undef _A
#undef _BL
#undef _C
#undef _D
#undef _G
#undef _L
#undef _P
#undef _R
#undef _S
#undef _U
#undef _X
const unsigned short *_ctype_tab_ = &_C_ctype_tab_[0];

View File

@ -1,4 +1,4 @@
/* $NetBSD: isctype.c,v 1.21 2010/12/14 02:28:57 joerg Exp $ */
/* $NetBSD: isctype.c,v 1.22 2013/04/13 10:21:20 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: isctype.c,v 1.21 2010/12/14 02:28:57 joerg Exp $");
__RCSID("$NetBSD: isctype.c,v 1.22 2013/04/13 10:21:20 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -55,24 +55,18 @@ is##name(int c) \
return (int)(_CTYPE_TAB(ctype_tab, c) & (bit)); \
}
_ISCTYPE_FUNC(alnum, _CTYPE_U|_CTYPE_L|_CTYPE_N )
_ISCTYPE_FUNC(alpha, _CTYPE_U|_CTYPE_L )
_ISCTYPE_FUNC(alnum, (_CTYPE_A|_CTYPE_D))
_ISCTYPE_FUNC(alpha, _CTYPE_A)
_ISCTYPE_FUNC(blank, _CTYPE_BL)
_ISCTYPE_FUNC(cntrl, _CTYPE_C )
_ISCTYPE_FUNC(digit, _CTYPE_N )
_ISCTYPE_FUNC(graph, _CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N )
_ISCTYPE_FUNC(digit, _CTYPE_D)
_ISCTYPE_FUNC(graph, _CTYPE_G)
_ISCTYPE_FUNC(lower, _CTYPE_L )
_ISCTYPE_FUNC(print, _CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)
_ISCTYPE_FUNC(print, _CTYPE_R)
_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(xdigit, _CTYPE_X)
int
toupper(int c)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctype_local.h,v 1.4 2010/06/13 04:14:57 tnozaki Exp $ */
/* $NetBSD: ctype_local.h,v 1.5 2013/04/13 10:21:20 joerg Exp $ */
/*-
* Copyright (c) 2010 Citrus Project,
@ -33,8 +33,22 @@
#define _CTYPE_NUM_CHARS (1 << CHAR_BIT)
#define _CTYPE_CACHE_SIZE (1 << 8)
extern const unsigned char _C_ctype_[];
extern const short _C_toupper_[];
extern const short _C_tolower_[];
#define _COMPAT_U 0x01
#define _COMPAT_L 0x02
#define _COMPAT_N 0x04
#define _COMPAT_S 0x08
#define _COMPAT_P 0x10
#define _COMPAT_C 0x20
#define _COMPAT_X 0x40
#define _COMPAT_B 0x80
extern const unsigned short _C_ctype_tab_[];
extern const short _C_toupper_tab_[];
extern const short _C_tolower_tab_[];
#ifdef __BUILD_LEGACY
extern const unsigned char *_ctype_;
extern const unsigned char _C_compat_bsdctype[];
#endif
#endif /*_CTYPE_LOCAL_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: global_locale.c,v 1.13 2012/03/21 14:11:24 christos Exp $ */
/* $NetBSD: global_locale.c,v 1.14 2013/04/13 10:21:20 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: global_locale.c,v 1.13 2012/03/21 14:11:24 christos Exp $");
__RCSID("$NetBSD: global_locale.c,v 1.14 2013/04/13 10:21:20 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -135,12 +135,16 @@ static const char *_global_items[(size_t)ALT_DIGITS + 1] = {
};
static struct _locale_cache_t _global_cache = {
.ctype_tab = (const unsigned char *)&_C_ctype_[0],
.tolower_tab = (const short *)&_C_tolower_[0],
.toupper_tab = (const short *)&_C_toupper_[0],
.ctype_tab = (const unsigned short *)&_C_ctype_tab_[0],
.tolower_tab = (const short *)&_C_tolower_tab_[0],
.toupper_tab = (const short *)&_C_toupper_tab_[0],
.mb_cur_max = (size_t)1,
.ldata = &_global_ldata,
.items = &_global_items[0],
#ifdef __BUILD_LEGACY
.compat_bsdctype = (const unsigned char *)&_C_compat_bsdctype[0],
#endif
};
struct _locale_impl_t _global_locale = {

View File

@ -1,4 +1,4 @@
/* $NetBSD: rune.c,v 1.45 2012/08/08 20:16:50 wiz Exp $ */
/* $NetBSD: rune.c,v 1.46 2013/04/13 10:21:20 joerg Exp $ */
/*-
* Copyright (c)2010 Citrus Project,
* All rights reserved.
@ -54,10 +54,14 @@
typedef struct {
_RuneLocale rl;
unsigned char rlp_ctype_tab [_CTYPE_NUM_CHARS + 1];
unsigned short rlp_ctype_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 */
#ifdef __BUILD_LEGACY
unsigned char rlp_compat_bsdctype[_CTYPE_NUM_CHARS + 1];
#endif
} _RuneLocalePriv;
static __inline void
@ -88,19 +92,29 @@ _rune_init_priv(_RuneLocalePriv *rlp)
rlp->rlp_ctype_tab [i + 1] = 0;
rlp->rlp_tolower_tab[i + 1] = i;
rlp->rlp_toupper_tab[i + 1] = i;
#ifdef __BUILD_LEGACY
rlp->rlp_compat_bsdctype[i + 1] = 0;
#endif
}
#endif
rlp->rlp_ctype_tab [0] = 0;
rlp->rlp_tolower_tab[0] = EOF;
rlp->rlp_toupper_tab[0] = EOF;
rlp->rl.rl_ctype_tab = (const unsigned char *)&rlp->rlp_ctype_tab[0];
rlp->rl.rl_ctype_tab = (const unsigned short *)&rlp->rlp_ctype_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];
_rune_wctype_init(&rlp->rl);
_rune_wctrans_init(&rlp->rl);
#ifdef __BUILD_LEGACY
rlp->rlp_compat_bsdctype[0] = 0;
rlp->rl.rl_compat_bsdctype = (const unsigned char *)
&rlp->rlp_compat_bsdctype[0];
#endif
}
static __inline void
@ -129,6 +143,35 @@ _rune_find_codeset(char *s, size_t n,
*s = '\0';
}
#ifdef __BUILD_LEGACY
static __inline int
_runetype_to_bsdctype(_RuneType bits)
{
int ret;
if (bits == (_RuneType)0)
return 0;
ret = 0;
if (bits & _RUNETYPE_U)
ret |= _COMPAT_U;
if (bits & _RUNETYPE_L)
ret |= _COMPAT_L;
if (bits & _RUNETYPE_D)
ret |= _COMPAT_N;
if (bits & _RUNETYPE_S)
ret |= _COMPAT_S;
if (bits & _RUNETYPE_P)
ret |= _COMPAT_P;
if (bits & _RUNETYPE_C)
ret |= _COMPAT_C;
if ((bits & (_RUNETYPE_X | _RUNETYPE_D)) == _RUNETYPE_X)
ret |= _COMPAT_X;
if ((bits & (_RUNETYPE_R | _RUNETYPE_G)) == _RUNETYPE_R)
ret |= _COMPAT_B;
return ret;
}
#endif /* __BUILD_LEGACY */
static __inline int
_rune_read_file(const char * __restrict var, size_t lenvar,
_RuneLocale ** __restrict prl)
@ -242,6 +285,7 @@ do { \
for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) {
wint_t wc;
_RuneType rc;
ret = _citrus_ctype_btowc(rl->rl_citrus_ctype, i, &wc);
if (ret)
@ -251,8 +295,14 @@ do { \
rlp->rlp_tolower_tab[i + 1] = i;
rlp->rlp_toupper_tab[i + 1] = i;
} else {
rlp->rlp_ctype_tab[i + 1] = (unsigned char)
_runetype_to_ctype(_runetype_priv(rl, wc));
rc = _runetype_priv(rl, wc);
rlp->rlp_ctype_tab[i + 1] = (unsigned short)
((rc & ~_RUNETYPE_SWM) >> 8);
#ifdef __BUILD_LEGACY
rlp->rlp_compat_bsdctype[i + 1]
= _runetype_to_bsdctype(rc);
#endif
#define CONVERT_MAP(name) \
do { \

View File

@ -1,4 +1,4 @@
/* $NetBSD: runetable.c,v 1.27 2010/06/19 13:26:52 tnozaki Exp $ */
/* $NetBSD: runetable.c,v 1.28 2013/04/13 10:21:21 joerg Exp $ */
/*-
* Copyright (c) 1993
@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93";
#else
__RCSID("$NetBSD: runetable.c,v 1.27 2010/06/19 13:26:52 tnozaki Exp $");
__RCSID("$NetBSD: runetable.c,v 1.28 2013/04/13 10:21:21 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -343,9 +343,13 @@ const _RuneLocale _DefaultRuneLocale = {
{ "upper", _RUNETYPE_U },
{ "xdigit", _RUNETYPE_X },
},
_C_ctype_,
_C_tolower_,
_C_toupper_
_C_ctype_tab_,
_C_tolower_tab_,
_C_toupper_tab_,
#ifdef __BUILD_LEGACY
_C_compat_bsdctype,
#endif
};
const _RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale;

View File

@ -1,4 +1,4 @@
/* $NetBSD: runetype_local.h,v 1.12 2010/06/20 02:23:15 tnozaki Exp $ */
/* $NetBSD: runetype_local.h,v 1.13 2013/04/13 10:21:21 joerg Exp $ */
/*-
* Copyright (c) 1993
@ -42,7 +42,8 @@
#include <sys/types.h>
#include <stdio.h>
#include "runetype_misc.h"
#include "ctype_local.h"
#include "runetype_file.h"
#define _RUNE_ISCACHED(c) ((c)>=0 && (c)<_CTYPE_CACHE_SIZE)
@ -123,9 +124,13 @@ typedef struct _RuneLocale {
_WCTransEntry rl_wctrans[_WCTRANS_NINDEXES];
_WCTypeEntry rl_wctype[_WCTYPE_NINDEXES];
const unsigned char *rl_ctype_tab;
const unsigned short *rl_ctype_tab;
const short *rl_tolower_tab;
const short *rl_toupper_tab;
#ifdef __BUILD_LEGACY
const unsigned char *rl_compat_bsdctype;
#endif
} _RuneLocale;
/*

View File

@ -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_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: setlocale_local.h,v 1.8 2012/03/04 21:14:57 tnozaki Exp $ */
/* $NetBSD: setlocale_local.h,v 1.9 2013/04/13 10:21:21 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -29,6 +29,8 @@
#ifndef _SETLOCALE_LOCAL_H_
#define _SETLOCALE_LOCAL_H_
#include "ctype_local.h"
#define _LOCALENAME_LEN_MAX 33
#define _C_LOCALE "C"
@ -40,12 +42,15 @@ extern const char *_PathLocale;
typedef void *_locale_part_t;
struct _locale_cache_t {
const unsigned char *ctype_tab;
const unsigned short *ctype_tab;
const short *tolower_tab;
const short *toupper_tab;
size_t mb_cur_max;
struct lconv *ldata;
const char **items;
#ifdef __BUILD_LEGACY
const unsigned char *compat_bsdctype;
#endif
};
struct _locale_impl_t {

View File

@ -1,4 +1,4 @@
# $NetBSD: shlib_version,v 1.238 2013/04/12 19:58:46 joerg Exp $
# $NetBSD: shlib_version,v 1.239 2013/04/13 10:21:20 joerg Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
# things we wish to do on next major version bump:
@ -30,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)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctype_bits.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
/* $NetBSD: ctype_bits.h,v 1.3 2013/04/13 10:21:21 joerg Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@ -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_D 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 */
#define _CTYPE_I 0x0800 /* Ideogram */
#define _CTYPE_T 0x1000 /* Special */
#define _CTYPE_Q 0x2000 /* Phonogram */
extern const unsigned char *_ctype_;
extern const unsigned short *_ctype_tab_;
extern const short *_tolower_tab_;
extern const short *_toupper_tab_;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctype_inline.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
/* $NetBSD: ctype_inline.h,v 1.3 2013/04/13 10:21:21 joerg Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@ -45,17 +45,17 @@
#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 isalnum(c) ((int)((_ctype_tab_ + 1)[(c)] & (_CTYPE_A|_CTYPE_D)))
#define isalpha(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_A))
#define iscntrl(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_C))
#define isdigit(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_D))
#define isgraph(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_G))
#define islower(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_L))
#define isprint(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_R))
#define ispunct(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_P))
#define isspace(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_S))
#define isupper(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_U))
#define isxdigit(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_X))
#define tolower(c) ((int)((_tolower_tab_ + 1)[(c)]))
#define toupper(c) ((int)((_toupper_tab_ + 1)[(c)]))
@ -68,15 +68,7 @@
#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
#define isblank(c) ((int)((_ctype_tab_ + 1)[(c)] & _CTYPE_BL))
#endif
#endif /* !_CTYPE_INLINE_H_ */