bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: CC Mode 5.28 (C++); indentation problem on class initializer list


From: Martin Stjernholm
Subject: Re: CC Mode 5.28 (C++); indentation problem on class initializer list
Date: 24 Oct 2001 17:29:13 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Trevor Spiteri <address@hidden> wrote:

> With the code below, trying to indent line 10 gives the error:
> Scan error: "Unbalanced parentheses", 83, 1
> 
> This bug appears any time the -> operator is used in the initializer
> list for a class constructor in C++.
> 
> 
> This is the code that triggers the bug:
/.../
>  8 >    a::a(b B)
>  9 >        : ai(B->bi),
> 10 >          aj(i)
> 11 >    {
> 12 >    }

The following patch fixes this:

*** cc-engine.el        2001/02/21 18:15:14     5.184
--- cc-engine.el        2001/10/24 15:13:36
***************
*** 1024,1054 ****
    (if (eq (char-after) ?,)
        (forward-char 1)
      (c-backward-syntactic-ws limit))
!   (c-with-syntax-table (if (c-major-mode-is 'c++-mode)
!                          c++-template-syntax-table
!                        (syntax-table))
!     (while (and (< limit (point))
!               (eq (char-before) ?,))
!       ;; this will catch member inits with multiple
!       ;; line arglists
!       (forward-char -1)
!       (c-backward-syntactic-ws)
!       (if (eq (char-before) ?\))
!         (c-backward-sexp 2)
        (c-backward-sexp 1))
!       ;; Skip over any template arg to the class.
!       (if (eq (char-after) ?<)
!         (c-backward-sexp 1))
!       ;; Skip backwards over a fully::qualified::name.
!       (c-backward-syntactic-ws limit)
!       (while (and (eq (char-before) ?:)
!                 (save-excursion
!                   (forward-char -1)
!                   (eq (char-before) ?:)))
!       (backward-char 2)
!       (c-backward-sexp 1))
!       ;; now continue checking
!       (c-backward-syntactic-ws limit)))
    (and (< limit (point))
         (eq (char-before) ?:)))
  
--- 1024,1053 ----
    (if (eq (char-after) ?,)
        (forward-char 1)
      (c-backward-syntactic-ws limit))
!   (while (and (< limit (point))
!             (eq (char-before) ?,))
!     ;; this will catch member inits with multiple
!     ;; line arglists
!     (forward-char -1)
!     (c-backward-syntactic-ws limit)
!     (if (eq (char-before) ?\))
        (c-backward-sexp 1))
!     (c-backward-syntactic-ws limit)
!     ;; Skip over any template arg to the class.
!     (if (eq (char-before) ?>)
!       (c-with-syntax-table c++-template-syntax-table
!         (c-backward-sexp 1)))
!     (c-backward-sexp 1)
!     (c-backward-syntactic-ws limit)
!     ;; Skip backwards over a fully::qualified::name.
!     (while (and (eq (char-before) ?:)
!               (save-excursion
!                 (forward-char -1)
!                 (eq (char-before) ?:)))
!       (backward-char 2)
!       (c-backward-sexp 1))
!     ;; now continue checking
!     (c-backward-syntactic-ws limit))
    (and (< limit (point))
         (eq (char-before) ?:)))
  

This bug is rather unfortunate, so the fix preferably shouldn't wait
until CC Mode 5.29 is released. I'd therefore appreciate if someone
with access could apply the patch above in the Emacs cvs, and in the
corresponding package for XEmacs. Here's a suggestion for the
ChangeLog entry:

Wed Oct 24 2001  Martin Stjernholm  <address@hidden>

        * cc-mode.el (c-beginning-of-member-init-list): Better
        handling of C++ template args to avoid confusion with `<' and
        `>' used as operators in member init expressions.




reply via email to

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