public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH] contrib: ignore CR in update-copyright.py
Date: Tue, 17 Jan 2023 13:00:35 +0100	[thread overview]
Message-ID: <d15fec2f-b7aa-2830-089a-62c0fd0b66d9@suse.cz> (raw)

When opening files, preserve CR characters. By default, open
accepts universal newlines, but I think we should only split with '\n'.

Ready to be installed?
Thanks,
Martin

contrib/ChangeLog:

	* update-copyright.py: Split lines only with '\n'.
---
 contrib/update-copyright.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/update-copyright.py b/contrib/update-copyright.py
index ac7a94743cf..bdb5417bcec 100755
--- a/contrib/update-copyright.py
+++ b/contrib/update-copyright.py
@@ -408,7 +408,7 @@ class Copyright:
         line_filter = filter.get_line_filter (dir, filename)
         mode = None
         encoding = self.guess_encoding(pathname)
-        with open (pathname, 'r', encoding=encoding) as file:
+        with open (pathname, 'r', encoding=encoding, newline='\n') as file:
             prev = None
             mode = os.fstat (file.fileno()).st_mode
             for line in file:
@@ -434,7 +434,7 @@ class Copyright:
         # If something changed, write the new file out.
         if changed and self.errors.ok():
             tmp_pathname = pathname + '.tmp'
-            with open (tmp_pathname, 'w', encoding=encoding) as file:
+            with open (tmp_pathname, 'w', encoding=encoding, newline='\n') as file:
                 for line in lines:
                     file.write (line)
                 os.fchmod (file.fileno(), mode)
-- 
2.39.0


             reply	other threads:[~2023-01-17 12:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 12:00 Martin Liška [this message]
2023-03-11 16:20 ` Jeff Law

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=d15fec2f-b7aa-2830-089a-62c0fd0b66d9@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.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).