1 #ifndef CCAN_CHARFLAG_H
2 #define CCAN_CHARFLAG_H
4 //All of these macros evaluate the argument exactly once
6 #define ccontrol(c) (charflag(c) & CF_CONTROL) //Weird characters that shouldn't be in text
7 #define cspace(c) (charflag(c) & CF_SPACE) //Space, tab, vertical tab, form feed
8 #define creturn(c) (charflag(c) & CF_RETURN) //Newline
9 #define cwhite(c) (charflag(c) & CF_WHITE) //cspace or creturn
10 #define cdigit(c) (charflag(c) & CF_DIGIT) //0-9
11 #define cletter(c) (charflag(c) & CF_LETTER) //A-Za-z
12 #define chex(c) (charflag(c) & CF_HEX) //0-9A-Fa-f
13 #define csymbol(c) (charflag(c) & CF_SYMBOL)
14 // !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
15 //If it's ASCII, prints a non-blank character, and is not a digit or letter, it's a symbol
16 #define cextended(c) (charflag(c) == 0) //Characters >= 128
20 All charflag macros should evaluate exactly once
24 extern unsigned char charflag[256];
25 #define charflag(c) (charflag[(unsigned int)(unsigned char)(c)])
27 #define CF_CONTROL ((unsigned char) 1)
28 #define CF_SPACE ((unsigned char) 2)
29 #define CF_RETURN ((unsigned char) 4)
30 #define CF_DIGIT ((unsigned char) 8)
31 #define CF_LETTER ((unsigned char) 16)
32 #define CF_HEX ((unsigned char) 32)
33 #define CF_SYMBOL ((unsigned char) 64)
35 #define CF_WHITE (CF_SPACE|CF_RETURN)