/* This file contains the tables and initialization function for elvis'
* version of <ctype.h>. It should be portable.
/* This function initializes the tables used by the ctype macros. It should
* be called at the start of the program. It can be called again anytime you
* wish to change the non-standard "flipcase" list. The "flipcase" list is
* a string of characters which are taken to be lowercase/uppercase pairs.
* If you don't want to use any special flipcase characters, then pass an
uchar
*flipcase
; /* list of non-standard lower/upper letter pairs */
/* reset all of the tables */
for (i
= 0; i
< 256; i
++)
_ct_toupper
[i
] = _ct_tolower
[i
] = i
;
for (scan
= (uchar
*)"0123456789"; *scan
; scan
++)
_ct_ctypes
[*scan
] |= _CT_DIGIT
| _CT_ALNUM
;
for (scan
= (uchar
*)" \t\n\r\f"; *scan
; scan
++)
_ct_ctypes
[*scan
] |= _CT_SPACE
;
/* add the standard ASCII letters */
for (scan
= (uchar
*)"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"; *scan
; scan
+= 2)
_ct_ctypes
[scan
[0]] |= _CT_LOWER
| _CT_ALNUM
;
_ct_ctypes
[scan
[1]] |= _CT_UPPER
| _CT_ALNUM
;
_ct_toupper
[scan
[0]] = scan
[1];
_ct_tolower
[scan
[1]] = scan
[0];
/* add the flipcase letters */
for (scan
= flipcase
; scan
[0] && scan
[1]; scan
+= 2)
_ct_ctypes
[scan
[0]] |= _CT_LOWER
| _CT_ALNUM
;
_ct_ctypes
[scan
[1]] |= _CT_UPPER
| _CT_ALNUM
;
_ct_toupper
[scan
[0]] = scan
[1];
_ct_tolower
[scan
[1]] = scan
[0];
/* include '_' in the isalnum() list */
_ct_ctypes
[UCHAR('_')] |= _CT_ALNUM
;
/* !!! find the control characters in an ASCII-dependent way */
for (i
= 0; i
< ' '; i
++)
_ct_ctypes
[i
] |= _CT_CNTRL
;
_ct_ctypes
[127] |= _CT_CNTRL
;
_ct_ctypes
[255] |= _CT_CNTRL
;