| 8 |
|
|
| 9 |
Written by: Philip Hazel <ph10@cam.ac.uk> |
Written by: Philip Hazel <ph10@cam.ac.uk> |
| 10 |
|
|
| 11 |
Copyright (c) 1997-1999 University of Cambridge |
Copyright (c) 1997-2000 University of Cambridge |
| 12 |
|
|
| 13 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| 14 |
Permission is granted to anyone to use this software for any purpose on any |
Permission is granted to anyone to use this software for any purpose on any |
| 81 |
|
|
| 82 |
for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i); |
for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i); |
| 83 |
|
|
| 84 |
/* Then the character class tables */ |
/* Then the character class tables. Don't try to be clever and save effort |
| 85 |
|
on exclusive ones - in some locales things may be different. */ |
| 86 |
|
|
| 87 |
memset(p, 0, cbit_length); |
memset(p, 0, cbit_length); |
| 88 |
for (i = 0; i < 256; i++) |
for (i = 0; i < 256; i++) |
| 89 |
{ |
{ |
| 90 |
if (isdigit(i)) p[cbit_digit + i/8] |= 1 << (i&7); |
if (isdigit(i)) |
| 91 |
if (isalnum(i) || i == '_') |
{ |
| 92 |
p[cbit_word + i/8] |= 1 << (i&7); |
p[cbit_digit + i/8] |= 1 << (i&7); |
| 93 |
|
p[cbit_word + i/8] |= 1 << (i&7); |
| 94 |
|
} |
| 95 |
|
if (isupper(i)) |
| 96 |
|
{ |
| 97 |
|
p[cbit_upper + i/8] |= 1 << (i&7); |
| 98 |
|
p[cbit_word + i/8] |= 1 << (i&7); |
| 99 |
|
} |
| 100 |
|
if (islower(i)) |
| 101 |
|
{ |
| 102 |
|
p[cbit_lower + i/8] |= 1 << (i&7); |
| 103 |
|
p[cbit_word + i/8] |= 1 << (i&7); |
| 104 |
|
} |
| 105 |
|
if (i == '_') p[cbit_word + i/8] |= 1 << (i&7); |
| 106 |
if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7); |
if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7); |
| 107 |
|
if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7); |
| 108 |
|
if (isgraph(i)) p[cbit_graph + i/8] |= 1 << (i&7); |
| 109 |
|
if (isprint(i)) p[cbit_print + i/8] |= 1 << (i&7); |
| 110 |
|
if (ispunct(i)) p[cbit_punct + i/8] |= 1 << (i&7); |
| 111 |
|
if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1 << (i&7); |
| 112 |
} |
} |
| 113 |
p += cbit_length; |
p += cbit_length; |
| 114 |
|
|