# HG changeset patch # User Stefan Monnier # Date 1018462784 0 # Node ID 2539a7fea37f5c4d2182d3e9dc22b1f2d014f72a # Parent 5bcb255d9dc554d74ce3f89d393ffd74c11aab25 (fill-context-prefix): Match the two prefixes differently to avoid pathological exponential-time case. diff -r 5bcb255d9dc5 -r 2539a7fea37f lisp/textmodes/fill.el --- a/lisp/textmodes/fill.el Wed Apr 10 15:19:11 2002 +0000 +++ b/lisp/textmodes/fill.el Wed Apr 10 18:19:44 2002 +0000 @@ -237,18 +237,14 @@ ;; just use it (this subsumes the 2 previous checks). ;; Used when first line is `/* ...' and second-line is ;; ` * ...'. - (save-excursion - (goto-char firstline) - (looking-at - (apply 'concat - (mapcar (lambda (c) - (if (memq c '(?\t ?\ )) - ;; The number of chars might not - ;; match up if there's a mix of - ;; tabs and spaces. - "\\([ \t]*\\|.\\)" - (regexp-quote (string c)))) - second-line-prefix)))) + (string-match + (concat "\\`" + (mapconcat + (lambda (c) (regexp-quote (string c))) + (replace-regexp-in-string "[ \t]+" "" first-line-prefix) + "?") + "?\\'") + (replace-regexp-in-string "[ \t]+" "" second-line-prefix)) second-line-prefix ;; Use the longest common substring of both prefixes,