emacs-diffs
[Top][All Lists]
Advanced

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

master 0e6ac3ffd40: ; cperl-mode: Avoid excessive regexp backtracking (B


From: Harald Jörg
Subject: master 0e6ac3ffd40: ; cperl-mode: Avoid excessive regexp backtracking (Bug#8077)
Date: Tue, 4 Jul 2023 11:45:05 -0400 (EDT)

branch: master
commit 0e6ac3ffd403d811244760f7ba6dd1997dd18bcb
Author: Harald Jörg <haj@posteo.de>
Commit: Harald Jörg <haj@posteo.de>

    ; cperl-mode: Avoid excessive regexp backtracking (Bug#8077)
    
    * lisp/progmodes/cperl-mode.el (defconst): Add a word-start
    assertion to cperl--single-attribute-rx
    (cperl-after-sub-regexp): Dito
    (cperl-init-faces): shorten matches of incomplete sub declarations
---
 lisp/progmodes/cperl-mode.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 54547c4668a..809a7274a25 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -1305,7 +1305,8 @@ or \"${ foo }\" will not.")
     "A sequence for recommended version number schemes in Perl.")
 
   (defconst cperl--single-attribute-rx
-    `(sequence ,cperl--basic-identifier-rx
+    `(sequence word-start
+               ,cperl--basic-identifier-rx
                (optional (sequence "("
                           (0+ (not (in ")")))
                           ")")))
@@ -1552,7 +1553,7 @@ the last)."
        (if attr (concat
                  "\\("
                     cperl-maybe-white-and-comment-rex ; whitespace-comments
-                    "\\(\\sw\\|_\\)+"  ; attr-name
+                    "\\(\\<\\sw\\|_\\)+"       ; attr-name
                     ;; attr-arg (1 level of internal parens allowed!)
                     "\\((\\(\\\\.\\|[^\\()]\\|([^\\()]*)\\)*)\\)?"
                     "\\("              ; optional : (XXX allows trailing???)
@@ -6003,7 +6004,11 @@ default function."
                                    ;; ... or the start of a "sloppy" signature
                                    (sequence (eval cperl--sloppy-signature-rx)
                                              ;; arbtrarily continue "a few 
lines"
-                                             (repeat 0 200 (not (in "{"))))))))
+                                             (repeat 0 200 (not (in "{"))))
+                                   ;; make sure we have a reasonably
+                                   ;; short match for an incomplete sub
+                                   (not (in ";{("))
+                                   buffer-end))))
                  '(1 (if (match-beginning 3)
                          'font-lock-variable-name-face
                        'font-lock-function-name-face)



reply via email to

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