From 0e35704fe37533a3b089c0b5fa8303e98baba562 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Tue, 20 Aug 2002 21:59:10 +0000 Subject: [PATCH] (c-forward-syntactic-ws): Fixed a bug that could cause an infinite loop if something that looks like a macro begins in the middle of a line. (c-parse-state): Fixed a bug that could cause `c-state-cache' to contain two conses in sequence when there's an unbalanced open paren in a macro. --- lisp/ChangeLog | 10 ++++++++++ lisp/progmodes/cc-engine.el | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 30a1e186768..1ea63117124 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2002-08-20 Martin Stjernholm + + * progmodes/cc-engine.el (c-forward-syntactic-ws): Fixed a bug + that could cause an infinite loop if something that looks like + a macro begins in the middle of a line. + + * progmodes/cc-engine.el (c-parse-state): Fixed a bug that + could cause `c-state-cache' to contain two conses in sequence + when there's an unbalanced open paren in a macro. + 2002-08-20 Glenn Morris * progmodes/fortran.el (fortran-current-defun): Use save-excursion. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 3994c5cc22c..4fdfbcf9502 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -642,8 +642,9 @@ specified." (forward-char)) ;; Skip preprocessor directives. ((and (looking-at "#[ \t]*[a-zA-Z0-9!]") - (progn (skip-chars-backward " \t") - (bolp))) + (save-excursion + (skip-chars-backward " \t") + (bolp))) (end-of-line) (while (and (<= (point) lim) (eq (char-before) ?\\) @@ -1245,6 +1246,11 @@ you need both the type of a literal and its limits." (setq c-state-cache (cdr c-state-cache))) (setq pairs (car pairs)) (setcar pairs (1- (car pairs))) + (when (consp (car-safe c-state-cache)) + ;; There could already be a cons first in `c-state-cache' + ;; if we've jumped over an unbalanced open paren in a + ;; macro below. + (setq c-state-cache (cdr c-state-cache))) (setq c-state-cache (cons pairs c-state-cache))) (if last-pos ;; Prepare to loop, but record the open paren only if it's -- 2.39.5