bug-coreutils
[Top][All Lists]
Advanced

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

C indentation tools: any recommendations?


From: Jim Meyering
Subject: C indentation tools: any recommendations?
Date: Mon, 14 Dec 2009 09:31:15 +0100

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.




reply via email to

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