xref: /csrg-svn/bin/csh/char.c (revision 60765)
147823Sbostic /*-
2*60765Sbostic  * Copyright (c) 1980, 1991, 1993
3*60765Sbostic  *	The Regents of the University of California.  All rights reserved.
447823Sbostic  *
547823Sbostic  * %sccs.include.redist.c%
621926Sdist  */
721926Sdist 
817522Sedward #ifndef lint
9*60765Sbostic static char sccsid[] = "@(#)char.c	8.1 (Berkeley) 05/31/93";
1047823Sbostic #endif /* not lint */
1117522Sedward 
1250023Sbostic #include "char.h"
1317522Sedward 
1426971Slepreau unsigned short _cmap[256] = {
1517522Sedward /*	nul		soh		stx		etx	*/
1649992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
1717522Sedward 
1817522Sedward /*	eot		enq		ack		bel	*/
1949992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
2017522Sedward 
2117522Sedward /*	bs		ht		nl		vt	*/
2249992Sbostic 	_CTR,		_CTR|_SP|_META,	_CTR|_NL|_META,	_CTR,
2317522Sedward 
2417522Sedward /*	np		cr		so		si	*/
2549992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
2617522Sedward 
2717522Sedward /*	dle		dc1		dc2		dc3	*/
2849992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
2917522Sedward 
3017522Sedward /*	dc4		nak		syn		etb	*/
3149992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
3217522Sedward 
3317522Sedward /*	can		em		sub		esc	*/
3449992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
3517522Sedward 
3617522Sedward /*	fs		gs		rs		us	*/
3749992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
3817522Sedward 
3917522Sedward /*	sp		!		"		#	*/
4060488Schristos 	_SP|_META,	0,		_QF,		_META,
4117522Sedward 
4217522Sedward /*	$		%		&		'	*/
4360488Schristos 	_DOL,		0,		_META|_CMD,	_QF,
4417522Sedward 
4517522Sedward /*	(		)		*		+	*/
4649992Sbostic 	_META|_CMD,	_META,		_GLOB,		0,
4717522Sedward 
4817522Sedward /*	,		-		.		/	*/
4917522Sedward 	0,		0,		0,		0,
5017522Sedward 
5117522Sedward /*	0		1		2		3	*/
5249992Sbostic 	_DIG|_XD,	_DIG|_XD,	_DIG|_XD,	_DIG|_XD,
5317522Sedward 
5417522Sedward /*	4		5		6		7	*/
5549992Sbostic 	_DIG|_XD,	_DIG|_XD,	_DIG|_XD,	_DIG|_XD,
5617522Sedward 
5717522Sedward /*	8		9		:		;	*/
5849992Sbostic 	_DIG|_XD,	_DIG|_XD,	0,		_META|_CMD,
5917522Sedward 
6017522Sedward /*	<		=		>		?	*/
6117522Sedward 	_META,		0,		_META,		_GLOB,
6217522Sedward 
6317522Sedward /*	@		A		B		C	*/
6449992Sbostic 	0,		_LET|_UP|_XD,	_LET|_UP|_XD,	_LET|_UP|_XD,
6517522Sedward 
6617522Sedward /*	D		E		F		G	*/
6749992Sbostic 	_LET|_UP|_XD,	_LET|_UP|_XD,	_LET|_UP|_XD,	_LET|_UP,
6817522Sedward 
6917522Sedward /*	H		I		J		K	*/
7049992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
7117522Sedward 
7217522Sedward /*	L		M		N		O	*/
7349992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
7417522Sedward 
7517522Sedward /*	P		Q		R		S	*/
7649992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
7717522Sedward 
7817522Sedward /*	T		U		V		W	*/
7949992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
8017522Sedward 
8117522Sedward /*	X		Y		Z		[	*/
8249992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_GLOB,
8317522Sedward 
8417522Sedward /*	\		]		^		_	*/
8549992Sbostic 	_ESC,		0,		0,		0,
8617522Sedward 
8717522Sedward /*	`		a		b		c	*/
8860488Schristos   _QB|_GLOB|_META,	_LET|_LOW|_XD,	_LET|_LOW|_XD,	_LET|_LOW|_XD,
8917522Sedward 
9017522Sedward /*	d		e		f		g	*/
9149992Sbostic 	_LET|_LOW|_XD,	_LET|_LOW|_XD,	_LET|_LOW|_XD,	_LET|_LOW,
9217522Sedward 
9317522Sedward /*	h		i		j		k	*/
9449992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
9517522Sedward 
9617522Sedward /*	l		m		n		o	*/
9749992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
9817522Sedward 
9917522Sedward /*	p		q		r		s	*/
10049992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
10117522Sedward 
10217522Sedward /*	t		u		v		w	*/
10349992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
10417522Sedward 
10517522Sedward /*	x		y		z		{	*/
10649992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_GLOB,
10717522Sedward 
10817522Sedward /*	|		}		~		del	*/
10949992Sbostic 	_META|_CMD,	0,		0,		_CTR,
11049992Sbostic 
11149992Sbostic #if defined(SHORT_STRINGS) && !defined(KANJI)
11249992Sbostic /****************************************************************/
11349992Sbostic /* 128 - 255 The below is supposedly ISO 8859/1			*/
11449992Sbostic /****************************************************************/
11549992Sbostic /*	(undef)		(undef)		(undef)		(undef)		*/
11649992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
11749992Sbostic 
11849992Sbostic /*	(undef)		(undef)		(undef)		(undef)		*/
11949992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
12049992Sbostic 
12149992Sbostic /*	(undef)		(undef)		(undef)		(undef)		*/
12249992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
12349992Sbostic 
12449992Sbostic /*	(undef)		(undef)		(undef)		(undef)		*/
12549992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
12649992Sbostic 
12749992Sbostic /*	(undef)		(undef)		(undef)		(undef)		*/
12849992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
12949992Sbostic 
13049992Sbostic /*	(undef)		(undef)		(undef)		(undef)		*/
13149992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
13249992Sbostic 
13349992Sbostic /*	(undef)		(undef)		(undef)		(undef)		*/
13449992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
13549992Sbostic 
13649992Sbostic /*	(undef)		(undef)		(undef)		(undef)		*/
13749992Sbostic 	_CTR,		_CTR,		_CTR,		_CTR,
13849992Sbostic 
13949992Sbostic /*	nobreakspace	exclamdown	cent		sterling	*/
14049992Sbostic 	_SP,		0,		0,		0,
14149992Sbostic 
14249992Sbostic /*	currency	yen		brokenbar	section		*/
14349992Sbostic 	0,		0,		0,		0,
14449992Sbostic 
14549992Sbostic /*	diaeresis	copyright	ordfeminine	guillemotleft	*/
14649992Sbostic 	0,		0,		0,		0,
14749992Sbostic 
14849992Sbostic /*	notsign		hyphen		registered	macron		*/
14949992Sbostic 	0,		0,		0,		0,
15049992Sbostic 
15149992Sbostic /*	degree		plusminus	twosuperior	threesuperior	*/
15249992Sbostic 	0,		0,		0,		0,
15349992Sbostic 
15449992Sbostic /*	acute		mu		paragraph	periodcentered	*/
15549992Sbostic 	0,		0,		0,		0,
15649992Sbostic 
15749992Sbostic /*	cedilla		onesuperior	masculine	guillemotright	*/
15849992Sbostic 	0,		0,		0,		0,
15949992Sbostic 
16049992Sbostic /*	onequarter	onehalf		threequarters	questiondown	*/
16149992Sbostic 	0,		0,		0,		0,
16249992Sbostic 
16349992Sbostic /*	Agrave		Aacute		Acircumflex	Atilde		*/
16449992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
16549992Sbostic 
16649992Sbostic /*	Adiaeresis	Aring		AE		Ccedilla	*/
16749992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
16849992Sbostic 
16949992Sbostic /*	Egrave		Eacute		Ecircumflex	Ediaeresis	*/
17049992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
17149992Sbostic 
17249992Sbostic /*	Igrave		Iacute		Icircumflex	Idiaeresis	*/
17349992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
17449992Sbostic 
17549992Sbostic /*	ETH		Ntilde		Ograve		Oacute		*/
17649992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
17749992Sbostic 
17849992Sbostic /*	Ocircumflex	Otilde		Odiaeresis	multiply	*/
17949992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	0,
18049992Sbostic 
18149992Sbostic /*	Ooblique	Ugrave		Uacute		Ucircumflex	*/
18249992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_UP,
18349992Sbostic 
18449992Sbostic /*	Udiaeresis	Yacute		THORN		ssharp		*/
18549992Sbostic 	_LET|_UP,	_LET|_UP,	_LET|_UP,	_LET|_LOW,
18649992Sbostic 
18749992Sbostic /*	agrave		aacute		acircumflex	atilde		*/
18849992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
18949992Sbostic 
19049992Sbostic /*	adiaeresis	aring		ae		ccedilla	*/
19149992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
19249992Sbostic 
19349992Sbostic /*	egrave		eacute		ecircumflex	ediaeresis	*/
19449992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
19549992Sbostic 
19649992Sbostic /*	igrave		iacute		icircumflex	idiaeresis	*/
19749992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
19849992Sbostic 
19949992Sbostic /*	eth		ntilde		ograve		oacute		*/
20049992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
20149992Sbostic 
20249992Sbostic /*	ocircumflex	otilde		odiaeresis	division	*/
20349992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	0,
20449992Sbostic 
20549992Sbostic /*	oslash		ugrave		uacute		ucircumflex	*/
20649992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
20749992Sbostic 
20849992Sbostic /*	udiaeresis	yacute		thorn		ydiaeresis	*/
20949992Sbostic 	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,	_LET|_LOW,
21049992Sbostic #endif /* SHORT_STRINGS && !KANJI */
21117522Sedward };
21249992Sbostic 
21349992Sbostic #ifndef NLS
21449992Sbostic /* _cmap_lower, _cmap_upper for ISO 8859/1 */
21549992Sbostic 
21649992Sbostic unsigned char _cmap_lower[256] = {
21749992Sbostic 	0000,	0001,	0002,	0003,	0004,	0005,	0006,	0007,
21849992Sbostic 	0010,	0011,	0012,	0013,	0014,	0015,	0016,	0017,
21949992Sbostic 	0020,	0021,	0022,	0023,	0024,	0025,	0026,	0027,
22049992Sbostic 	0030,	0031,	0032,	0033,	0034,	0035,	0036,	0037,
22149992Sbostic 	0040,	0041,	0042,	0043,	0044,	0045,	0046,	0047,
22249992Sbostic 	0050,	0051,	0052,	0053,	0054,	0055,	0056,	0057,
22349992Sbostic 	0060,	0061,	0062,	0063,	0064,	0065,	0066,	0067,
22449992Sbostic 	0070,	0071,	0072,	0073,	0074,	0075,	0076,	0077,
22549992Sbostic 	0100,	0141,	0142,	0143,	0144,	0145,	0146,	0147,
22649992Sbostic 	0150,	0151,	0152,	0153,	0154,	0155,	0156,	0157,
22749992Sbostic 	0160,	0161,	0162,	0163,	0164,	0165,	0166,	0167,
22849992Sbostic 	0170,	0171,	0172,	0133,	0134,	0135,	0136,	0137,
22949992Sbostic 	0140,	0141,	0142,	0143,	0144,	0145,	0146,	0147,
23049992Sbostic 	0150,	0151,	0152,	0153,	0154,	0155,	0156,	0157,
23149992Sbostic 	0160,	0161,	0162,	0163,	0164,	0165,	0166,	0167,
23249992Sbostic 	0170,	0171,	0172,	0173,	0174,	0175,	0176,	0177,
23349992Sbostic 	0200,	0201,	0202,	0203,	0204,	0205,	0206,	0207,
23449992Sbostic 	0210,	0211,	0212,	0213,	0214,	0215,	0216,	0217,
23549992Sbostic 	0220,	0221,	0222,	0223,	0224,	0225,	0226,	0227,
23649992Sbostic 	0230,	0231,	0232,	0233,	0234,	0235,	0236,	0237,
23749992Sbostic 	0240,	0241,	0242,	0243,	0244,	0245,	0246,	0247,
23849992Sbostic 	0250,	0251,	0252,	0253,	0254,	0255,	0256,	0257,
23949992Sbostic 	0260,	0261,	0262,	0263,	0264,	0265,	0266,	0267,
24049992Sbostic 	0270,	0271,	0272,	0273,	0274,	0275,	0276,	0277,
24149992Sbostic 	0340,	0341,	0342,	0343,	0344,	0345,	0346,	0347,
24249992Sbostic 	0350,	0351,	0352,	0353,	0354,	0355,	0356,	0357,
24349992Sbostic 	0360,	0361,	0362,	0363,	0364,	0365,	0366,	0327,
24449992Sbostic 	0370,	0371,	0372,	0373,	0374,	0375,	0376,	0337,
24549992Sbostic 	0340,	0341,	0342,	0343,	0344,	0345,	0346,	0347,
24649992Sbostic 	0350,	0351,	0352,	0353,	0354,	0355,	0356,	0357,
24749992Sbostic 	0360,	0361,	0362,	0363,	0364,	0365,	0366,	0367,
24849992Sbostic 	0370,	0371,	0372,	0373,	0374,	0375,	0376,	0377,
24949992Sbostic };
25049992Sbostic 
25149992Sbostic unsigned char _cmap_upper[256] = {
25249992Sbostic 	0000,	0001,	0002,	0003,	0004,	0005,	0006,	0007,
25349992Sbostic 	0010,	0011,	0012,	0013,	0014,	0015,	0016,	0017,
25449992Sbostic 	0020,	0021,	0022,	0023,	0024,	0025,	0026,	0027,
25549992Sbostic 	0030,	0031,	0032,	0033,	0034,	0035,	0036,	0037,
25649992Sbostic 	0040,	0041,	0042,	0043,	0044,	0045,	0046,	0047,
25749992Sbostic 	0050,	0051,	0052,	0053,	0054,	0055,	0056,	0057,
25849992Sbostic 	0060,	0061,	0062,	0063,	0064,	0065,	0066,	0067,
25949992Sbostic 	0070,	0071,	0072,	0073,	0074,	0075,	0076,	0077,
26049992Sbostic 	0100,	0101,	0102,	0103,	0104,	0105,	0106,	0107,
26149992Sbostic 	0110,	0111,	0112,	0113,	0114,	0115,	0116,	0117,
26249992Sbostic 	0120,	0121,	0122,	0123,	0124,	0125,	0126,	0127,
26349992Sbostic 	0130,	0131,	0132,	0133,	0134,	0135,	0136,	0137,
26449992Sbostic 	0140,	0101,	0102,	0103,	0104,	0105,	0106,	0107,
26549992Sbostic 	0110,	0111,	0112,	0113,	0114,	0115,	0116,	0117,
26649992Sbostic 	0120,	0121,	0122,	0123,	0124,	0125,	0126,	0127,
26749992Sbostic 	0130,	0131,	0132,	0173,	0174,	0175,	0176,	0177,
26849992Sbostic 	0200,	0201,	0202,	0203,	0204,	0205,	0206,	0207,
26949992Sbostic 	0210,	0211,	0212,	0213,	0214,	0215,	0216,	0217,
27049992Sbostic 	0220,	0221,	0222,	0223,	0224,	0225,	0226,	0227,
27149992Sbostic 	0230,	0231,	0232,	0233,	0234,	0235,	0236,	0237,
27249992Sbostic 	0240,	0241,	0242,	0243,	0244,	0245,	0246,	0247,
27349992Sbostic 	0250,	0251,	0252,	0253,	0254,	0255,	0256,	0257,
27449992Sbostic 	0260,	0261,	0262,	0263,	0264,	0265,	0266,	0267,
27549992Sbostic 	0270,	0271,	0272,	0273,	0274,	0275,	0276,	0277,
27649992Sbostic 	0300,	0301,	0302,	0303,	0304,	0305,	0306,	0307,
27749992Sbostic 	0310,	0311,	0312,	0313,	0314,	0315,	0316,	0317,
27849992Sbostic 	0320,	0321,	0322,	0323,	0324,	0325,	0326,	0327,
27949992Sbostic 	0330,	0331,	0332,	0333,	0334,	0335,	0336,	0337,
28049992Sbostic 	0300,	0301,	0302,	0303,	0304,	0305,	0306,	0307,
28149992Sbostic 	0310,	0311,	0312,	0313,	0314,	0315,	0316,	0317,
28249992Sbostic 	0320,	0321,	0322,	0323,	0324,	0325,	0326,	0367,
28349992Sbostic 	0330,	0331,	0332,	0333,	0334,	0335,	0336,	0377,
28449992Sbostic };
28549992Sbostic #endif /* NLS */
286