From patchwork Tue Jan 17 12:00:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 44648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1712942wrn; Tue, 17 Jan 2023 04:01:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXsH+lAr6We/Chzdd1TKv6jNt28LUuLvHSNOZPWRKqc0H5tNL6zvVYAvyvjrVyjHpmDhsW0X X-Received: by 2002:a17:906:df49:b0:84d:34fa:f1a4 with SMTP id if9-20020a170906df4900b0084d34faf1a4mr2332109ejc.60.1673956899822; Tue, 17 Jan 2023 04:01:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673956899; cv=none; d=google.com; s=arc-20160816; b=P3wbMxVAQyeyFoWReAuVNGgh5SvjbldHzk4K4TnigjvhW7NdXjiu+ncsJmxkLA7/4r QxR2SGYGpRKXqLxKJ8Fp8vEkTPzDq7gqVByDhH01/mN6GNlRYsmaV2jaNzB7TvQPjwaW 7ujYn1ahsuU1m1b1JDIP8RIZDizOe1lcjF9m7C0eaYf+Gx1Sn5I0VZ4n8mXhyEQG5nLG JfmBGoCtfoVnNIrv7PvphzQGdo+459C+ARraTcxYxAO0ZKnCzlhySluPV2eEJb/gR6D7 +fHFp/6iCqFiKj3RWVSHKsPoErWJUFjnWT8fppyZNqoL60qAF3QaUr9SIhZz5DV5sfJa NomA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:cc :content-language:to:subject:from:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:dmarc-filter:delivered-to; bh=yGedWzrp5tPqYESnMT0XRwwPrvn+gaJYOXWjz52Aduo=; b=BxwDyfwavjzrgp1zUEDSRnv5/o+ZqvGJeVYE+3Ks3otGMzra2kWPsUDcK0JAbUnfuM gVtvYkjwktssl4/7Lo3JJ6EcyDYNTrYBbIGKmU6ZJJkbSX8QLqbop1qHBVj1jHP0XLIt Hzrl8EzTsiKBQk+6WWxhV2cbZdXqNanGsvApp0s39p7BHDNg3ZtS65lJV0ESm2U1c1Rc y3yFqqvlxruauOTFrKeg6OViioMWuTgh+ZaPb/zECSvoOEgThKl/lDxXt43DDDJOMI29 92OsG3OfoYItpEUZLUdoOfSp5rz3KBGzMIie248n8m/Cw+mCU7wjvUdD29EZ2eESi7c/ Pvzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=a0Sg7zxp; dkim=neutral (no key) header.i=@gcc.gnu.org header.b=+u6Edfp6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id fj2-20020a1709069c8200b00871ca439062si2693683ejc.375.2023.01.17.04.01.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 04:01:39 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=a0Sg7zxp; dkim=neutral (no key) header.i=@gcc.gnu.org header.b=+u6Edfp6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7ED7E3854396 for ; Tue, 17 Jan 2023 12:01:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 2C0E1385B53E for ; Tue, 17 Jan 2023 12:00:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C0E1385B53E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7E1115CF7F; Tue, 17 Jan 2023 12:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1673956835; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yGedWzrp5tPqYESnMT0XRwwPrvn+gaJYOXWjz52Aduo=; b=a0Sg7zxpDL5urfQxwHHjd3PS6vb6X3Vyov03OOIfmhqNOCL0COuVYm//zAEmmbuPqTonoW Ntu+EOlrZwF8+H/KNnVpneRpeW4W+VrVgePB2B2Eo6QY/5+AzOKvQbmXaR3I2phXnXBMAn UUT0piBeD3JjELz6OA1vBgh93FpAm4Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1673956835; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yGedWzrp5tPqYESnMT0XRwwPrvn+gaJYOXWjz52Aduo=; b=+u6Edfp6tF2FAXrOmjDTS5zS9xYCLJB/cRreK82bE7Kt1eR7Bl4zrlq8gLo3pPdYTgXHe1 tVRsVvKyVyjQ8vCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6BDED13357; Tue, 17 Jan 2023 12:00:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id W5ZpGeONxmOVUgAAMHmgww (envelope-from ); Tue, 17 Jan 2023 12:00:35 +0000 Message-ID: Date: Tue, 17 Jan 2023 13:00:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] contrib: ignore CR in update-copyright.py To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: Jakub Jelinek X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755271029828082607?= X-GMAIL-MSGID: =?utf-8?q?1755271029828082607?= 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)