emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 702d76d: Unrevert most of regexp reentrancy abort


From: Stefan Monnier
Subject: [Emacs-diffs] emacs-25 702d76d: Unrevert most of regexp reentrancy abort patch
Date: Sun, 22 Nov 2015 03:05:31 +0000

branch: emacs-25
commit 702d76dbee8447f56d01009142983f09e7507d6f
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    Unrevert most of regexp reentrancy abort patch
    
    The problem was in:
      * src/syntax.c (update_syntax_table_forward): Propertize even when 
truncated
    which is hence not unreverted.
    The rest is:
    * src/syntax.h (UPDATE_SYNTAX_TABLE_FORWARD_FAST):
    (UPDATE_SYNTAX_TABLE_FAST): Re-introduce.
    All callers in regex.c changed back to the _FAST versions.
    
    * test/automated/message-mode-tests.el: Tweak the test to rely on auto
    propertization in backward-sexp.
---
 src/regex.c                          |   18 +++++++++---------
 src/syntax.h                         |   14 ++++++++++++++
 test/automated/message-mode-tests.el |    6 +++---
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/regex.c b/src/regex.c
index dcf2864..4e00fd1 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -5945,12 +5945,12 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const_re_char *string1,
 #ifdef emacs
                ssize_t offset = PTR_TO_OFFSET (d - 1);
                ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
-               UPDATE_SYNTAX_TABLE (charpos);
+               UPDATE_SYNTAX_TABLE_FAST (charpos);
 #endif
                GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
                s1 = SYNTAX (c1);
 #ifdef emacs
-               UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1);
+               UPDATE_SYNTAX_TABLE_FORWARD_FAST (charpos + 1);
 #endif
                PREFETCH_NOLIMIT ();
                GET_CHAR_AFTER (c2, d, dummy);
@@ -5987,7 +5987,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const_re_char *string1,
 #ifdef emacs
              ssize_t offset = PTR_TO_OFFSET (d);
              ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
-             UPDATE_SYNTAX_TABLE (charpos);
+             UPDATE_SYNTAX_TABLE_FAST (charpos);
 #endif
              PREFETCH ();
              GET_CHAR_AFTER (c2, d, dummy);
@@ -6032,7 +6032,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const_re_char *string1,
 #ifdef emacs
              ssize_t offset = PTR_TO_OFFSET (d) - 1;
              ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
-             UPDATE_SYNTAX_TABLE (charpos);
+             UPDATE_SYNTAX_TABLE_FAST (charpos);
 #endif
              GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
              s1 = SYNTAX (c1);
@@ -6047,7 +6047,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const_re_char *string1,
                  PREFETCH_NOLIMIT ();
                  GET_CHAR_AFTER (c2, d, dummy);
 #ifdef emacs
-                 UPDATE_SYNTAX_TABLE_FORWARD (charpos);
+                 UPDATE_SYNTAX_TABLE_FORWARD_FAST (charpos);
 #endif
                  s2 = SYNTAX (c2);
 
@@ -6076,7 +6076,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const_re_char *string1,
 #ifdef emacs
              ssize_t offset = PTR_TO_OFFSET (d);
              ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
-             UPDATE_SYNTAX_TABLE (charpos);
+             UPDATE_SYNTAX_TABLE_FAST (charpos);
 #endif
              PREFETCH ();
              c2 = RE_STRING_CHAR (d, target_multibyte);
@@ -6119,7 +6119,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const_re_char *string1,
 #ifdef emacs
              ssize_t offset = PTR_TO_OFFSET (d) - 1;
              ssize_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
-             UPDATE_SYNTAX_TABLE (charpos);
+             UPDATE_SYNTAX_TABLE_FAST (charpos);
 #endif
              GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
              s1 = SYNTAX (c1);
@@ -6134,7 +6134,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const_re_char *string1,
                  PREFETCH_NOLIMIT ();
                  c2 = RE_STRING_CHAR (d, target_multibyte);
 #ifdef emacs
-                 UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1);
+                 UPDATE_SYNTAX_TABLE_FORWARD_FAST (charpos + 1);
 #endif
                  s2 = SYNTAX (c2);
 
@@ -6157,7 +6157,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
const_re_char *string1,
            {
              ssize_t offset = PTR_TO_OFFSET (d);
              ssize_t pos1 = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
-             UPDATE_SYNTAX_TABLE (pos1);
+             UPDATE_SYNTAX_TABLE_FAST (pos1);
            }
 #endif
            {
diff --git a/src/syntax.h b/src/syntax.h
index 06ce0ec..eb154e0 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -186,6 +186,13 @@ UPDATE_SYNTAX_TABLE_FORWARD (ptrdiff_t charpos)
                                 false, gl_state.object);
 }
 
+INLINE void
+UPDATE_SYNTAX_TABLE_FORWARD_FAST (ptrdiff_t charpos)
+{
+  if (parse_sexp_lookup_properties && charpos >= gl_state.e_property)
+    update_syntax_table (charpos + gl_state.offset, 1, false, gl_state.object);
+}
+
 /* Make syntax table state (gl_state) good for CHARPOS, assuming it is
    currently good for a position after CHARPOS.  */
 
@@ -205,6 +212,13 @@ UPDATE_SYNTAX_TABLE (ptrdiff_t charpos)
   UPDATE_SYNTAX_TABLE_FORWARD (charpos);
 }
 
+INLINE void
+UPDATE_SYNTAX_TABLE_FAST (ptrdiff_t charpos)
+{
+  UPDATE_SYNTAX_TABLE_BACKWARD (charpos);
+  UPDATE_SYNTAX_TABLE_FORWARD_FAST (charpos);
+}
+
 /* Set up the buffer-global syntax table.  */
 
 INLINE void
diff --git a/test/automated/message-mode-tests.el 
b/test/automated/message-mode-tests.el
index 49a72b0..790b5c1 100644
--- a/test/automated/message-mode-tests.el
+++ b/test/automated/message-mode-tests.el
@@ -40,9 +40,9 @@
                   "and here's a closer ")
           (let ((last-command-event ?\)))
             (ert-simulate-command '(self-insert-command 1)))
-          ;; Syntax propertization doesn't kick in batch mode
-          (when noninteractive
-            (syntax-propertize (point-max)))
+          ;; Auto syntax propertization doesn't kick in until
+          ;; parse-sexp-lookup-properties is set.
+          (setq-local parse-sexp-lookup-properties t)
           (backward-sexp)
           (should (string= "here's an opener "
                            (buffer-substring-no-properties



reply via email to

[Prev in Thread] Current Thread [Next in Thread]