75 lines
3.0 KiB
C
75 lines
3.0 KiB
C
|
|
#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] = {
|
|
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,
|
|
|
|
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,
|
|
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;
|
|
}
|
|
|
|
|
|
|