1 /* $OpenBSD: chrdef.h,v 1.7 2005/06/14 18:14:40 kjell Exp $ */
3 /* This file is in the public domain. */
6 * sys/default/chardef.h: character set specific #defines for Mg 2a
7 * Warning: System specific ones exist
11 * Casting should be at least as efficient as anding with 0xff,
12 * and won't have the size problems. Override in sysdef.h if no
15 #define CHARMASK(c) ((unsigned char) (c))
18 * These flags, and the macros below them,
19 * make up a do-it-yourself set of "ctype" macros that
20 * understand the DEC multinational set, and let me ask
21 * a slightly different set of questions.
23 #define _MG_W 0x01 /* Word. */
24 #define _MG_U 0x02 /* Upper case letter. */
25 #define _MG_L 0x04 /* Lower case letter. */
26 #define _MG_C 0x08 /* Control. */
27 #define _MG_P 0x10 /* end of sentence punctuation */
28 #define _MG_D 0x20 /* is decimal digit */
30 #define ISWORD(c) ((cinfo[CHARMASK(c)]&_MG_W)!=0)
31 #define ISCTRL(c) ((cinfo[CHARMASK(c)]&_MG_C)!=0)
32 #define ISUPPER(c) ((cinfo[CHARMASK(c)]&_MG_U)!=0)
33 #define ISLOWER(c) ((cinfo[CHARMASK(c)]&_MG_L)!=0)
34 #define ISEOSP(c) ((cinfo[CHARMASK(c)]&_MG_P)!=0)
35 #define ISDIGIT(c) ((cinfo[CHARMASK(c)]&_MG_D)!=0)
36 #define TOUPPER(c) ((c)-0x20)
37 #define TOLOWER(c) ((c)+0x20)
40 * Generally useful thing for chars
42 #define CCHR(x) ((x) ^ 0x40) /* CCHR('?') == DEL */
45 #define METACH CCHR('[')