2 /* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
5 This file is part of groff.
7 groff is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License along
18 with groff; see the file COPYING. If not, write to the Free Software
19 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
31 cset csalpha(CSET_BUILTIN);
32 cset csupper(CSET_BUILTIN);
33 cset cslower(CSET_BUILTIN);
34 cset csdigit(CSET_BUILTIN);
35 cset csxdigit(CSET_BUILTIN);
36 cset csspace(CSET_BUILTIN);
37 cset cspunct(CSET_BUILTIN);
38 cset csalnum(CSET_BUILTIN);
39 cset csprint(CSET_BUILTIN);
40 cset csgraph(CSET_BUILTIN);
41 cset cscntrl(CSET_BUILTIN);
43 #if defined(isascii) && !defined(__FreeBSD__)
44 #define ISASCII(c) isascii(c)
46 #define ISASCII(c) (1)
52 for (int i = 0; i <= UCHAR_MAX; i++)
61 cset::cset(const char *s)
65 v[(unsigned char)*s++] = 1;
68 cset::cset(const unsigned char *s)
75 cset::cset(cset_builtin)
77 // these are initialised by cset_init::cset_init()
80 cset &cset::operator|=(const cset &cs)
82 for (int i = 0; i <= UCHAR_MAX; i++)
89 int cset_init::initialised = 0;
91 cset_init::cset_init()
97 (void) setlocale(LC_CTYPE, "");
99 for (int i = 0; i <= UCHAR_MAX; i++) {
100 csalpha.v[i] = ISASCII(i) && isalpha(i);
101 csupper.v[i] = ISASCII(i) && isupper(i);
102 cslower.v[i] = ISASCII(i) && islower(i);
103 csdigit.v[i] = ISASCII(i) && isdigit(i);
104 csxdigit.v[i] = ISASCII(i) && isxdigit(i);
105 csspace.v[i] = ISASCII(i) && isspace(i);
106 cspunct.v[i] = ISASCII(i) && ispunct(i);
107 csalnum.v[i] = ISASCII(i) && isalnum(i);
108 csprint.v[i] = ISASCII(i) && isprint(i);
109 csgraph.v[i] = ISASCII(i) && isgraph(i);
110 cscntrl.v[i] = ISASCII(i) && iscntrl(i);