changeset 74397:429f18443ca0

(sgml-font-lock-keywords-1): Fix pathological O(n^2) regexp-search by anchoring the search.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 04 Dec 2006 08:08:06 +0000
parents ee60f0fe10d6
children 48c50a37cc14
files lisp/ChangeLog lisp/textmodes/sgml-mode.el
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Dec 04 07:34:01 2006 +0000
+++ b/lisp/ChangeLog	Mon Dec 04 08:08:06 2006 +0000
@@ -1,3 +1,8 @@
+2006-12-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* textmodes/sgml-mode.el (sgml-font-lock-keywords-1): Fix pathological
+	O(n^2) regexp-search by anchoring the search.
+
 2006-12-04  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* whitespace.el (whitespace-cleanup-internal): Use current
@@ -31,7 +36,7 @@
 	<indicate-empty-lines, case-fold-search>:
 	Add "globally" to Help string.
 	<case-fold-search>: MESSAGE arg need not say "globally".
-	(menu-bar-edit-menu <paste-from-menu>): Renamed from select-and-paste.
+	(menu-bar-edit-menu <paste-from-menu>): Rename from select-and-paste.
 
 2006-12-03  Liam Healy  <lnp@healy.washington.dc.us>  (tiny change)
 
@@ -45,7 +50,7 @@
 	docstring error.
 	(allout-yank-processing): Fix depth shift of multiple-topic so yanks
 	work again, using allout-ascend's new option.
-	(allout-setup-mode-map): Extracted from allout-mode to initialize
+	(allout-setup-mode-map): Extract from allout-mode to initialize
 	allout-mode-map.  Call it on file load, so the mode docstring
 	substitutions work even if allout mode has not yet been invoked.
 	(allout-mode): Use new allout-setup-mode-map to track any keybinding
@@ -191,8 +196,8 @@
 
 2006-11-29  J.D. Smith  <jdsmith@as.arizona.edu>
 
-	* progmodes/idlwave.el (idlwave-auto-fill): Remove
-	paragraph-start let to prevent auto-fill giving up.
+	* progmodes/idlwave.el (idlwave-auto-fill):
+	Remove paragraph-start let to prevent auto-fill giving up.
 
 2006-11-28  Juanma Barranquero  <lekktu@gmail.com>
 
@@ -200,8 +205,8 @@
 
 2006-11-27  Andreas Seltenreich  <uwi7@rz.uni-karlsruhe.de>
 
-	* emacs-lisp/easy-mmode.el (easy-mmode-define-navigation): Fix
-	interactive spec of the functions getting defined to make them
+	* emacs-lisp/easy-mmode.el (easy-mmode-define-navigation):
+	Fix interactive spec of the functions getting defined to make them
 	work as documented.
 
 2006-11-28  Chong Yidong  <cyd@stupidchicken.com>
--- a/lisp/textmodes/sgml-mode.el	Mon Dec 04 07:34:01 2006 +0000
+++ b/lisp/textmodes/sgml-mode.el	Mon Dec 04 08:08:06 2006 +0000
@@ -265,7 +265,10 @@
      (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))