cmap.cpp revision 114411
1114402Sru// -*- C++ -*- 2114402Sru/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. 3114402Sru Written by James Clark (jjc@jclark.com) 4114402Sru 5114402SruThis file is part of groff. 6114402Sru 7114402Srugroff is free software; you can redistribute it and/or modify it under 8114402Sruthe terms of the GNU General Public License as published by the Free 9114402SruSoftware Foundation; either version 2, or (at your option) any later 10114402Sruversion. 11114402Sru 12114402Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY 13114402SruWARRANTY; without even the implied warranty of MERCHANTABILITY or 14114402SruFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15114402Srufor more details. 16114402Sru 17114402SruYou should have received a copy of the GNU General Public License along 18114402Sruwith groff; see the file COPYING. If not, write to the Free Software 19114402SruFoundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 20114402Sru 21114411Sru/* $FreeBSD: head/contrib/groff/src/libs/libgroff/cmap.cpp 114411 2003-05-01 13:18:55Z ru $ */ 22114411Sru 23114402Sru#include <ctype.h> 24114411Sru#ifdef __FreeBSD__ 25114411Sru#include <locale.h> 26114411Sru#endif 27114402Sru#include "cmap.h" 28114402Sru 29114402Srucmap cmlower(CMAP_BUILTIN); 30114402Srucmap cmupper(CMAP_BUILTIN); 31114402Sru 32114411Sru#if defined(isascii) && !defined(__FreeBSD__) 33114402Sru#define ISASCII(c) isascii(c) 34114402Sru#else 35114402Sru#define ISASCII(c) (1) 36114402Sru#endif 37114402Sru 38114402Srucmap::cmap() 39114402Sru{ 40114402Sru unsigned char *p = v; 41114402Sru for (int i = 0; i <= UCHAR_MAX; i++) 42114402Sru p[i] = i; 43114402Sru} 44114402Sru 45114402Srucmap::cmap(cmap_builtin) 46114402Sru{ 47114402Sru // these are initialised by cmap_init::cmap_init() 48114402Sru} 49114402Sru 50114402Sruint cmap_init::initialised = 0; 51114402Sru 52114402Srucmap_init::cmap_init() 53114402Sru{ 54114402Sru if (initialised) 55114402Sru return; 56114402Sru initialised = 1; 57114411Sru#ifdef __FreeBSD__ 58114411Sru (void) setlocale(LC_CTYPE, ""); 59114411Sru#endif 60114402Sru for (int i = 0; i <= UCHAR_MAX; i++) { 61114402Sru cmupper.v[i] = ISASCII(i) && islower(i) ? toupper(i) : i; 62114402Sru cmlower.v[i] = ISASCII(i) && isupper(i) ? tolower(i) : i; 63114402Sru } 64114402Sru} 65