Annotation of src/usr.bin/mg/chrdef.h, Revision 1.5
1.5 ! deraadt 1: /* $OpenBSD: chrdef.h,v 1.4 2002/02/14 02:50:10 vincent Exp $ */
1.3 niklas 2:
1.1 deraadt 3: /*
1.2 millert 4: * sys/default/chardef.h: character set specific #defines for Mg 2a
1.1 deraadt 5: * Warning: System specific ones exist
6: */
7:
8: /*
1.2 millert 9: * Casting should be at least as efficent as anding with 0xff,
1.1 deraadt 10: * and won't have the size problems. Override in sysdef.h if no
11: * unsigned char type.
12: */
13: #define CHARMASK(c) ((unsigned char) (c))
14:
15: /*
16: * These flags, and the macros below them,
17: * make up a do-it-yourself set of "ctype" macros that
18: * understand the DEC multinational set, and let me ask
19: * a slightly different set of questions.
20: */
1.4 vincent 21: #define _MG_W 0x01 /* Word. */
22: #define _MG_U 0x02 /* Upper case letter. */
23: #define _MG_L 0x04 /* Lower case letter. */
24: #define _MG_C 0x08 /* Control. */
25: #define _MG_P 0x10 /* end of sentence punctuation */
26: #define _MG_D 0x20 /* is decimal digit */
1.1 deraadt 27:
1.4 vincent 28: #define ISWORD(c) ((cinfo[CHARMASK(c)]&_MG_W)!=0)
29: #define ISCTRL(c) ((cinfo[CHARMASK(c)]&_MG_C)!=0)
30: #define ISUPPER(c) ((cinfo[CHARMASK(c)]&_MG_U)!=0)
31: #define ISLOWER(c) ((cinfo[CHARMASK(c)]&_MG_L)!=0)
32: #define ISEOSP(c) ((cinfo[CHARMASK(c)]&_MG_P)!=0)
33: #define ISDIGIT(c) ((cinfo[CHARMASK(c)]&_MG_D)!=0)
1.1 deraadt 34: #define TOUPPER(c) ((c)-0x20)
35: #define TOLOWER(c) ((c)+0x20)
36:
37: /*
1.2 millert 38: * Generally useful thing for chars
1.1 deraadt 39: */
40: #define CCHR(x) ((x) ^ 0x40) /* CCHR('?') == DEL */
41:
42: #ifndef METACH
1.2 millert 43: #define METACH CCHR('[')
1.1 deraadt 44: #endif
45:
1.2 millert 46: #ifdef XKEYS
47: #define K00 256
48: #define K01 257
49: #define K02 258
50: #define K03 259
51: #define K04 260
52: #define K05 261
53: #define K06 262
54: #define K07 263
55: #define K08 264
56: #define K09 265
57: #define K0A 266
58: #define K0B 267
59: #define K0C 268
60: #define K0D 269
61: #define K0E 270
62: #define K0F 271
63: #define K10 272
64: #define K11 273
65: #define K12 274
66: #define K13 275
67: #define K14 276
68: #define K15 277
69: #define K16 278
70: #define K17 279
71: #define K18 280
72: #define K19 281
73: #define K1A 282
74: #define K1B 283
75: #define K1C 284
76: #define K1D 285
77: #define K1E 286
78: #define K1F 287
1.1 deraadt 79: #endif