Mercurial > emacs
comparison src/regex.c @ 28279:24a23e27dac6
(enum syntaxcode): Provide default for non-Emacs.
(re_compile_fastmap, re_match_2_internal): Undo Dave's previous fix.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 23 Mar 2000 04:36:14 +0000 |
parents | 33f65d22f2a8 |
children | 9761cf2351fa |
comparison
equal
deleted
inserted
replaced
28278:85db5c5cde20 | 28279:24a23e27dac6 |
---|---|
20 USA. */ | 20 USA. */ |
21 | 21 |
22 /* TODO: | 22 /* TODO: |
23 - detect nasty infinite loops like "\\(\\)+?ab" when matching "ac". | 23 - detect nasty infinite loops like "\\(\\)+?ab" when matching "ac". |
24 - use analyze_first to optimize non-empty loops | 24 - use analyze_first to optimize non-empty loops |
25 - reduce code duplication | |
26 - optimize succeed_n and jump_n away when possible | 25 - optimize succeed_n and jump_n away when possible |
27 - clean up multibyte issues | 26 - clean up multibyte issues |
28 - structure the opcode space into opcode+flag. | 27 - structure the opcode space into opcode+flag. |
29 - merge with glic's regex.[ch] | 28 - merge with glic's regex.[ch] |
30 | 29 |
131 #endif | 130 #endif |
132 #endif | 131 #endif |
133 | 132 |
134 /* Define the syntax stuff for \<, \>, etc. */ | 133 /* Define the syntax stuff for \<, \>, etc. */ |
135 | 134 |
136 /* This must be nonzero for the wordchar pattern | 135 /* Sword must be nonzero for the wordchar pattern commands in re_match_2. */ |
137 commands in re_match_2. */ | 136 enum syntaxcode { Swhitespace = 0, Sword = 1 }; |
138 #ifndef Sword | |
139 #define Sword 1 | |
140 #endif | |
141 | 137 |
142 #ifdef SWITCH_ENUM_BUG | 138 #ifdef SWITCH_ENUM_BUG |
143 #define SWITCH_ENUM_CAST(x) ((int)(x)) | 139 #define SWITCH_ENUM_CAST(x) ((int)(x)) |
144 #else | 140 #else |
145 #define SWITCH_ENUM_CAST(x) (x) | 141 #define SWITCH_ENUM_CAST(x) (x) |
3460 if (!fastmap) break; | 3456 if (!fastmap) break; |
3461 #ifndef emacs | 3457 #ifndef emacs |
3462 not = (re_opcode_t)p[-1] == notsyntaxspec; | 3458 not = (re_opcode_t)p[-1] == notsyntaxspec; |
3463 k = *p++; | 3459 k = *p++; |
3464 for (j = 0; j < (1 << BYTEWIDTH); j++) | 3460 for (j = 0; j < (1 << BYTEWIDTH); j++) |
3465 if ((SYNTAX (j) == (re_opcode_t) k) ^ not) | 3461 if ((SYNTAX (j) == (enum syntaxcode) k) ^ not) |
3466 fastmap[j] = 1; | 3462 fastmap[j] = 1; |
3467 break; | 3463 break; |
3468 #else /* emacs */ | 3464 #else /* emacs */ |
3469 /* This match depends on text properties. These end with | 3465 /* This match depends on text properties. These end with |
3470 aborting optimizations. */ | 3466 aborting optimizations. */ |
5361 else | 5357 else |
5362 /* everything should be handled as ASCII, even though it | 5358 /* everything should be handled as ASCII, even though it |
5363 looks like multibyte form. */ | 5359 looks like multibyte form. */ |
5364 c = *d, len = 1; | 5360 c = *d, len = 1; |
5365 | 5361 |
5366 if ((SYNTAX (c) != (re_opcode_t) mcnt) ^ not) | 5362 if ((SYNTAX (c) != (enum syntaxcode) mcnt) ^ not) |
5367 goto fail; | 5363 goto fail; |
5368 d += len; | 5364 d += len; |
5369 } | 5365 } |
5370 break; | 5366 break; |
5371 | 5367 |