bug-coreutils
[Top][All Lists]
Advanced

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

Re: C indentation tools: any recommendations?


From: Steve Ward
Subject: Re: C indentation tools: any recommendations?
Date: Mon, 14 Dec 2009 22:42:13 -0500

On Mon, Dec 14, 2009 at 03:31, Jim Meyering <address@hidden> wrote:

> David Soria Parra wrote:
> > From: David Soria Parra <address@hidden>
> > * src/rm.c: Correct brace indention
> ...
> >  enum interactive_type
> > -  {
> > +{
> >      interactive_never,               /* 0: no option or
> --interactive=never */
> >      interactive_once,                /* 1: -I or --interactive=once */
> >      interactive_always               /* 2: default, -i or
> --interactive=always */
> > -  };
> > +};
>
> Thanks, but there are many of those,
>
>    $ git grep -B1 '^  {'|grep enum|wc -l
>    41
>
> because that's the way emacs indents by default.
>
> I would be interested in changes like that only if they were part of a
> much larger change involving an indenter or formatter that's good enough
> to be used to ensure uniform style throughout the project.  While I've
> recently expanded all TABs in coreutils' indentation, I'm not ready to
> filter everything through a full-fledged code formatter just yet.
> The main obstacle is that I haven't found one that is flexible enough
> to allow existing style.
>
> For example, GNU indent joins continued expressions, argument lists, etc.,
> if the result fits on a line.  Sometimes, for readability, I really do not
> want to maximize line length, yet I didn't see a way to turn that off.
> Also, I don't want it to align my comments; just leave them alone.
> And if I choose to write "if ( ! some_thing)", I'd like an option to
> make it leave that as-is.  My primary goal is to find an indentation
> normalizer, and enforce that, because I've seen too many bugs that would
> have been detected by a tool enforcing consistent style on that front.
>
> Have any of you found C code indenters or formatters you've liked?
>
> BTW, to make the above match what GNU indent produces,
> you would have to adjust the indentation of each member, too.
>
>
>

I have used astyle <http://astyle.sourceforge.net/> in the past.  It was
effective once I got the options just right for my use.


Steve


reply via email to

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