1 /* $OpenBSD: char.c,v 1.4 2009/10/27 23:59:21 deraadt Exp $ */ 2 /* $NetBSD: char.c,v 1.6 1995/03/21 09:02:26 cgd Exp $ */ 3 4 /*- 5 * Copyright (c) 1980, 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 #include "char.h" 34 35 unsigned short _cmap[256] = { 36 /* nul soh stx etx */ 37 _CTR, _CTR, _CTR, _CTR, 38 39 /* eot enq ack bel */ 40 _CTR, _CTR, _CTR, _CTR, 41 42 /* bs ht nl vt */ 43 _CTR, _CTR|_SP|_META, _CTR|_NL|_META, _CTR, 44 45 /* np cr so si */ 46 _CTR, _CTR, _CTR, _CTR, 47 48 /* dle dc1 dc2 dc3 */ 49 _CTR, _CTR, _CTR, _CTR, 50 51 /* dc4 nak syn etb */ 52 _CTR, _CTR, _CTR, _CTR, 53 54 /* can em sub esc */ 55 _CTR, _CTR, _CTR, _CTR, 56 57 /* fs gs rs us */ 58 _CTR, _CTR, _CTR, _CTR, 59 60 /* sp ! " # */ 61 _SP|_META, 0, _QF, _META, 62 63 /* $ % & ' */ 64 _DOL, 0, _META|_CMD, _QF, 65 66 /* ( ) * + */ 67 _META|_CMD, _META, _GLOB, 0, 68 69 /* , - . / */ 70 0, 0, 0, 0, 71 72 /* 0 1 2 3 */ 73 _DIG|_XD, _DIG|_XD, _DIG|_XD, _DIG|_XD, 74 75 /* 4 5 6 7 */ 76 _DIG|_XD, _DIG|_XD, _DIG|_XD, _DIG|_XD, 77 78 /* 8 9 : ; */ 79 _DIG|_XD, _DIG|_XD, 0, _META|_CMD, 80 81 /* < = > ? */ 82 _META, 0, _META, _GLOB, 83 84 /* @ A B C */ 85 0, _LET|_UP|_XD, _LET|_UP|_XD, _LET|_UP|_XD, 86 87 /* D E F G */ 88 _LET|_UP|_XD, _LET|_UP|_XD, _LET|_UP|_XD, _LET|_UP, 89 90 /* H I J K */ 91 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 92 93 /* L M N O */ 94 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 95 96 /* P Q R S */ 97 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 98 99 /* T U V W */ 100 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 101 102 /* X Y Z [ */ 103 _LET|_UP, _LET|_UP, _LET|_UP, _GLOB, 104 105 /* \ ] ^ _ */ 106 _ESC, 0, 0, 0, 107 108 /* ` a b c */ 109 _QB|_GLOB|_META, _LET|_LOW|_XD, _LET|_LOW|_XD, _LET|_LOW|_XD, 110 111 /* d e f g */ 112 _LET|_LOW|_XD, _LET|_LOW|_XD, _LET|_LOW|_XD, _LET|_LOW, 113 114 /* h i j k */ 115 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 116 117 /* l m n o */ 118 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 119 120 /* p q r s */ 121 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 122 123 /* t u v w */ 124 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 125 126 /* x y z { */ 127 _LET|_LOW, _LET|_LOW, _LET|_LOW, _GLOB, 128 129 /* | } ~ del */ 130 _META|_CMD, 0, 0, _CTR, 131 132 #if defined(SHORT_STRINGS) && !defined(KANJI) 133 /****************************************************************/ 134 /* 128 - 255 The below is supposedly ISO 8859/1 */ 135 /****************************************************************/ 136 /* (undef) (undef) (undef) (undef) */ 137 _CTR, _CTR, _CTR, _CTR, 138 139 /* (undef) (undef) (undef) (undef) */ 140 _CTR, _CTR, _CTR, _CTR, 141 142 /* (undef) (undef) (undef) (undef) */ 143 _CTR, _CTR, _CTR, _CTR, 144 145 /* (undef) (undef) (undef) (undef) */ 146 _CTR, _CTR, _CTR, _CTR, 147 148 /* (undef) (undef) (undef) (undef) */ 149 _CTR, _CTR, _CTR, _CTR, 150 151 /* (undef) (undef) (undef) (undef) */ 152 _CTR, _CTR, _CTR, _CTR, 153 154 /* (undef) (undef) (undef) (undef) */ 155 _CTR, _CTR, _CTR, _CTR, 156 157 /* (undef) (undef) (undef) (undef) */ 158 _CTR, _CTR, _CTR, _CTR, 159 160 /* nobreakspace exclamdown cent sterling */ 161 _SP, 0, 0, 0, 162 163 /* currency yen brokenbar section */ 164 0, 0, 0, 0, 165 166 /* diaeresis copyright ordfeminine guillemotleft */ 167 0, 0, 0, 0, 168 169 /* notsign hyphen registered macron */ 170 0, 0, 0, 0, 171 172 /* degree plusminus twosuperior threesuperior */ 173 0, 0, 0, 0, 174 175 /* acute mu paragraph periodcentered */ 176 0, 0, 0, 0, 177 178 /* cedilla onesuperior masculine guillemotright */ 179 0, 0, 0, 0, 180 181 /* onequarter onehalf threequarters questiondown */ 182 0, 0, 0, 0, 183 184 /* Agrave Aacute Acircumflex Atilde */ 185 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 186 187 /* Adiaeresis Aring AE Ccedilla */ 188 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 189 190 /* Egrave Eacute Ecircumflex Ediaeresis */ 191 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 192 193 /* Igrave Iacute Icircumflex Idiaeresis */ 194 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 195 196 /* ETH Ntilde Ograve Oacute */ 197 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 198 199 /* Ocircumflex Otilde Odiaeresis multiply */ 200 _LET|_UP, _LET|_UP, _LET|_UP, 0, 201 202 /* Ooblique Ugrave Uacute Ucircumflex */ 203 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_UP, 204 205 /* Udiaeresis Yacute THORN ssharp */ 206 _LET|_UP, _LET|_UP, _LET|_UP, _LET|_LOW, 207 208 /* agrave aacute acircumflex atilde */ 209 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 210 211 /* adiaeresis aring ae ccedilla */ 212 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 213 214 /* egrave eacute ecircumflex ediaeresis */ 215 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 216 217 /* igrave iacute icircumflex idiaeresis */ 218 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 219 220 /* eth ntilde ograve oacute */ 221 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 222 223 /* ocircumflex otilde odiaeresis division */ 224 _LET|_LOW, _LET|_LOW, _LET|_LOW, 0, 225 226 /* oslash ugrave uacute ucircumflex */ 227 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 228 229 /* udiaeresis yacute thorn ydiaeresis */ 230 _LET|_LOW, _LET|_LOW, _LET|_LOW, _LET|_LOW, 231 #endif /* SHORT_STRINGS && !KANJI */ 232 }; 233 234 #ifndef NLS 235 /* _cmap_lower, _cmap_upper for ISO 8859/1 */ 236 237 unsigned char _cmap_lower[256] = { 238 0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007, 239 0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017, 240 0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027, 241 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037, 242 0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047, 243 0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057, 244 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067, 245 0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077, 246 0100, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 247 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 248 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 249 0170, 0171, 0172, 0133, 0134, 0135, 0136, 0137, 250 0140, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 251 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 252 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 253 0170, 0171, 0172, 0173, 0174, 0175, 0176, 0177, 254 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, 255 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, 256 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, 257 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, 258 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, 259 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, 260 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, 261 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, 262 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, 263 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, 264 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0327, 265 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0337, 266 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, 267 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, 268 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, 269 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377, 270 }; 271 272 unsigned char _cmap_upper[256] = { 273 0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007, 274 0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017, 275 0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027, 276 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037, 277 0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047, 278 0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057, 279 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067, 280 0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077, 281 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 282 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 283 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 284 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, 285 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 286 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 287 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 288 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, 289 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, 290 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, 291 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, 292 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, 293 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, 294 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, 295 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, 296 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, 297 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, 298 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, 299 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, 300 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, 301 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, 302 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, 303 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0367, 304 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0377, 305 }; 306 #endif /* NLS */ 307