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