Commit 0bc5886a authored by Alan Mackenzie's avatar Alan Mackenzie
Browse files

Fix infinite loop with long macros.

parent faccede1
2012-02-12 Alan Mackenzie <acm@muc.de>
Fix infinite loop with long macros.
* cc-engine.el (c-state-safe-place): Handle macros properly.
2012-02-12 Chong Yidong <cyd@gnu.org> 2012-02-12 Chong Yidong <cyd@gnu.org>
* window.el (display-buffer): Doc fix (Bug#10785). * window.el (display-buffer): Doc fix (Bug#10785).
......
...@@ -2129,7 +2129,7 @@ comment at the start of cc-engine.el for more info." ...@@ -2129,7 +2129,7 @@ comment at the start of cc-engine.el for more info."
(widen) (widen)
(save-excursion (save-excursion
(let ((c c-state-nonlit-pos-cache) (let ((c c-state-nonlit-pos-cache)
pos npos lit macro-beg) pos npos lit macro-beg macro-end)
;; Trim the cache to take account of buffer changes. ;; Trim the cache to take account of buffer changes.
(while (and c (> (car c) c-state-nonlit-pos-cache-limit)) (while (and c (> (car c) c-state-nonlit-pos-cache-limit))
(setq c (cdr c))) (setq c (cdr c)))
...@@ -2143,28 +2143,29 @@ comment at the start of cc-engine.el for more info." ...@@ -2143,28 +2143,29 @@ comment at the start of cc-engine.el for more info."
;; Add an element to `c-state-nonlit-pos-cache' each iteration. ;; Add an element to `c-state-nonlit-pos-cache' each iteration.
(and (and
(<= (setq npos (+ pos c-state-nonlit-pos-interval)) here) (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
;; Test for being in a literal.
(progn (progn
(setq lit (car (cddr (c-state-pp-to-literal pos npos)))) (setq lit (car (cddr (c-state-pp-to-literal pos npos))))
(cond (or (null lit)
((null lit) (prog1 (<= (cdr lit) here)
(setq pos npos) (setq npos (cdr lit)))))
t)
((<= (cdr lit) here)
(setq pos (cdr lit))
t)
(t
(setq pos (car lit))
nil))))
(goto-char pos) ;; Test for being in a macro.
(when (and (c-beginning-of-macro) (/= (point) pos)) (progn
(setq macro-beg (point)) (goto-char npos)
(c-syntactic-end-of-macro) (setq macro-beg
(or (eobp) (forward-char)) (and (c-beginning-of-macro) (/= (point) npos) (point)))
(setq pos (if (<= (point) here) (when macro-beg
(point) (c-syntactic-end-of-macro)
macro-beg))) (or (eobp) (forward-char))
(setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache))) (setq macro-end (point)))
(or (null macro-beg)
(prog1 (<= macro-end here)
(setq npos macro-end)))))
(setq pos npos)
(setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache)))
(if (> pos c-state-nonlit-pos-cache-limit) (if (> pos c-state-nonlit-pos-cache-limit)
(setq c-state-nonlit-pos-cache-limit pos)) (setq c-state-nonlit-pos-cache-limit pos))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment