home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / Shells / tcsh / Source / sh.char.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-21  |  10.8 KB  |  315 lines

  1. /* $Header: /u/christos/src/tcsh-6.03/RCS/sh.char.c,v 3.6 1992/06/16 20:46:26 christos Exp $ */
  2. /*
  3.  * sh.char.c: Character classification tables
  4.  */
  5. /*-
  6.  * Copyright (c) 1980, 1991 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions
  11.  * are met:
  12.  * 1. Redistributions of source code must retain the above copyright
  13.  *    notice, this list of conditions and the following disclaimer.
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in the
  16.  *    documentation and/or other materials provided with the distribution.
  17.  * 3. All advertising materials mentioning features or use of this software
  18.  *    must display the following acknowledgement:
  19.  *    This product includes software developed by the University of
  20.  *    California, Berkeley and its contributors.
  21.  * 4. Neither the name of the University nor the names of its contributors
  22.  *    may be used to endorse or promote products derived from this software
  23.  *    without specific prior written permission.
  24.  *
  25.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  26.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  29.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  31.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  32.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  34.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  35.  * SUCH DAMAGE.
  36.  */
  37. #include "sh.h"
  38.  
  39. RCSID("$Id: sh.char.c,v 3.6 1992/06/16 20:46:26 christos Exp $")
  40.  
  41. #include "sh.char.h"
  42.  
  43. unsigned short _cmap[256] = {
  44. /*      0 nul          1 soh          2 stx          3 etx    */
  45.     _CTR,        _CTR,        _CTR,        _CTR,
  46.  
  47. /*      4 eot          5 enq          6 ack          7 bel    */
  48.     _CTR,        _CTR,        _CTR,        _CTR,
  49.  
  50. /*      8 bs          9 ht         10 nl         11 vt    */
  51.     _CTR,        _CTR|_SP|_META,    _CTR|_NL|_META,    _CTR,
  52.  
  53. /*     12 np         13 cr         14 so         15 si    */
  54.     _CTR,        _CTR,        _CTR,        _CTR,
  55.  
  56. /*     16 dle         17 dc1         18 dc2         19 dc3    */
  57.     _CTR,        _CTR,        _CTR,        _CTR,
  58.  
  59. /*     20 dc4         21 nak         22 syn         23 etb    */
  60.     _CTR,        _CTR,        _CTR,        _CTR,
  61.  
  62. /*     24 can         25 em         26 sub         27 esc    */
  63.     _CTR,        _CTR,        _CTR,        _CTR,
  64.  
  65. /*     28 fs         29 gs         30 rs         31 us    */
  66.     _CTR,        _CTR,        _CTR,        _CTR,
  67.  
  68. /*     32 sp         33 !         34 "         35 #    */
  69.     _SP|_META,    _PUN,        _Q|_PUN,    _META|_PUN,
  70.  
  71. /*     36 $         37 %         38 &         39 '    */
  72.     _DOL|_PUN,    _PUN,        _META|_CMD|_PUN,_Q|_PUN,
  73.  
  74. /*     40 (         41 )         42 *         43 +    */
  75.     _META|_CMD|_PUN,_META|_PUN,    _GLOB|_PUN,    _PUN,
  76.  
  77. /*     44 ,         45 -         46 .         47 /    */
  78.     _PUN,        _PUN,        _PUN,        _PUN,
  79.  
  80. /*     48 0         49 1         50 2         51 3    */
  81.     _DIG|_XD,    _DIG|_XD,    _DIG|_XD,    _DIG|_XD,
  82.  
  83. /*     52 4         53 5         54 6         55 7    */
  84.     _DIG|_XD,    _DIG|_XD,    _DIG|_XD,    _DIG|_XD,
  85.  
  86. /*     56 8         57 9         58 :         59 ;    */
  87.     _DIG|_XD,    _DIG|_XD,    _PUN,        _META|_CMD|_PUN,
  88.  
  89. /*     60 <         61 =         62 >         63 ?    */
  90.     _META|_PUN,    _PUN,        _META|_PUN,    _GLOB|_PUN,
  91.  
  92. /*     64 @         65 A         66 B         67 C    */
  93.     _PUN,        _LET|_UP|_XD,    _LET|_UP|_XD,    _LET|_UP|_XD,
  94.  
  95. /*     68 D         69 E         70 F         71 G    */
  96.     _LET|_UP|_XD,    _LET|_UP|_XD,    _LET|_UP|_XD,    _LET|_UP,
  97.  
  98. /*     72 H         73 I         74 J         75 K    */
  99.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  100.  
  101. /*     76 L         77 M         78 N         79 O    */
  102.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  103.  
  104. /*     80 P         81 Q         82 R         83 S    */
  105.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  106.  
  107. /*     84 T         85 U         86 V         87 W    */
  108.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  109.  
  110. /*     88 X         89 Y         90 Z         91 [    */
  111.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _GLOB|_PUN,
  112.  
  113. /*     92 \         93 ]         94 ^         95 _    */
  114.     _ESC|_PUN,    _PUN,        _PUN,        _PUN,
  115.  
  116. /*     96 `         97 a         98 b         99 c    */
  117.   _Q1|_GLOB|_META|_PUN,    _LET|_DOW|_XD,    _LET|_DOW|_XD,    _LET|_DOW|_XD,
  118.  
  119. /*    100 d        101 e        102 f        103 g    */
  120.     _LET|_DOW|_XD,    _LET|_DOW|_XD,    _LET|_DOW|_XD,    _LET|_DOW,
  121.  
  122. /*    104 h        105 i        106 j        107 k    */
  123.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  124.  
  125. /*    108 l        109 m        110 n        111 o    */
  126.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  127.  
  128. /*    112 p        113 q        114 r        115 s    */
  129.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  130.  
  131. /*    116 t        117 u        118 v        119 w    */
  132.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  133.  
  134. /*    120 x        121 y        122 z        123 {    */
  135.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _GLOB|_PUN,
  136.  
  137. /*    124 |        125 }        126 ~        127 del    */
  138.     _META|_CMD|_PUN,_PUN,        _PUN,        _CTR,
  139.  
  140. #ifdef SHORT_STRINGS
  141. /****************************************************************/
  142. /* 128 - 255 The below is supposedly ISO 8859/1            */
  143. /****************************************************************/
  144. /*    128 (undef)    129 (undef)    130 (undef)    131 (undef)    */
  145.     _CTR,        _CTR,        _CTR,        _CTR,
  146.  
  147. /*    132 (undef)    133 (undef)    134 (undef)    135 (undef)    */
  148.     _CTR,        _CTR,        _CTR,        _CTR,
  149.  
  150. /*    136 (undef)    137 (undef)    138 (undef)    139 (undef)    */
  151.     _CTR,        _CTR,        _CTR,        _CTR,
  152.  
  153. /*    140 (undef)    141 (undef)    142 (undef)    143 (undef)    */
  154.     _CTR,        _CTR,        _CTR,        _CTR,
  155.  
  156. /*    144 (undef)    145 (undef)    146 (undef)    147 (undef)    */
  157.     _CTR,        _CTR,        _CTR,        _CTR,
  158.  
  159. /*    148 (undef)    149 (undef)    150 (undef)    151 (undef)    */
  160.     _CTR,        _CTR,        _CTR,        _CTR,
  161.  
  162. /*    152 (undef)    153 (undef)    154 (undef)    155 (undef)    */
  163.     _CTR,        _CTR,        _CTR,        _CTR,
  164.  
  165. /*    156 (undef)    157 (undef)    158 (undef)    159 (undef)    */
  166.     _CTR,        _CTR,        _CTR,        _CTR,
  167.  
  168. /*    160 nobreakspace 161 exclamdown    162 cent    163 sterling    */
  169.     _SP,        _PUN,        _PUN,        _PUN,
  170.  
  171. /*    164 currency    165 yen        166 brokenbar    167 section    */
  172.     _PUN,        _PUN,        _PUN,        _PUN,
  173.  
  174. /*    168 diaeresis    169 copyright    170 ordfeminine    171 guillemotleft*/
  175.     _PUN,        _PUN,        _PUN,        _PUN,
  176.  
  177. /*    172 notsign    173 hyphen    174 registered    175 macron    */
  178.     _PUN,        _PUN,        _PUN,        _PUN,
  179.  
  180. /*    176 degree    177 plusminus    178 twosuperior    179 threesuperior*/
  181.     _PUN,        _PUN,        _PUN,        _PUN,
  182.  
  183. /*    180 acute    181 mu         182 paragraph    183 periodcentered*/
  184.     _PUN,        _PUN, /*XXX*/    _PUN,        _PUN,
  185.  
  186. /*    184 cedilla    185 onesuperior    186 masculine    187 guillemotright*/
  187.     _PUN,        _PUN,        _PUN,        _PUN,
  188.  
  189. /*    188 onequarter    189 onehalf    190 threequarters 191 questiondown*/
  190.     _PUN,        _PUN,        _PUN,        _PUN,
  191.  
  192. /*    192 Agrave    193 Aacute    194 Acircumflex    195 Atilde    */
  193.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  194.  
  195. /*    196 Adiaeresis    197 Aring    198 AE        199 Ccedilla    */
  196.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  197.  
  198. /*    200 Egrave    201 Eacute    202 Ecircumflex    203 Ediaeresis    */
  199.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  200.  
  201. /*    204 Igrave    205 Iacute    206 Icircumflex    207 Idiaeresis    */
  202.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  203.  
  204. /*    208 ETH        209 Ntilde    210 Ograve    211 Oacute    */
  205.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  206.  
  207. /*    212 Ocircumflex    213 Otilde    214 Odiaeresis    215 multiply    */
  208.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _PUN,
  209.  
  210. /*    216 Ooblique    217 Ugrave    218 Uacute    219 Ucircumflex    */
  211.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_UP,
  212.  
  213. /*    220 Udiaeresis    221 Yacute    222 THORN    223 ssharp    */
  214.     _LET|_UP,    _LET|_UP,    _LET|_UP,    _LET|_DOW,
  215.  
  216. /*    224 agrave    225 aacute    226 acircumflex    227 atilde    */
  217.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  218.  
  219. /*    228 adiaeresis    229 aring    230 ae        231 ccedilla    */
  220.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  221.  
  222. /*    232 egrave    233 eacute    234 ecircumflex    235 ediaeresis    */
  223.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  224.  
  225. /*    236 igrave    237 iacute    238 icircumflex    239 idiaeresis    */
  226.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  227.  
  228. /*    240 eth        241 ntilde    242 ograve    243 oacute    */
  229.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  230.  
  231. /*    244 ocircumflex    245 otilde    246 odiaeresis    247 division    */
  232.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _PUN,
  233.  
  234. /*    248 oslash    249 ugrave    250 uacute    251 ucircumflex    */
  235.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  236.  
  237. /*    252 udiaeresis    253 yacute    254 thorn    255 ydiaeresis    */
  238.     _LET|_DOW,    _LET|_DOW,    _LET|_DOW,    _LET|_DOW,
  239. #endif /* SHORT_STRINGS */
  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.