public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Guillaume Gomez <guillaume1.gomez@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATH] [CLEANUP] Remove trailing whitespace characters
Date: Mon, 11 Sep 2023 09:27:48 -0400	[thread overview]
Message-ID: <a9d995c70a9dacf4fe20b1bc549734b355dccf38.camel@redhat.com> (raw)
In-Reply-To: <CAAOQCfR=WBnuXX4=Wz_9WhAueWavsEWV83JUC-mBnLP96RMUdw@mail.gmail.com>

On Sun, 2023-09-10 at 16:36 +0200, Guillaume Gomez wrote:
> When going through the code, I saw a lot of trailing whitespace
> characters so I decided to write a small script that would remove
> them. I didn't expect there would be so many though... Not sure if
> patch with so many changes are accepted like this or if I should send
> more focused one.

I'm not sure either.

Some notes on the patch:

- the ChangeLog sensibly makes use of "Likewise", but for the initial
file in each ChangeLog it incorrectly also says "Likewise".  When these
are copied into the individual ChangeLog files by the "Daily bump"
cronjob, the Subject line from the commit won't be visible [1], so the
thing that "Likewise" refers to won't be present.  So that initial file
in each category should read "Remove trailing whitespace characters".

- the patch touches the testsuite.  Note that not all source files in
the testsuite are UTF-8 encoded, and we want the testsuite to contain a
variety of source formatting idioms (and examples of badly formatted
source code).

- some of our source files use U+000C, the form feed character, and the
patch eliminates these.  I think this is an old convention used to
indicate a major change of topic within the source file.  Perhaps it
leads to a page break when printing the source file?  Personally I
dislike this convention, and feel a suitable big comment line would be
clearer such as:

/* Name of new topic.

   General comments about the new topic, where useful.  */

for such "high-level" source file organizational bounaries, but perhaps
people like and use the form feed characters?

Hope this is constructive
Dave

[1] see e.g. a134b6ce8e5c589f8c1b58cdf124cd4a916b0e8c


> 
> Anyway, for posterity, here is the python script I used:
> 
> ```
> from os import listdir
> from os.path import isfile, join
> 
> 
> def clean_file(p):
>     if not p.endswith(".cc") and not p.endswith(".h"):
>         return
>     with open(p, 'r', encoding='utf8') as f:
>         content = f.read().split('\n')
>     updated = 0
>     i = 0
>     while i < len(content):
>         s = content[i].rstrip()
>         if s != content[i]:
>             updated += 1
>             content[i] = s
>         i += 1
>     if updated == 0:
>         return
>     with open(p, 'w', encoding='utf8') as f:
>         f.write('\n'.join(content))
> 
> 
> def recur_read(p):
>     for f in listdir(p):
>         full_path = join(p, f)
>         if isfile(full_path):
>             clean_file(full_path)
>         else:
>             recur_read(full_path)
> 
> recur_read(".")
> ```
> 
> Cordially.


  reply	other threads:[~2023-09-11 13:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-10 14:36 Guillaume Gomez
2023-09-11 13:27 ` David Malcolm [this message]
2023-09-11 13:30   ` Guillaume Gomez
2023-09-11 13:43   ` Jakub Jelinek
2023-09-11 14:43     ` Eric Gallager
2023-09-11 14:49       ` Arthur Cohen

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=a9d995c70a9dacf4fe20b1bc549734b355dccf38.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guillaume1.gomez@gmail.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).