bug-indent
[Top][All Lists]
Advanced

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

Re: [Bug-indent] Oops on Nested Loops (and stuff)


From: Eric Deplagne
Subject: Re: [Bug-indent] Oops on Nested Loops (and stuff)
Date: Mon, 15 Mar 2004 10:43:17 +0100

On Tue, 24 Feb 2004 02:43:58 -0500 (EST)
Alex Clarke <address@hidden> wrote:

> New to indent.  Great concept.  Bad on nested blocks (at least redhat 9's
> 2.2.9-2 version is).
> 
> Example of problem:
> 
> input:
> 
> #include <stdio.h>
> 
> int main()
> {
>     int i,j,k,l;
>     for (i = 0; i < 100; i++)
>     {
>         for (j = 0; j < 100; j++)
>         {
>             for (k = 0; k < 100; k++)
>             {
>                 for (l = 0; l < 100; l++)
>                 {
>                     fprintf(stderr,"argh!");
>                 }
>             }
>         }
>     }
> }
> 
> indent myfile.c      #default GNU style, right?
> produces:
> 
> #include <stdio.h>
> 
> int
> main ()
> {
>   int i, j, k, l;
>   for (i = 0; i < 100; i++)
>     {
>       for (j = 0; j < 100; j++)
>     {
>       for (k = 0; k < 100; k++)
>         {
>           for (l = 0; l < 100; l++)
>         {
>           fprintf (stderr, "argh!");
>         }
>         }
>     }
>     }
> }
> 
> and that's just not cool.  The behaviour I expected was for every nested
> level to be indented, not every other.  Is this known behaviour or an
> aberration?

  This aberration is the standard behaviour...

  In fact all standard indentations (GNU, K&R, Linux kernel, ...)
  put { at the end of a line, hence the problem...

  You can you the option -bli0 to get the correct thing...
  I you add -bl, you will also move the { from the end of a line
  to its own line...

  BTW something's wrong in your code, "int main()", the empty parentheses
  are wrong in ANSI C... You have to state "int main(void)" to have no argument,
  otherwise you instead say nothing about the arguments, which is bad...

-- 
  Eric Deplagne


reply via email to

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