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

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

bug#17756: indentation after declaring+initializing two arrays


From: Alan Mackenzie
Subject: bug#17756: indentation after declaring+initializing two arrays
Date: Thu, 12 Jun 2014 19:25:47 +0000 (UTC)
User-agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64))

Pietro Belotti <petr.7b6@gmail.com> wrote:
> Hello. I have a problem with Emacs (version: 23.4.1
> (x86_64-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-09-08 on trouble,
> modified by Debian [2 times]). A declaration is incorrectly indented
> when following one where two or more arrays are declared and
> initialized. The function foo() below has "char c = 'a';"
> over-indented, while the function bar() following it has the same
> declaration correctly indented.

> int foo () {
>
>  int a [2] = {1,2},
>    b [2] = {3,4};
>
>    char c = 'a';
> }

> This also happens if a newline is placed between "int" and "a [2]",
> but it does not happen if a and b are declared on the same line. Both
> M-x indent-region and moving the cursor and hitting TAB result in
> this. I could not find any related issue in the mailing list archive,
> is this expected behaviour?

No, it's a bug.  What is happening is that C Mode has got confused by the
brace expression "{1,2}" into thinking that a statement ends after
"{1,2},", because close braces are usually ends of statements.  Hence it
thinks that "b [2] ...." is the beginning of a statement.  The next
statement "char c ..." is thus indented under the "b [2] ...".

I'll get a fix to this out soon.  Thanks for taking the trouble to report
this bug.

By the way, for future reference, it is helpful if you say what major mode
you're using (the best place being in the Subject:) so that we don't have
to guess.

> Thanks,
> Pietro

-- 
Alan Mackenzie (Nuremberg, Germany).






reply via email to

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