aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/cc-engine.el41
2 files changed, 26 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2f830b7447b..5cee6b4d5c2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12012-02-12 Alan Mackenzie <acm@muc.de>
2
3 Fix infinite loop with long macros.
4 * cc-engine.el (c-state-safe-place): Handle macros properly.
5
12012-02-12 Chong Yidong <cyd@gnu.org> 62012-02-12 Chong Yidong <cyd@gnu.org>
2 7
3 * window.el (display-buffer): Doc fix (Bug#10785). 8 * window.el (display-buffer): Doc fix (Bug#10785).
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index be0f86ddd7e..95b43e763d5 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -2129,7 +2129,7 @@ comment at the start of cc-engine.el for more info."
2129 (widen) 2129 (widen)
2130 (save-excursion 2130 (save-excursion
2131 (let ((c c-state-nonlit-pos-cache) 2131 (let ((c c-state-nonlit-pos-cache)
2132 pos npos lit macro-beg) 2132 pos npos lit macro-beg macro-end)
2133 ;; Trim the cache to take account of buffer changes. 2133 ;; Trim the cache to take account of buffer changes.
2134 (while (and c (> (car c) c-state-nonlit-pos-cache-limit)) 2134 (while (and c (> (car c) c-state-nonlit-pos-cache-limit))
2135 (setq c (cdr c))) 2135 (setq c (cdr c)))
@@ -2143,28 +2143,29 @@ comment at the start of cc-engine.el for more info."
2143 ;; Add an element to `c-state-nonlit-pos-cache' each iteration. 2143 ;; Add an element to `c-state-nonlit-pos-cache' each iteration.
2144 (and 2144 (and
2145 (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here) 2145 (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
2146
2147 ;; Test for being in a literal.
2146 (progn 2148 (progn
2147 (setq lit (car (cddr (c-state-pp-to-literal pos npos)))) 2149 (setq lit (car (cddr (c-state-pp-to-literal pos npos))))
2148 (cond 2150 (or (null lit)
2149 ((null lit) 2151 (prog1 (<= (cdr lit) here)
2150 (setq pos npos) 2152 (setq npos (cdr lit)))))
2151 t)
2152 ((<= (cdr lit) here)
2153 (setq pos (cdr lit))
2154 t)
2155 (t
2156 (setq pos (car lit))
2157 nil))))
2158 2153
2159 (goto-char pos) 2154 ;; Test for being in a macro.
2160 (when (and (c-beginning-of-macro) (/= (point) pos)) 2155 (progn
2161 (setq macro-beg (point)) 2156 (goto-char npos)
2162 (c-syntactic-end-of-macro) 2157 (setq macro-beg
2163 (or (eobp) (forward-char)) 2158 (and (c-beginning-of-macro) (/= (point) npos) (point)))
2164 (setq pos (if (<= (point) here) 2159 (when macro-beg
2165 (point) 2160 (c-syntactic-end-of-macro)
2166 macro-beg))) 2161 (or (eobp) (forward-char))
2167 (setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache))) 2162 (setq macro-end (point)))
2163 (or (null macro-beg)
2164 (prog1 (<= macro-end here)
2165 (setq npos macro-end)))))
2166
2167 (setq pos npos)
2168 (setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache)))
2168 2169
2169 (if (> pos c-state-nonlit-pos-cache-limit) 2170 (if (> pos c-state-nonlit-pos-cache-limit)
2170 (setq c-state-nonlit-pos-cache-limit pos)) 2171 (setq c-state-nonlit-pos-cache-limit pos))