| Commit | Line | Data |
|---|---|---|
| 92d0a6a6 | 1 | // -*- C++ -*- |
| 4d3e9548 JL |
2 | /* Copyright (C) 1989, 1990, 1991, 1992, 2009 |
| 3 | Free Software Foundation, Inc. | |
| 92d0a6a6 JR |
4 | Written by James Clark (jjc@jclark.com) |
| 5 | ||
| 6 | This file is part of groff. | |
| 7 | ||
| 8 | groff is free software; you can redistribute it and/or modify it under | |
| 9 | the terms of the GNU General Public License as published by the Free | |
| 4d3e9548 JL |
10 | Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. | |
| 92d0a6a6 JR |
12 | |
| 13 | groff is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 16 | for more details. | |
| 17 | ||
| 4d3e9548 JL |
18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
| 92d0a6a6 JR |
20 | |
| 21 | #ifdef HAVE_CC_LIMITS_H | |
| 22 | #include <limits.h> | |
| 23 | #else /* not HAVE_CC_LIMITS_H */ | |
| 24 | #ifndef UCHAR_MAX | |
| 25 | #define UCHAR_MAX 255 | |
| 26 | #endif | |
| 27 | #endif /* not HAVE_CC_LIMITS_H */ | |
| 28 | ||
| 29 | enum cset_builtin { CSET_BUILTIN }; | |
| 30 | ||
| 31 | class cset { | |
| 32 | public: | |
| 33 | cset(); | |
| 34 | cset(cset_builtin); | |
| 35 | cset(const char *); | |
| 36 | cset(const unsigned char *); | |
| 37 | int operator()(unsigned char) const; | |
| 38 | ||
| 39 | cset &operator|=(const cset &); | |
| 40 | cset &operator|=(unsigned char); | |
| 41 | ||
| 42 | friend class cset_init; | |
| 43 | private: | |
| 44 | char v[UCHAR_MAX+1]; | |
| 45 | void clear(); | |
| 46 | }; | |
| 47 | ||
| 48 | inline int cset::operator()(unsigned char c) const | |
| 49 | { | |
| 50 | return v[c]; | |
| 51 | } | |
| 52 | ||
| 53 | inline cset &cset::operator|=(unsigned char c) | |
| 54 | { | |
| 55 | v[c] = 1; | |
| 56 | return *this; | |
| 57 | } | |
| 58 | ||
| 59 | extern cset csalpha; | |
| 60 | extern cset csupper; | |
| 61 | extern cset cslower; | |
| 62 | extern cset csdigit; | |
| 63 | extern cset csxdigit; | |
| 64 | extern cset csspace; | |
| 65 | extern cset cspunct; | |
| 66 | extern cset csalnum; | |
| 67 | extern cset csprint; | |
| 68 | extern cset csgraph; | |
| 69 | extern cset cscntrl; | |
| 70 | ||
| 71 | static class cset_init { | |
| 72 | static int initialised; | |
| 73 | public: | |
| 74 | cset_init(); | |
| 75 | } _cset_init; |