2023-10-07 23:32:30 +00:00
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#define NONE 0x00
|
|
|
|
#define ALPHA 0x01
|
|
|
|
#define DIGIT 0x02
|
|
|
|
#define LOWER 0x04
|
|
|
|
#define UPPER 0x08
|
|
|
|
#define SPECL 0x10
|
|
|
|
#define SPACE 0x20
|
|
|
|
#define PUNCT 0x40
|
|
|
|
#define GRAPH 0x80
|
|
|
|
|
|
|
|
// TODO.
|
|
|
|
static unsigned char tab[256] = {
|
2023-10-08 11:39:38 +00:00
|
|
|
GRAPH, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, GRAPH, GRAPH, GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL,
|
|
|
|
GRAPH|SPECL, SPECL, SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, GRAPH|SPECL, GRAPH|SPECL,
|
|
|
|
SPACE, PUNCT|SPECL, PUNCT|SPECL, SPECL|GRAPH, SPECL, SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH,
|
|
|
|
PUNCT|SPECL|GRAPH, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA,
|
2023-10-07 23:32:30 +00:00
|
|
|
|
2023-10-08 11:39:38 +00:00
|
|
|
UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, SPECL|GRAPH|ALPHA, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH,
|
|
|
|
PUNCT|SPECL|GRAPH, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA,
|
|
|
|
LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, NONE, NONE, NONE, NONE, NONE,
|
2023-10-07 23:32:30 +00:00
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
|
|
|
|
|
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
|
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
|
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
|
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
|
|
|
|
|
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
|
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
|
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
|
|
|
|
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
int isalnum(int c) {
|
|
|
|
return tab[c & 0xFF] & (ALPHA | DIGIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
int isalpha(int c) {
|
|
|
|
return tab[c & 0xFF] & ALPHA;
|
|
|
|
}
|
|
|
|
|
|
|
|
int islower(int c) {
|
|
|
|
return tab[c & 0xFF] & LOWER;
|
|
|
|
}
|
|
|
|
|
|
|
|
int isupper(int c) {
|
|
|
|
return tab[c & 0xFF] & UPPER;
|
|
|
|
}
|
|
|
|
|
|
|
|
int isdigit(int c) {
|
|
|
|
return tab[c & 0xFF] & DIGIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
int isspecl(int c) {
|
|
|
|
return tab[c & 0xFF] & SPECL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int isspace(int c) {
|
|
|
|
return tab[c & 0xFF] & SPACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ispunct(int c) {
|
|
|
|
return tab[c & 0xFF] & PUNCT;
|
|
|
|
}
|
|
|
|
|
|
|
|
int isgraph(int c) {
|
|
|
|
return tab[c & 0xFF] & GRAPH;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|