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: Tue, 23 Nov 2004 13:43:20 +0100
User-agent: Mutt/1.5.6+20040722i

On lun, 22 nov 2004 08:15:41 -0800, j c wrote:
> Actually, it seems that Alex was talking about the
> fact that the for(j..) and for(k..) statements are
> indented the same amount.  I also am frustrated with
> this.  It seems that the indentation is the same for
> every other nest level if using -i4. -i2 moves it in
> 2, then back 2, every nest level.  -i3 puts it in 3,
> then back 1.  Is there a way to make indent just keep
> indenting IN?
> 
> -Joe

Right. That's more strange.
Looks like indent just gets confused by { being on their own lines.
It's not that surprising since that matches no usual standard,
and thus is poorly tested.

> 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
> 
> 
>               
> __________________________________ 
> Do you Yahoo!? 
> Meet the all-new My Yahoo! - Try it today! 
> http://my.yahoo.com 
>  
> 
> 
> 
> 

-- 
  Eric Deplagne




reply via email to

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