From c60f3aa4429416744dd20162d0ed2f05d5efcc18 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Sat, 21 Jun 2008 09:00:49 +0000 Subject: [PATCH] (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax. --- lisp/progmodes/cc-engine.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index c29faecb8c0..817b161ff87 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -8252,21 +8252,24 @@ comment at the start of cc-engine.el for more info." (c-add-syntax 'inher-cont (c-point 'boi))) ;; CASE 5D.5: Continuation of the "expression part" of a - ;; top level construct. + ;; top level construct. Or, perhaps, an unrecognised construct. (t - (while (and (eq (car (c-beginning-of-decl-1 containing-sexp)) + (while (and (setq placeholder (point)) + (eq (car (c-beginning-of-decl-1 containing-sexp)) 'same) (save-excursion (c-backward-syntactic-ws) - (eq (char-before) ?})))) + (eq (char-before) ?})) + (< (point) placeholder))) (c-add-stmt-syntax - (if (eq char-before-ip ?,) + (cond + ((eq (point) placeholder) 'statement) ; unrecognised construct ;; A preceding comma at the top level means that a ;; new variable declaration starts here. Use ;; topmost-intro-cont for it, for consistency with ;; the first variable declaration. C.f. case 5N. - 'topmost-intro-cont - 'statement-cont) + ((eq char-before-ip ?,) 'topmost-intro-cont) + (t 'statement-cont)) nil nil containing-sexp paren-state)) )) -- 2.39.2