3 /* This file contains the tables and initialization function for elvis'
4 * version of <ctype.h>. It should be portable.
10 uchar _ct_toupper
[256];
11 uchar _ct_tolower
[256];
12 uchar _ct_ctypes
[256];
14 /* This function initializes the tables used by the ctype macros. It should
15 * be called at the start of the program. It can be called again anytime you
16 * wish to change the non-standard "flipcase" list. The "flipcase" list is
17 * a string of characters which are taken to be lowercase/uppercase pairs.
18 * If you don't want to use any special flipcase characters, then pass an
21 void _ct_init(flipcase
)
22 uchar
*flipcase
; /* list of non-standard lower/upper letter pairs */
27 /* reset all of the tables */
28 for (i
= 0; i
< 256; i
++)
30 _ct_toupper
[i
] = _ct_tolower
[i
] = i
;
35 for (scan
= (uchar
*)"0123456789"; *scan
; scan
++)
37 _ct_ctypes
[*scan
] |= _CT_DIGIT
| _CT_ALNUM
;
40 /* add the whitespace */
41 for (scan
= (uchar
*)" \t\n\r\f"; *scan
; scan
++)
43 _ct_ctypes
[*scan
] |= _CT_SPACE
;
46 /* add the standard ASCII letters */
47 for (scan
= (uchar
*)"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"; *scan
; scan
+= 2)
49 _ct_ctypes
[scan
[0]] |= _CT_LOWER
| _CT_ALNUM
;
50 _ct_ctypes
[scan
[1]] |= _CT_UPPER
| _CT_ALNUM
;
51 _ct_toupper
[scan
[0]] = scan
[1];
52 _ct_tolower
[scan
[1]] = scan
[0];
55 /* add the flipcase letters */
56 for (scan
= flipcase
; scan
[0] && scan
[1]; scan
+= 2)
58 _ct_ctypes
[scan
[0]] |= _CT_LOWER
| _CT_ALNUM
;
59 _ct_ctypes
[scan
[1]] |= _CT_UPPER
| _CT_ALNUM
;
60 _ct_toupper
[scan
[0]] = scan
[1];
61 _ct_tolower
[scan
[1]] = scan
[0];
64 /* include '_' in the isalnum() list */
65 _ct_ctypes
[UCHAR('_')] |= _CT_ALNUM
;
67 /* !!! find the control characters in an ASCII-dependent way */
68 for (i
= 0; i
< ' '; i
++)
70 _ct_ctypes
[i
] |= _CT_CNTRL
;
72 _ct_ctypes
[127] |= _CT_CNTRL
;
73 _ct_ctypes
[255] |= _CT_CNTRL
;