diff options
author | Martin Stjernholm <mast@lysator.liu.se> | 2003-03-23 01:58:30 +0000 |
---|---|---|
committer | Martin Stjernholm <mast@lysator.liu.se> | 2003-03-23 01:58:30 +0000 |
commit | e33c01bb57a63b0dc4fb31cf7e1e90940ee1df02 (patch) | |
tree | a80e7d51b5db9088ef87dbfc0f968e80144e7b96 | |
parent | 55ba29ee66df015214e3991f2c46a6270792ff49 (diff) | |
download | emacs-e33c01bb57a63b0dc4fb31cf7e1e90940ee1df02.tar.gz emacs-e33c01bb57a63b0dc4fb31cf7e1e90940ee1df02.tar.bz2 emacs-e33c01bb57a63b0dc4fb31cf7e1e90940ee1df02.zip |
(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.
-rw-r--r-- | lisp/progmodes/cc-engine.el | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 58d61eb2182..c2be72b0043 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -1144,7 +1144,7 @@ you need both the type of a literal and its limits." (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 @@ you need both the type of a literal and its limits." (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 @@ you need both the type of a literal and its limits." (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" |