… | |
… | |
6 | |
6 | |
7 | /* C o n f i g u r a t i o n |
7 | /* C o n f i g u r a t i o n |
8 | */ |
8 | */ |
9 | |
9 | |
10 | #define SAFE_CHECKS /* Regexp's with syntax errors will core dump if |
10 | #define SAFE_CHECKS /* Regexp's with syntax errors will core dump if |
11 | * this is undefined. |
11 | * this is undefined. |
12 | */ |
12 | */ |
13 | |
13 | |
14 | #define RE_TOKEN_MAX 64 /* Max amount of tokens in a regexp. |
14 | #define RE_TOKEN_MAX 64 /* Max amount of tokens in a regexp. |
15 | * Each token uses ~264 bytes. They are allocated |
15 | * Each token uses ~264 bytes. They are allocated |
16 | * as needed, but never de-allocated. |
16 | * as needed, but never de-allocated. |
17 | * E.g. [A-Za-z0-9_] counts as one token, so 64 |
17 | * E.g. [A-Za-z0-9_] counts as one token, so 64 |
18 | * should be plenty for most purposes. |
18 | * should be plenty for most purposes. |
19 | */ |
19 | */ |
20 | |
20 | |
21 | /* D o n o t c h a n g e b e l o w |
21 | /* D o n o t c h a n g e b e l o w |
22 | */ |
22 | */ |
23 | |
|
|
24 | #ifdef uchar |
|
|
25 | # undef uchar |
|
|
26 | #endif |
|
|
27 | #ifdef Boolean |
|
|
28 | # undef Boolean |
|
|
29 | #endif |
|
|
30 | #ifdef True |
|
|
31 | # undef True |
|
|
32 | #endif |
|
|
33 | #ifdef False |
|
|
34 | # undef False |
|
|
35 | #endif |
|
|
36 | |
|
|
37 | #define uchar unsigned char |
|
|
38 | #define Boolean uchar |
|
|
39 | #define True 1 /* Changing this value will break the code */ |
|
|
40 | #define False 0 |
|
|
41 | |
23 | |
42 | typedef enum { |
24 | typedef enum { |
43 | sel_any, /* corresponds to e.g. . */ |
25 | sel_any, /* corresponds to e.g. . */ |
44 | sel_end, /* " $ */ |
26 | sel_end, /* " $ */ |
45 | sel_single, /* " q */ |
27 | sel_single, /* " q */ |
… | |
… | |
57 | } repetetion_type; |
39 | } repetetion_type; |
58 | |
40 | |
59 | typedef struct { |
41 | typedef struct { |
60 | selection_type type; |
42 | selection_type type; |
61 | union { |
43 | union { |
62 | uchar single; |
44 | unsigned char single; |
63 | struct { |
45 | struct { |
64 | uchar low, high; |
46 | unsigned char low, high; |
65 | } range; |
47 | } range; |
66 | Boolean array[UCHAR_MAX]; |
48 | bool array[UCHAR_MAX]; |
67 | } u; |
49 | } u; |
68 | repetetion_type repeat; |
50 | repetetion_type repeat; |
69 | } selection; |
51 | } selection; |