Prefix ctype bitmask macros with _CTYPE

This commit is contained in:
joerg 2010-12-14 02:28:57 +00:00
parent 7527c22f7f
commit 674a655551
7 changed files with 95 additions and 85 deletions

View File

@ -44,15 +44,15 @@
// 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;
static const mask upper = _U;
static const mask lower = _L;
static const mask alpha = _U | _L;
static const mask digit = _N;
static const mask xdigit = _N | _X;
static const mask space = _S;
static const mask print = _P | _U | _L | _N | _B;
static const mask graph = _P | _U | _L | _N;
static const mask cntrl = _C;
static const mask punct = _P;
static const mask alnum = _U | _L | _N;
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 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 cntrl = _CTYPE_C;
static const mask punct = _CTYPE_P;
static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctype_.c,v 1.18 2010/06/01 13:52:08 tnozaki Exp $ */
/* $NetBSD: ctype_.c,v 1.19 2010/12/14 02:28:57 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.18 2010/06/01 13:52:08 tnozaki Exp $");
__RCSID("$NetBSD: ctype_.c,v 1.19 2010/12/14 02:28:57 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -51,6 +51,15 @@ __RCSID("$NetBSD: ctype_.c,v 1.18 2010/06/01 13:52:08 tnozaki 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
const unsigned char _C_ctype_[1 + _CTYPE_NUM_CHARS] = {
0,
_C, _C, _C, _C, _C, _C, _C, _C,

View File

@ -1,4 +1,4 @@
/* $NetBSD: isctype.c,v 1.20 2010/06/01 13:52:08 tnozaki Exp $ */
/* $NetBSD: isctype.c,v 1.21 2010/12/14 02:28:57 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.20 2010/06/01 13:52:08 tnozaki Exp $");
__RCSID("$NetBSD: isctype.c,v 1.21 2010/12/14 02:28:57 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -55,17 +55,17 @@ is##name(int c) \
return (int)(_CTYPE_TAB(ctype_tab, c) & (bit)); \
}
_ISCTYPE_FUNC(alnum, _U|_L|_N )
_ISCTYPE_FUNC(alpha, _U|_L )
_ISCTYPE_FUNC(cntrl, _C )
_ISCTYPE_FUNC(digit, _N )
_ISCTYPE_FUNC(graph, _P|_U|_L|_N )
_ISCTYPE_FUNC(lower, _L )
_ISCTYPE_FUNC(print, _P|_U|_L|_N|_B)
_ISCTYPE_FUNC(punct, _P )
_ISCTYPE_FUNC(space, _S )
_ISCTYPE_FUNC(upper, _U )
_ISCTYPE_FUNC(xdigit, _N|_X )
_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)

View File

@ -1,4 +1,4 @@
/* $NetBSD: runetype_misc.h,v 1.1 2010/06/20 02:23:15 tnozaki Exp $ */
/* $NetBSD: runetype_misc.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
/*-
* Copyright (c) 1993
@ -49,19 +49,19 @@ _runetype_to_ctype(_RuneType bits)
return 0;
ret = 0;
if (bits & _RUNETYPE_U)
ret |= _U;
ret |= _CTYPE_U;
if (bits & _RUNETYPE_L)
ret |= _L;
ret |= _CTYPE_L;
if (bits & _RUNETYPE_D)
ret |= _N;
ret |= _CTYPE_N;
if (bits & _RUNETYPE_S)
ret |= _S;
ret |= _CTYPE_S;
if (bits & _RUNETYPE_P)
ret |= _P;
ret |= _CTYPE_P;
if (bits & _RUNETYPE_C)
ret |= _C;
ret |= _CTYPE_C;
if (bits & _RUNETYPE_X)
ret |= _X;
ret |= _CTYPE_X;
/*
* TWEAK! _B has been used incorrectly (or with older
* declaration) in ctype.h isprint() macro.
@ -71,10 +71,10 @@ _runetype_to_ctype(_RuneType bits)
*/
#if 1
if ((bits & (_RUNETYPE_R | _RUNETYPE_G)) == _RUNETYPE_R)
ret |= _B;
ret |= _CTYPE_B;
#else
if (bits & _RUNETYPE_B)
ret |= _B;
ret |= _CTYPE_B;
#endif
return ret;
}
@ -97,29 +97,30 @@ _runetype_from_ctype(int bits, int ch)
*/
ret = (_RuneType)0;
if (bits & _U)
if (bits & _CTYPE_U)
ret |= _RUNETYPE_U;
if (bits & _L)
if (bits & _CTYPE_L)
ret |= _RUNETYPE_L;
if (bits & _N)
if (bits & _CTYPE_N)
ret |= _RUNETYPE_D;
if (bits & _S)
if (bits & _CTYPE_S)
ret |= _RUNETYPE_S;
if (bits & _P)
if (bits & _CTYPE_P)
ret |= _RUNETYPE_P;
if (bits & _C)
if (bits & _CTYPE_C)
ret |= _RUNETYPE_C;
/* derived flag bits, duplicate of ctype.h */
if (bits & (_U|_L))
if (bits & (_CTYPE_U|_CTYPE_L))
ret |= _RUNETYPE_A;
if (bits & (_N|_X))
if (bits & (_CTYPE_N|_CTYPE_X))
ret |= _RUNETYPE_X;
if (bits & (_P|_U|_L|_N))
if (bits & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N))
ret |= _RUNETYPE_G;
/* we don't really trust _B in the file. see above. */
if (bits & _B)
if (bits & _CTYPE_B)
ret |= _RUNETYPE_B;
if ((bits & (_P|_U|_L|_N|_B)) || ch == ' ')
if ((bits & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)) ||
ch == ' ')
ret |= (_RUNETYPE_R | _RUNETYPE_SW1);
if (ch == ' ' || ch == '\t')
ret |= _RUNETYPE_B;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctype_bits.h,v 1.1 2010/06/01 13:52:08 tnozaki Exp $ */
/* $NetBSD: ctype_bits.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@ -40,14 +40,14 @@
#ifndef _SYS_CTYPE_BITS_H_
#define _SYS_CTYPE_BITS_H_
#define _U 0x01
#define _L 0x02
#define _N 0x04
#define _S 0x08
#define _P 0x10
#define _C 0x20
#define _X 0x40
#define _B 0x80
#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
extern const unsigned char *_ctype_;
extern const short *_tolower_tab_;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctype_inline.h,v 1.1 2010/06/01 13:52:08 tnozaki Exp $ */
/* $NetBSD: ctype_inline.h,v 1.2 2010/12/14 02:28:57 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)] & _N))
#define islower(c) ((int)((_ctype_ + 1)[(c)] & _L))
#define isspace(c) ((int)((_ctype_ + 1)[(c)] & _S))
#define ispunct(c) ((int)((_ctype_ + 1)[(c)] & _P))
#define isupper(c) ((int)((_ctype_ + 1)[(c)] & _U))
#define isalpha(c) ((int)((_ctype_ + 1)[(c)] & (_U|_L)))
#define isxdigit(c) ((int)((_ctype_ + 1)[(c)] & (_N|_X)))
#define isalnum(c) ((int)((_ctype_ + 1)[(c)] & (_U|_L|_N)))
#define isprint(c) ((int)((_ctype_ + 1)[(c)] & (_P|_U|_L|_N|_B)))
#define isgraph(c) ((int)((_ctype_ + 1)[(c)] & (_P|_U|_L|_N)))
#define iscntrl(c) ((int)((_ctype_ + 1)[(c)] & _C))
#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 tolower(c) ((int)((_tolower_tab_ + 1)[(c)]))
#define toupper(c) ((int)((_toupper_tab_ + 1)[(c)]))

View File

@ -1,4 +1,4 @@
/* $NetBSD: chrtbl.c,v 1.12 2009/10/21 01:07:47 snj Exp $ */
/* $NetBSD: chrtbl.c,v 1.13 2010/12/14 02:28:58 joerg Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@ -63,21 +63,21 @@ static const struct toklist {
char *, size_t lno));
int arg;
} tokens[] = {
{ "LC_CTYPE", setfilename, 0 },
{ "isupper", addattr, _U },
{ "islower", addattr, _L },
{ "isdigit", addattr, _N },
{ "isspace", addattr, _S },
{ "ispunct", addattr, _P },
{ "iscntrl", addattr, _C },
{ "isblank", addattr, _B },
{ "isxdigit", addattr, _X },
{ "ul", uplow, 0 },
{ "cswidth", cswidth, 0 },
{ "LC_NUMERIC", setfilename, 1 },
{ "decimal_point", numeric, 0 },
{ "thousands_sep", numeric, 0 },
{ NULL, NULL, 0 }
{ "LC_CTYPE", setfilename, 0 },
{ "isupper", addattr, _CTYPE_U },
{ "islower", addattr, _CTYPE_L },
{ "isdigit", addattr, _CTYPE_N },
{ "isspace", addattr, _CTYPE_S },
{ "ispunct", addattr, _CTYPE_P },
{ "iscntrl", addattr, _CTYPE_C },
{ "isblank", addattr, _CTYPE_B },
{ "isxdigit", addattr, _CTYPE_X },
{ "ul", uplow, 0 },
{ "cswidth", cswidth, 0 },
{ "LC_NUMERIC", setfilename, 1 },
{ "decimal_point", numeric, 0 },
{ "thousands_sep", numeric, 0 },
{ NULL, NULL, 0 }
};
/* usage():
@ -331,7 +331,7 @@ printctype(fp, ct)
{
int did = 0;
#define DO(a) if (__CONCAT(_,a) & ct) { \
#define DO(a) if (__CONCAT(_CTYPE_,a) & ct) { \
if (did) \
(void) fputc('|', fp); \
did = 1; \