]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix infinite loop with long macros.
authorAlan Mackenzie <acm@muc.de>
Sun, 12 Feb 2012 11:06:42 +0000 (11:06 +0000)
committerAlan Mackenzie <acm@muc.de>
Sun, 12 Feb 2012 11:06:42 +0000 (11:06 +0000)
lisp/ChangeLog
lisp/progmodes/cc-engine.el

index 2f830b7447bd8e01d9fdb26b606f4c2f79be9f4d..5cee6b4d5c2b7c332ca40316c5ca42e4ff55cbff 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * window.el (display-buffer): Doc fix (Bug#10785).
index be0f86ddd7e78a17be96f2baaac55dc8aab0da62..95b43e763d505398ff77252941103e75423fe5c4 100644 (file)
@@ -2129,7 +2129,7 @@ comment at the start of cc-engine.el for more info."
     (widen)
     (save-excursion
       (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.
        (while (and c (> (car c) c-state-nonlit-pos-cache-limit))
          (setq c (cdr c)))
@@ -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.
            (and
             (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
+
+            ;; Test for being in a literal.
             (progn
               (setq lit (car (cddr (c-state-pp-to-literal pos npos))))
-              (cond
-               ((null lit)
-                (setq pos npos)
-                t)
-               ((<= (cdr lit) here)
-                (setq pos (cdr lit))
-                t)
-               (t
-                (setq pos (car lit))
-                nil))))
+              (or (null lit)
+                  (prog1 (<= (cdr lit) here)
+                    (setq npos (cdr lit)))))
 
-         (goto-char pos)
-         (when (and (c-beginning-of-macro) (/= (point) pos))
-             (setq macro-beg (point))
-             (c-syntactic-end-of-macro)
-             (or (eobp) (forward-char))
-             (setq pos (if (<= (point) here)
-                           (point)
-                         macro-beg)))
-           (setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache)))
+            ;; Test for being in a macro.
+            (progn
+              (goto-char npos)
+              (setq macro-beg
+                    (and (c-beginning-of-macro) (/= (point) npos) (point)))
+              (when macro-beg
+                (c-syntactic-end-of-macro)
+                (or (eobp) (forward-char))
+                (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)
            (setq c-state-nonlit-pos-cache-limit pos))