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 12:15:08 +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, ALPHA|UPPER|SPECL,
|
2023-10-08 11:39:38 +00:00
|
|
|
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,
|
2023-10-08 12:15:08 +00:00
|
|
|
DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH,
|
2023-10-08 11:39:38 +00:00
|
|
|
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,
|
2023-10-08 12:15:08 +00:00
|
|
|
LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH,
|
|
|
|
DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER,
|
|
|
|
ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER,
|
|
|
|
ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER,
|
|
|
|
ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER,
|
|
|
|
ALPHA|LOWER, SPECL|GRAPH|PUNCT, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|SPECL, ALPHA|SPECL, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT,
|
|
|
|
GRAPH, GRAPH|SPECL, GRAPH|SPECL, DIGIT|LOWER|SPECL, SPECL|GRAPH, DIGIT|LOWER|SPECL, GRAPH|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER|SPECL, ALPHA|UPPER|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER, ALPHA|UPPER|SPECL, GRAPH|SPECL, GRAPH|SPECL,
|
|
|
|
GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL,
|
|
|
|
GRAPH|SPECL, GRAPH|SPECL, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH
|
2023-10-07 23:32:30 +00:00
|
|
|
};
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char isalnum(unsigned char c) {
|
|
|
|
return tab[c] & (ALPHA | DIGIT);
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char isalpha(unsigned char c) {
|
|
|
|
return tab[c] & ALPHA;
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char islower(unsigned char c) {
|
|
|
|
return tab[c] & LOWER;
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char isupper(unsigned char c) {
|
|
|
|
return tab[c] & UPPER;
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char isdigit(unsigned char c) {
|
|
|
|
return tab[c] & DIGIT;
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char isspecl(unsigned char c) {
|
|
|
|
return tab[c] & SPECL;
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char isspace(unsigned char c) {
|
|
|
|
return tab[c] & SPACE;
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char ispunct(unsigned char c) {
|
|
|
|
return tab[c] & PUNCT;
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
2023-10-08 12:15:08 +00:00
|
|
|
unsigned char isgraph(unsigned char c) {
|
|
|
|
return tab[c] & GRAPH;
|
2023-10-07 23:32:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|