aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-11-16 20:29:39 +0000
committerRichard M. Stallman1994-11-16 20:29:39 +0000
commit91fc6e4448782f6bf594d709677ad12d110b6c69 (patch)
tree4b5158592dc857e6e98cd119d0b1cc48ca8d8a37 /src
parent5cc055623c120b0a30611c9563b6e2f71060e752 (diff)
downloademacs-91fc6e4448782f6bf594d709677ad12d110b6c69.tar.gz
emacs-91fc6e4448782f6bf594d709677ad12d110b6c69.zip
(re_opcode_t): New opcode `succeed'
(re_match_2_internal): Handle `succeed'. (regex_compile): Handle RE_NO_BACKTRACKING. (re_syntax_options): Delete initializer.
Diffstat (limited to 'src')
-rw-r--r--src/regex.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/regex.c b/src/regex.c
index 33c7ea242cd..bce02247d05 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -267,6 +267,9 @@ typedef enum
267{ 267{
268 no_op = 0, 268 no_op = 0,
269 269
270 /* Succeed right away--no more backtracking. */
271 succeed,
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
@@ -834,7 +837,9 @@ print_double_string (where, string1, size1, string2, size2)
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. */
837reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; 840/* This has no initializer because initialized variables in Emacs
841 become read-only after dumping. */
842reg_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
@@ -2470,6 +2475,11 @@ regex_compile (pattern, size, syntax, bufp)
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. */
@@ -3652,6 +3662,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
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. */
@@ -3752,6 +3763,9 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
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