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 via email to