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