Line data Source code
1 : /* Copyright 1989-2020 Free Software Foundation, Inc. 2 : Written by James Clark (jjc@jclark.com) 3 : 4 : This file is part of groff, the GNU roff typesetting system. 5 : 6 : groff is free software; you can redistribute it and/or modify it under 7 : the terms of the GNU General Public License as published by the Free 8 : Software Foundation, either version 3 of the License, or 9 : (at your option) any later version. 10 : 11 : groff is distributed in the hope that it will be useful, but WITHOUT ANY 12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 : for more details. 15 : 16 : You should have received a copy of the GNU General Public License 17 : along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18 : 19 : #ifdef HAVE_CONFIG_H 20 : #include <config.h> 21 : #endif 22 : 23 : #include <ctype.h> 24 : #include "cmap.h" 25 : 26 : cmap cmlower(CMAP_BUILTIN); 27 : cmap cmupper(CMAP_BUILTIN); 28 : 29 : #ifdef isascii 30 : #define ISASCII(c) isascii(c) 31 : #else 32 : #define ISASCII(c) (1) 33 : #endif 34 : 35 0 : cmap::cmap() 36 : { 37 0 : unsigned char *p = v; 38 0 : for (int i = 0; i <= UCHAR_MAX; i++) 39 0 : p[i] = i; 40 0 : } 41 : 42 3120 : cmap::cmap(cmap_builtin) 43 : { 44 : // these are initialised by cmap_init::cmap_init() 45 3120 : } 46 : 47 : int cmap_init::initialised = 0; 48 : 49 13230 : cmap_init::cmap_init() 50 : { 51 13230 : if (initialised) 52 11670 : return; 53 1560 : initialised = 1; 54 400920 : for (int i = 0; i <= UCHAR_MAX; i++) { 55 399360 : cmupper.v[i] = ISASCII(i) && islower(i) ? toupper(i) : i; 56 399360 : cmlower.v[i] = ISASCII(i) && isupper(i) ? tolower(i) : i; 57 : } 58 : } 59 : 60 : // Local Variables: 61 : // fill-column: 72 62 : // mode: C++ 63 : // End: 64 : // vim: set cindent noexpandtab shiftwidth=2 textwidth=72: