aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Jörg2023-07-04 17:42:05 +0200
committerHarald Jörg2023-07-04 17:43:59 +0200
commit0e6ac3ffd403d811244760f7ba6dd1997dd18bcb (patch)
treef84f5b36e71a31dafd8dbe8e2fccd2678ca1f108
parent753aaeb99c7eaa87e40c058235e31ef773babc8a (diff)
downloademacs-0e6ac3ffd403d811244760f7ba6dd1997dd18bcb.tar.gz
emacs-0e6ac3ffd403d811244760f7ba6dd1997dd18bcb.zip
; 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
-rw-r--r--lisp/progmodes/cperl-mode.el11
1 files 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.")
1305 "A sequence for recommended version number schemes in Perl.") 1305 "A sequence for recommended version number schemes in Perl.")
1306 1306
1307 (defconst cperl--single-attribute-rx 1307 (defconst cperl--single-attribute-rx
1308 `(sequence ,cperl--basic-identifier-rx 1308 `(sequence word-start
1309 ,cperl--basic-identifier-rx
1309 (optional (sequence "(" 1310 (optional (sequence "("
1310 (0+ (not (in ")"))) 1311 (0+ (not (in ")")))
1311 ")"))) 1312 ")")))
@@ -1552,7 +1553,7 @@ the last)."
1552 (if attr (concat 1553 (if attr (concat
1553 "\\(" 1554 "\\("
1554 cperl-maybe-white-and-comment-rex ; whitespace-comments 1555 cperl-maybe-white-and-comment-rex ; whitespace-comments
1555 "\\(\\sw\\|_\\)+" ; attr-name 1556 "\\(\\<\\sw\\|_\\)+" ; attr-name
1556 ;; attr-arg (1 level of internal parens allowed!) 1557 ;; attr-arg (1 level of internal parens allowed!)
1557 "\\((\\(\\\\.\\|[^\\()]\\|([^\\()]*)\\)*)\\)?" 1558 "\\((\\(\\\\.\\|[^\\()]\\|([^\\()]*)\\)*)\\)?"
1558 "\\(" ; optional : (XXX allows trailing???) 1559 "\\(" ; optional : (XXX allows trailing???)
@@ -6003,7 +6004,11 @@ default function."
6003 ;; ... or the start of a "sloppy" signature 6004 ;; ... or the start of a "sloppy" signature
6004 (sequence (eval cperl--sloppy-signature-rx) 6005 (sequence (eval cperl--sloppy-signature-rx)
6005 ;; arbtrarily continue "a few lines" 6006 ;; arbtrarily continue "a few lines"
6006 (repeat 0 200 (not (in "{")))))))) 6007 (repeat 0 200 (not (in "{"))))
6008 ;; make sure we have a reasonably
6009 ;; short match for an incomplete sub
6010 (not (in ";{("))
6011 buffer-end))))
6007 '(1 (if (match-beginning 3) 6012 '(1 (if (match-beginning 3)
6008 'font-lock-variable-name-face 6013 'font-lock-variable-name-face
6009 'font-lock-function-name-face) 6014 'font-lock-function-name-face)