Mercurial > emacs
comparison src/regex.c @ 9983:ef6e1637c777
(re_opcode_t): New opcode `succeed'
(re_match_2_internal): Handle `succeed'.
(regex_compile): Handle RE_NO_BACKTRACKING.
(re_syntax_options): Delete initializer.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 16 Nov 1994 20:29:39 +0000 |
parents | 96a592ccb751 |
children | 659346eafd79 |
comparison
equal
deleted
inserted
replaced
9982:65d2d56726ea | 9983:ef6e1637c777 |
---|---|
264 arguments. Zero bytes may appear in the compiled regular expression. */ | 264 arguments. Zero bytes may appear in the compiled regular expression. */ |
265 | 265 |
266 typedef enum | 266 typedef enum |
267 { | 267 { |
268 no_op = 0, | 268 no_op = 0, |
269 | |
270 /* Succeed right away--no more backtracking. */ | |
271 succeed, | |
269 | 272 |
270 /* Followed by one byte giving n, then by n literal bytes. */ | 273 /* Followed by one byte giving n, then by n literal bytes. */ |
271 exactn, | 274 exactn, |
272 | 275 |
273 /* Matches any (more or less) character. */ | 276 /* Matches any (more or less) character. */ |
832 #endif /* not DEBUG */ | 835 #endif /* not DEBUG */ |
833 | 836 |
834 /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can | 837 /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can |
835 also be assigned to arbitrarily: each pattern buffer stores its own | 838 also be assigned to arbitrarily: each pattern buffer stores its own |
836 syntax, so it can be changed between regex compilations. */ | 839 syntax, so it can be changed between regex compilations. */ |
837 reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; | 840 /* This has no initializer because initialized variables in Emacs |
841 become read-only after dumping. */ | |
842 reg_syntax_t re_syntax_options; | |
838 | 843 |
839 | 844 |
840 /* Specify the precise syntax of regexps for compilation. This provides | 845 /* Specify the precise syntax of regexps for compilation. This provides |
841 for compatibility for various utilities which historically have | 846 for compatibility for various utilities which historically have |
842 different, incompatible syntaxes. | 847 different, incompatible syntaxes. |
2468 STORE_JUMP (jump_past_alt, fixup_alt_jump, b); | 2473 STORE_JUMP (jump_past_alt, fixup_alt_jump, b); |
2469 | 2474 |
2470 if (!COMPILE_STACK_EMPTY) | 2475 if (!COMPILE_STACK_EMPTY) |
2471 FREE_STACK_RETURN (REG_EPAREN); | 2476 FREE_STACK_RETURN (REG_EPAREN); |
2472 | 2477 |
2478 /* If we don't want backtracking, force success | |
2479 the first time we reach the end of the compiled pattern. */ | |
2480 if (syntax & RE_NO_POSIX_BACKTRACKING) | |
2481 BUF_PUSH (succeed); | |
2482 | |
2473 free (compile_stack.stack); | 2483 free (compile_stack.stack); |
2474 | 2484 |
2475 /* We have succeeded; set the length of the buffer. */ | 2485 /* We have succeeded; set the length of the buffer. */ |
2476 bufp->used = b - bufp->buffer; | 2486 bufp->used = b - bufp->buffer; |
2477 | 2487 |
3650 regend[mcnt] = best_regend[mcnt]; | 3660 regend[mcnt] = best_regend[mcnt]; |
3651 } | 3661 } |
3652 } | 3662 } |
3653 } /* d != end_match_2 */ | 3663 } /* d != end_match_2 */ |
3654 | 3664 |
3665 succeed: | |
3655 DEBUG_PRINT1 ("Accepting match.\n"); | 3666 DEBUG_PRINT1 ("Accepting match.\n"); |
3656 | 3667 |
3657 /* If caller wants register contents data back, do it. */ | 3668 /* If caller wants register contents data back, do it. */ |
3658 if (regs && !bufp->no_sub) | 3669 if (regs && !bufp->no_sub) |
3659 { | 3670 { |
3750 currently have n == 0. */ | 3761 currently have n == 0. */ |
3751 case no_op: | 3762 case no_op: |
3752 DEBUG_PRINT1 ("EXECUTING no_op.\n"); | 3763 DEBUG_PRINT1 ("EXECUTING no_op.\n"); |
3753 break; | 3764 break; |
3754 | 3765 |
3766 case succeed: | |
3767 DEBUG_PRINT1 ("EXECUTING succeed.\n"); | |
3768 goto succeed; | |
3755 | 3769 |
3756 /* Match the next n pattern characters exactly. The following | 3770 /* Match the next n pattern characters exactly. The following |
3757 byte in the pattern defines n, and the n bytes after that | 3771 byte in the pattern defines n, and the n bytes after that |
3758 are the characters to match. */ | 3772 are the characters to match. */ |
3759 case exactn: | 3773 case exactn: |