diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-23 11:02:52 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-23 11:02:52 -0300 |
commit | f8e9bc1c721a0802b2260f48ced72c7e04d7b1ef (patch) | |
tree | fcd765f59c5d74574bdb21cd7a11e1f723068d87 /lptypes.h | |
parent | 9f7183c280f310c0d0b49b7b9c3b8eac297fafa7 (diff) | |
download | lpeg-f8e9bc1c721a0802b2260f48ced72c7e04d7b1ef.tar.gz lpeg-f8e9bc1c721a0802b2260f48ced72c7e04d7b1ef.tar.bz2 lpeg-f8e9bc1c721a0802b2260f48ced72c7e04d7b1ef.zip |
Towards a smaller encoding for charsets in code
Diffstat (limited to 'lptypes.h')
-rw-r--r-- | lptypes.h | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -127,19 +127,19 @@ typedef struct Charset { | |||
127 | #define MAXPATTSIZE (SHRT_MAX - 10) | 127 | #define MAXPATTSIZE (SHRT_MAX - 10) |
128 | 128 | ||
129 | 129 | ||
130 | /* size (in elements) for an instruction plus extra l bytes */ | 130 | /* size (in instructions) for l bytes (l > 0) */ |
131 | #define instsize(l) (((l) + sizeof(Instruction) - 1)/sizeof(Instruction) + 1) | 131 | #define instsize(l) (((l) - 1)/sizeof(Instruction) + 1) |
132 | 132 | ||
133 | 133 | ||
134 | /* size (in elements) for a ISet instruction */ | 134 | /* size (in elements) for a ISet instruction */ |
135 | #define CHARSETINSTSIZE instsize(CHARSETSIZE) | 135 | #define CHARSETINSTSIZE (1 + instsize(CHARSETSIZE)) |
136 | 136 | ||
137 | /* size (in elements) for a IFunc instruction */ | 137 | /* size (in elements) for a IFunc instruction */ |
138 | #define funcinstsize(p) ((p)->i.aux + 2) | 138 | #define funcinstsize(p) ((p)->i.aux + 2) |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | #define testchar(st,c) (((int)(st)[((c) >> 3)] & (1 << ((c) & 7)))) | 142 | #define testchar(st,c) ((((unsigned int)(st)[((c) >> 3)]) >> ((c) & 7)) & 1) |
143 | 143 | ||
144 | 144 | ||
145 | #endif | 145 | #endif |