# HG changeset patch # User Martin Stjernholm # Date 1048384710 0 # Node ID ea06392567c0efe0b1d1ff3654e7025cfc813f32 # Parent c5e286e85257935c14e2936add353a8fa43a6588 (c-parse-state): Added kludge to avoid an infinite loop when Emacs' open-paren-in-column-zero rule kicks in and causes the sexp functions to misbehave. diff -r c5e286e85257 -r ea06392567c0 lisp/progmodes/cc-engine.el --- a/lisp/progmodes/cc-engine.el Sun Mar 23 01:09:49 2003 +0000 +++ b/lisp/progmodes/cc-engine.el Sun Mar 23 01:58:30 2003 +0000 @@ -1144,7 +1144,7 @@ (let* ((here (point)) (c-macro-start (c-query-macro-start)) (in-macro-start (or c-macro-start (point))) - old-state last-pos pairs pos) + old-state last-pos pairs pos save-pos) ;; Somewhat ugly use of c-check-state-cache to get rid of the ;; part of the state cache that is after point. Can't use ;; c-whack-state-after for the same reasons as in that function. @@ -1225,7 +1225,8 @@ (narrow-to-region (point-min) here) (while pos ;; Find the balanced brace pairs. - (setq pairs nil) + (setq save-pos pos + pairs nil) (while (and (setq last-pos (c-down-list-forward pos)) (setq pos (c-up-list-forward last-pos))) (if (eq (char-before last-pos) ?{) @@ -1269,7 +1270,13 @@ (progn (setq pos (c-up-list-backward pos) c-state-cache nil) - (unless pos + (when (or (not pos) + ;; Emacs (up to at least 21.2) can get confused by + ;; open parens in column zero inside comments: The + ;; sexp functions can then misbehave and bring us + ;; back to the same point again. Check this so that + ;; we don't get an infinite loop. + (>= pos save-pos)) (setq pos last-pos c-parsing-error (format "Unbalanced close paren at line %d"