aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes/sgml-mode.el
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2006-12-04 08:08:06 +0000
committerStefan Monnier <[email protected]>2006-12-04 08:08:06 +0000
commit9bbceb74b4d1ac225fd9a2292d287810a6c90316 (patch)
tree3d283554677a32a546f0f6a3e520c83a31a719e9 /lisp/textmodes/sgml-mode.el
parent2b058c727ef14a3fe205c99c0b5191820b285480 (diff)
(sgml-font-lock-keywords-1): Fix pathological O(n^2) regexp-search by
anchoring the search.
Diffstat (limited to 'lisp/textmodes/sgml-mode.el')
-rw-r--r--lisp/textmodes/sgml-mode.el5
1 files changed, 4 insertions, 1 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 6136d22e43..aa24a72487 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -265,7 +265,10 @@ Any terminating `>' or `/' is not matched.")
(1 (if (match-end 2) sgml-namespace-face font-lock-function-name-face))
(2 font-lock-function-name-face nil t))
;; FIXME: this doesn't cover the variables using a default value.
- (,(concat "\\(" sgml-namespace-re "\\)\\(?::\\("
+ ;; The first shy-group is an important anchor: it prevents an O(n^2)
+ ;; pathological case where we otherwise keep retrying a failing match
+ ;; against a very long word at every possible position within the word.
+ (,(concat "\\(?:^\\|[ \t]\\)\\(" sgml-namespace-re "\\)\\(?::\\("
sgml-name-re "\\)\\)?=[\"']")
(1 (if (match-end 2) sgml-namespace-face font-lock-variable-name-face))
(2 font-lock-variable-name-face nil t))