emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 97959349651: Fix c-in-knr-argdecl to avoid false recognition of K


From: Alan Mackenzie
Subject: master 97959349651: Fix c-in-knr-argdecl to avoid false recognition of K&R
Date: Fri, 13 Oct 2023 10:29:34 -0400 (EDT)

branch: master
commit 97959349651a8fb170c1c754e73a4d86ed24d018
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    Fix c-in-knr-argdecl to avoid false recognition of K&R
    
    In the OP's test case, the type of a declaration was a macro
    with parentheses, which confused c-in-knr-argdecl.
    
    * lisp/progmodes/cc-engine.el (c-in-knr-argdecl): Amend this
    function to return nil if a "parameter declaration" can't be
    parsed as a declaration.
---
 lisp/progmodes/cc-engine.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index e687f44d657..f5e0d21108f 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -12266,11 +12266,14 @@ comment at the start of cc-engine.el for more info."
                       ;; Each time around the following checks one
                       ;; declaration (which may contain several identifiers).
                       (while (and
-                              (consp (setq decl-or-cast
-                                           (c-forward-decl-or-cast-1
-                                            after-prec-token
-                                            nil ; Or 'arglist ???
-                                            nil)))
+                              (not (eq (char-after) ?{))
+                              (or
+                               (consp (setq decl-or-cast
+                                            (c-forward-decl-or-cast-1
+                                             after-prec-token
+                                             nil ; Or 'arglist ???
+                                             nil)))
+                               (throw 'knr nil))
                               (memq (char-after) '(?\; ?\,))
                               (goto-char (car decl-or-cast))
                               (save-excursion



reply via email to

[Prev in Thread] Current Thread [Next in Thread]