1 /* $OpenBSD: cinfo.c,v 1.16 2011/11/28 04:41:39 lum Exp $ */
3 /* This file is in the public domain. */
6 * Character class tables.
7 * Do it yourself character classification
8 * macros, that understand the multinational character set,
9 * and let me ask some questions the standard macros (in
10 * ctype.h) don't let you ask.
15 * This table, indexed by a character drawn
16 * from the 256 member character set, is used by my
17 * own character type macros to answer questions about the
18 * type of a character. It handles the full multinational
19 * character set, and lets me ask some questions that the
20 * standard "ctype" macros cannot ask.
23 * Due to incompatible behaviour between "standard" emacs and
24 * ctags word traversing, '_' character's value is changed on
25 * the fly in ctags mode, hence non-const.
28 _MG_C, _MG_C, _MG_C, _MG_C, /* 0x0X */
29 _MG_C, _MG_C, _MG_C, _MG_C,
30 _MG_C, _MG_C, _MG_C, _MG_C,
31 _MG_C, _MG_C, _MG_C, _MG_C,
32 _MG_C, _MG_C, _MG_C, _MG_C, /* 0x1X */
33 _MG_C, _MG_C, _MG_C, _MG_C,
34 _MG_C, _MG_C, _MG_C, _MG_C,
35 _MG_C, _MG_C, _MG_C, _MG_C,
36 0, _MG_P, 0, 0, /* 0x2X */
37 _MG_W, _MG_W, 0, _MG_W,
40 _MG_D | _MG_W, _MG_D | _MG_W, _MG_D | _MG_W, _MG_D | _MG_W, /* 0x3X */
41 _MG_D | _MG_W, _MG_D | _MG_W, _MG_D | _MG_W, _MG_D | _MG_W,
42 _MG_D | _MG_W, _MG_D | _MG_W, 0, 0,
44 0, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, /* 0x4X */
45 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
46 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
47 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
48 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, /* 0x5X */
49 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
50 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, 0,
52 0, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, /* 0x6X */
53 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
54 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
55 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
56 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, /* 0x7X */
57 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
58 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, 0,
60 0, 0, 0, 0, /* 0x8X */
64 0, 0, 0, 0, /* 0x9X */
68 0, 0, 0, 0, /* 0xAX */
72 0, 0, 0, 0, /* 0xBX */
76 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, /* 0xCX */
77 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
78 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
79 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
80 0, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, /* 0xDX */
81 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
82 _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W, _MG_U | _MG_W,
83 _MG_U | _MG_W, _MG_U | _MG_W, 0, _MG_W,
84 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, /* 0xEX */
85 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
86 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
87 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
88 0, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, /* 0xFX */
89 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
90 _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W, _MG_L | _MG_W,
91 _MG_L | _MG_W, _MG_L | _MG_W, 0, 0
95 * Find the name of a keystroke. Needs to be changed to handle 8-bit printing
96 * characters and function keys better. Returns a pointer to the terminating
97 * '\0'. Returns NULL on failure.
100 getkeyname(char *cp, size_t len, int k)
106 k = CHARMASK(k); /* sign extended char */
122 break; /* yuck again */
128 if (k >= KFIRST && k <= KLAST &&
129 (np = keystrings[k - KFIRST]) != NULL)
134 *cp++ = ((k >> 6) & 7) + '0';
135 *cp++ = ((k >> 3) & 7) + '0';
136 *cp++ = (k & 7) + '0';
139 } else if (k < ' ') {
150 copied = strlcpy(cp, np, len);
153 return (cp + copied);