emacs-diffs
[Top][All Lists]
Advanced

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

master 233c91d32a: CC Mode: Fontify correctly a brace list element follo


From: Alan Mackenzie
Subject: master 233c91d32a: CC Mode: Fontify correctly a brace list element followed only by syntactic WS
Date: Fri, 26 Aug 2022 11:53:22 -0400 (EDT)

branch: master
commit 233c91d32adff3978931fbc78c27ef1d1560cf96
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    CC Mode: Fontify correctly a brace list element followed only by syntactic 
WS
    
    This fixes a regression introduced in the fix for bug #56841 on 2022-08-24.
    
    * lisp/progmodes/cc-engine (c-forward-declarator): Allow point to be at EOB
    after the call to c-forward-name, rather than rejecting it as an invalid
    declarator.  Also reindent a section of this function.
---
 lisp/progmodes/cc-engine.el | 82 +++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 40 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 1139423a45..b2d1f15d39 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -9459,7 +9459,8 @@ point unchanged and return nil."
 
 (defun c-forward-declarator (&optional limit accept-anon)
   ;; Assuming point is at the start of a declarator, move forward over it,
-  ;; leaving point at the next token after it (e.g. a ) or a ; or a ,).
+  ;; leaving point at the next token after it (e.g. a ) or a ; or a ,), or at
+  ;; end of buffer if there is no such token.
   ;;
   ;; Return a list (ID-START ID-END BRACKETS-AFTER-ID GOT-INIT DECORATED),
   ;; where ID-START and ID-END are the bounds of the declarator's identifier,
@@ -9499,44 +9500,44 @@ point unchanged and return nil."
           ;; of the while.  These are, e.g. "*" in "int *foo" or "(" and
           ;; "*" in "int (*foo) (void)" (Note similar code in
           ;; `c-forward-decl-or-cast-1'.)
-             (while
-                 (cond
-                  ((looking-at c-decl-hangon-key)
-                   (c-forward-keyword-clause 1))
-                  ((and c-opt-cpp-prefix
-                        (looking-at c-noise-macro-with-parens-name-re))
-                   (c-forward-noise-clause))
-                  ((and (looking-at c-type-decl-prefix-key)
-                        (if (and (c-major-mode-is 'c++-mode)
-                                 (match-beginning 4)) ; Was 3 - 2021-01-01
-                            ;; If the third submatch matches in C++ then
-                            ;; we're looking at an identifier that's a
-                            ;; prefix only if it specifies a member pointer.
-                            (progn
-                              (setq id-start (point))
-                              (c-forward-name)
-                              (if (save-match-data
-                                    (looking-at "\\(::\\)"))
-                                  ;; We only check for a trailing "::" and
-                                  ;; let the "*" that should follow be
-                                  ;; matched in the next round.
-                                  t
-                                ;; It turned out to be the real identifier,
-                                ;; so flag that and stop.
-                                (setq got-identifier t)
-                                nil))
-                          t))
-                   (if (save-match-data
-                         (looking-at c-type-decl-operator-prefix-key))
-                       (setq decorated t))
-                   (if (eq (char-after) ?\()
-                       (progn
-                         (setq paren-depth (1+ paren-depth))
-                         (forward-char))
-                     (goto-char (or (match-end 1)
-                                    (match-end 2))))
-                   (c-forward-syntactic-ws)
-                   t)))
+          (while
+              (cond
+               ((looking-at c-decl-hangon-key)
+                (c-forward-keyword-clause 1))
+               ((and c-opt-cpp-prefix
+                     (looking-at c-noise-macro-with-parens-name-re))
+                (c-forward-noise-clause))
+               ((and (looking-at c-type-decl-prefix-key)
+                     (if (and (c-major-mode-is 'c++-mode)
+                              (match-beginning 4)) ; Was 3 - 2021-01-01
+                         ;; If the third submatch matches in C++ then
+                         ;; we're looking at an identifier that's a
+                         ;; prefix only if it specifies a member pointer.
+                         (progn
+                           (setq id-start (point))
+                           (c-forward-name)
+                           (if (save-match-data
+                                 (looking-at "\\(::\\)"))
+                               ;; We only check for a trailing "::" and
+                               ;; let the "*" that should follow be
+                               ;; matched in the next round.
+                               t
+                             ;; It turned out to be the real identifier,
+                             ;; so flag that and stop.
+                             (setq got-identifier t)
+                             nil))
+                       t))
+                (if (save-match-data
+                      (looking-at c-type-decl-operator-prefix-key))
+                    (setq decorated t))
+                (if (eq (char-after) ?\()
+                    (progn
+                      (setq paren-depth (1+ paren-depth))
+                      (forward-char))
+                  (goto-char (or (match-end 1)
+                                 (match-end 2))))
+                (c-forward-syntactic-ws)
+                t)))
 
           ;; If we haven't passed the identifier already, do it now.
           (unless got-identifier
@@ -9557,7 +9558,8 @@ point unchanged and return nil."
         (or (= paren-depth 0)
             (c-safe (goto-char (scan-lists (point) 1 paren-depth))))
 
-        (< (point) limit)
+        (or (eq (point) (point-max))   ; No token after identifier.
+            (< (point) limit))
 
         ;; Skip over any trailing bit, such as "__attribute__".
         (progn



reply via email to

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