Mercurial > emacs
comparison lisp/textmodes/fill.el @ 44478:2539a7fea37f
(fill-context-prefix): Match the two prefixes
differently to avoid pathological exponential-time case.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 10 Apr 2002 18:19:44 +0000 |
parents | 82810216f9a4 |
children | d85112eaf2d2 |
comparison
equal
deleted
inserted
replaced
44477:5bcb255d9dc5 | 44478:2539a7fea37f |
---|---|
235 | 235 |
236 (if ;; If the non-whitespace chars match the first line, | 236 (if ;; If the non-whitespace chars match the first line, |
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, |
255 ;; if there is one. | 251 ;; if there is one. |
256 (fill-common-string-prefix first-line-prefix | 252 (fill-common-string-prefix first-line-prefix |