Annotation of src/usr.bin/mg/chrdef.h, Revision 1.9
1.9 ! bcallah 1: /* $OpenBSD: chrdef.h,v 1.8 2015/03/17 18:08:52 bcallah Exp $ */
1.7 kjell 2:
3: /* This file is in the public domain. */
1.3 niklas 4:
1.1 deraadt 5: /*
1.2 millert 6: * sys/default/chardef.h: character set specific #defines for Mg 2a
1.1 deraadt 7: * Warning: System specific ones exist
8: */
9:
10: /*
1.6 db 11: * Casting should be at least as efficient as anding with 0xff,
1.9 ! bcallah 12: * and won't have the size problems.
1.1 deraadt 13: */
14: #define CHARMASK(c) ((unsigned char) (c))
15:
16: /*
17: * These flags, and the macros below them,
18: * make up a do-it-yourself set of "ctype" macros that
19: * understand the DEC multinational set, and let me ask
20: * a slightly different set of questions.
21: */
1.4 vincent 22: #define _MG_W 0x01 /* Word. */
23: #define _MG_U 0x02 /* Upper case letter. */
24: #define _MG_L 0x04 /* Lower case letter. */
25: #define _MG_C 0x08 /* Control. */
26: #define _MG_P 0x10 /* end of sentence punctuation */
27: #define _MG_D 0x20 /* is decimal digit */
1.1 deraadt 28:
1.4 vincent 29: #define ISWORD(c) ((cinfo[CHARMASK(c)]&_MG_W)!=0)
30: #define ISCTRL(c) ((cinfo[CHARMASK(c)]&_MG_C)!=0)
31: #define ISUPPER(c) ((cinfo[CHARMASK(c)]&_MG_U)!=0)
32: #define ISLOWER(c) ((cinfo[CHARMASK(c)]&_MG_L)!=0)
33: #define ISEOSP(c) ((cinfo[CHARMASK(c)]&_MG_P)!=0)
34: #define ISDIGIT(c) ((cinfo[CHARMASK(c)]&_MG_D)!=0)
1.1 deraadt 35: #define TOUPPER(c) ((c)-0x20)
36: #define TOLOWER(c) ((c)+0x20)
37:
38: /*
1.2 millert 39: * Generally useful thing for chars
1.1 deraadt 40: */
41: #define CCHR(x) ((x) ^ 0x40) /* CCHR('?') == DEL */
42:
43: #ifndef METACH
1.2 millert 44: #define METACH CCHR('[')
1.1 deraadt 45: #endif
46:
1.2 millert 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