Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ruslan Kabatsayev <b7.10110111@gmail.com>
To: Simon Marchi <simark@simark.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v3] Align natural-format register values to the same column
Date: Sat, 03 Feb 2018 16:15:00 -0000	[thread overview]
Message-ID: <CAHEcG97yW=V2mWyNLjBjUqQKLZr6MC3umHNyeQmJN3UCT-BtvQ@mail.gmail.com> (raw)
In-Reply-To: <87b8b9de-1a29-0470-a65b-784475502473@simark.ca>

On 3 February 2018 at 18:55, Simon Marchi <simark@simark.ca> wrote:
> On 2018-02-03 06:43 AM, Ruslan Kabatsayev wrote:
>> I'm extremely sorry for making you repeat your comments. I keep
>> missing some formatting bits. Are there any known-working options for
>> any linter/indenter so that I could automatically check/prettify my
>> GDB patches before posting? I've tried astyle, but it somehow messes
>> up spaces/tabs and doesn't seem to support half-indenting enum braces
>> (or I didn't use the correct options). GNU indent appears to confuse
>> C++ references with bitwise OR, putting spaces on both sides, and also
>> doesn't want to half-indent enums.
>
> I don't know of any tool/config that does it right out of the box, but if
> you manage to find a solution that works nicely, please share it.  The problem
> is often that if you run files through an automatic formatter, you'll have a huge
> diff of little changes (fix existing style issues, change how things are wrapped,
> etc).  If there was a way to tell the formatter to only touch the lines that were
> touched in your patch, it would be ideal.
>
> What do you mean by half-indent enum, do you mean that the curly braces are
> indented with respect to the enum keywork, like this?
>
>   enum tab_stops
>     {
>       value_column_1 = 15,
>       /* Give enough room for "0x", 16 hex digits and two spaces in
>          preceding column. */
>       value_column_2 = value_column_1 + 2 + 16 + 2,
>     };

I guess I was still under the impression of 4-space indent between
scopes and perceived this additional 2-space indent of braces after
enum as a half-indent. I see now that generally the indent is 2
spaces, not 4, so this is actually one full indentation of the braces.

>
> I've seen inconsistent style in GDB between the above, and this:
>
>   enum tab_stops
>   {
>     value_column_1 = 15,
>     /* Give enough room for "0x", 16 hex digits and two spaces in
>        preceding column. */
>     value_column_2 = value_column_1 + 2 + 16 + 2,
>   };

Apparently I wasn't too lucky when I was looking for examples how to
format enums in the code base and came up with the first instance of
"enum opt" in "gdb/mi/mi-cmd-stack.c". Otherwise I'd do it without
indenting braces.

>
> I think the second version makes more sense, because it mimics how it's
> done for functions.  But I don't know if it should be different if the
> enum is declared inside the scope of a function.  If your formatter
> writes it like the second version, I would be totally fine with it.
>
>> I've sent a new version of the patch.
>
> Thanks, I'll look at it later.
>
> Simon


      reply	other threads:[~2018-02-03 16:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19  7:22 Ruslan Kabatsayev
2018-02-03  4:46 ` Simon Marchi
2018-02-03 11:43   ` Ruslan Kabatsayev
2018-02-03 15:55     ` Simon Marchi
2018-02-03 16:15       ` Ruslan Kabatsayev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHEcG97yW=V2mWyNLjBjUqQKLZr6MC3umHNyeQmJN3UCT-BtvQ@mail.gmail.com' \
    --to=b7.10110111@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox