aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-04-10 18:19:44 +0000
committerStefan Monnier2002-04-10 18:19:44 +0000
commit419275721fa0d19443bfcafa207f2e611a5793a9 (patch)
treeaffabc2f8531f5a0f6e8002a5bf30a351587cdd3
parent05ea8efde04e9b9e2e1f720f1544fb4f62abe13d (diff)
downloademacs-419275721fa0d19443bfcafa207f2e611a5793a9.tar.gz
emacs-419275721fa0d19443bfcafa207f2e611a5793a9.zip
(fill-context-prefix): Match the two prefixes
differently to avoid pathological exponential-time case.
-rw-r--r--lisp/textmodes/fill.el20
1 files changed, 8 insertions, 12 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 34fa1f544bb..e4545021cc2 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -237,18 +237,14 @@ act as a paragraph-separator."
237 ;; just use it (this subsumes the 2 previous checks). 237 ;; just use it (this subsumes the 2 previous checks).
238 ;; Used when first line is `/* ...' and second-line is 238 ;; Used when first line is `/* ...' and second-line is
239 ;; ` * ...'. 239 ;; ` * ...'.
240 (save-excursion 240 (string-match
241 (goto-char firstline) 241 (concat "\\`"
242 (looking-at 242 (mapconcat
243 (apply 'concat 243 (lambda (c) (regexp-quote (string c)))
244 (mapcar (lambda (c) 244 (replace-regexp-in-string "[ \t]+" "" first-line-prefix)
245 (if (memq c '(?\t ?\ )) 245 "?")
246 ;; The number of chars might not 246 "?\\'")
247 ;; match up if there's a mix of 247 (replace-regexp-in-string "[ \t]+" "" second-line-prefix))
248 ;; tabs and spaces.
249 "\\([ \t]*\\|.\\)"
250 (regexp-quote (string c))))
251 second-line-prefix))))
252 second-line-prefix 248 second-line-prefix
253 249
254 ;; Use the longest common substring of both prefixes, 250 ;; Use the longest common substring of both prefixes,