From patchwork Sun Dec 11 16:21:09 2022 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: 1714681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=cSu4wEC1; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Eu3lDQsd; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVVPh73KWz23np for ; Mon, 12 Dec 2022 03:21:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 071F938AABB2 for ; Sun, 11 Dec 2022 16:21:27 +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 B95813834E16 for ; Sun, 11 Dec 2022 16:21:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B95813834E16 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 D4C201FD66; Sun, 11 Dec 2022 16:21:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1670775669; 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=Jd0YQzRXX60nBW7Un5AdtJFbCEm8DRptMeqwyR7xXEY=; b=cSu4wEC14dJk2K4Bikz3yorYcVelxYqqa83qkbRd4147x42tctHg8giCazF58LcbYEcgq2 9QZFyY6DTin40EB+n9ldsRBk9jXLXVul1NG1NJm4quHuzBMMokPz6/cdO1XbHWVPfmk9LS 8YRdO8OuE/H/c/pZZJWzb1kRoTrRnnM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1670775669; 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=Jd0YQzRXX60nBW7Un5AdtJFbCEm8DRptMeqwyR7xXEY=; b=Eu3lDQsdjo6QHsjjIlNTPPH6lKY3ctEd1xGJkdbkxlFUGDdnWmNYd+hk4X7YYIA3gntnho 6dRmNeaXuts6Y/CQ== 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 BC9E71376E; Sun, 11 Dec 2022 16:21:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9u+7LHUDlmMGWgAAMHmgww (envelope-from ); Sun, 11 Dec 2022 16:21:09 +0000 Message-ID: Date: Sun, 11 Dec 2022 17:21:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH (pushed)] unidiff: use newline='\n' argument To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: arthur.cohen@embecosm.com, Thomas Schwinge X-Spam-Status: No, score=-11.7 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" In order to support CR on a line, we need to open files with newline='\n' as our line endings supposed to be of UNIX style. Pushed to master. contrib/ChangeLog: * check_GNU_style.py: Use newline=\n. * check_GNU_style_lib.py: Simplify. * gcc-changelog/git_commit.py: Fix issues seen Rust patchset. * gcc-changelog/git_email.py: Use newline argument. * gcc-changelog/test_email.py: New test. * gcc-changelog/test_patches.txt: New test. * mklog.py: Use newline argument. --- contrib/check_GNU_style.py | 6 +++--- contrib/check_GNU_style_lib.py | 4 ++-- contrib/gcc-changelog/git_commit.py | 11 ++++++----- contrib/gcc-changelog/git_email.py | 2 +- contrib/gcc-changelog/test_email.py | 6 +++++- contrib/gcc-changelog/test_patches.txt | 26 ++++++++++++++++++++++++++ contrib/mklog.py | 2 +- 7 files changed, 44 insertions(+), 13 deletions(-) diff --git a/contrib/check_GNU_style.py b/contrib/check_GNU_style.py index 61faa290fa1..969534a3cc9 100755 --- a/contrib/check_GNU_style.py +++ b/contrib/check_GNU_style.py @@ -35,9 +35,9 @@ def main(): format = args.format if filename == '-': - check_GNU_style_file(sys.stdin, None, format) + check_GNU_style_file(sys.stdin, format) else: - with open(filename, 'rb') as diff_file: - check_GNU_style_file(diff_file, 'utf-8', format) + with open(filename, newline='\n') as diff_file: + check_GNU_style_file(diff_file, format) main() diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py index b5ab67ed285..b3db4fbddc9 100755 --- a/contrib/check_GNU_style_lib.py +++ b/contrib/check_GNU_style_lib.py @@ -262,7 +262,7 @@ class SpacesAndTabsMixedTest(unittest.TestCase): r = self.check.check('foo', 123, '\t a = 123;') self.assertIsNone(r) -def check_GNU_style_file(file, file_encoding, format): +def check_GNU_style_file(file, format): checks = [LineLengthCheck(), SpacesCheck(), TrailingWhitespaceCheck(), SentenceSeparatorCheck(), SentenceEndOfCommentCheck(), SentenceDotEndCheck(), FunctionParenthesisCheck(), @@ -271,7 +271,7 @@ def check_GNU_style_file(file, file_encoding, format): SpacesAndTabsMixedCheck()] errors = [] - patch = PatchSet(file, encoding=file_encoding) + patch = PatchSet(file) for pfile in patch.added_files + patch.modified_files: t = pfile.target_file.lstrip('b/') diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index aae3416e082..d90e6c19b76 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -718,11 +718,12 @@ class GitCommit: if not prs: # if all ChangeLog entries have identical PRs # then use them - prs = self.changelog_entries[0].prs - for entry in self.changelog_entries: - if entry.prs != prs: - prs = [] - break + if self.changelog_entries: + prs = self.changelog_entries[0].prs + for entry in self.changelog_entries: + if entry.prs != prs: + prs = [] + break entry = ChangeLogEntry(changelog_location, self.top_level_authors, prs) diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py index 87b419cae5d..2566d4149e7 100755 --- a/contrib/gcc-changelog/git_email.py +++ b/contrib/gcc-changelog/git_email.py @@ -37,7 +37,7 @@ unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename') class GitEmail(GitCommit): def __init__(self, filename): self.filename = filename - diff = PatchSet.from_filename(filename) + diff = PatchSet.from_filename(filename, newline='\n') date = None author = None subject = '' diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py index d0de88cf562..b9d0cb4157c 100755 --- a/contrib/gcc-changelog/test_email.py +++ b/contrib/gcc-changelog/test_email.py @@ -44,7 +44,7 @@ class TestGccChangelog(unittest.TestCase): filename = None patch_lines = [] - with open(os.path.join(script_path, 'test_patches.txt')) as f: + with open(os.path.join(script_path, 'test_patches.txt'), newline='\n') as f: lines = f.read() for line in lines.split('\n'): if line.startswith('==='): @@ -455,3 +455,7 @@ class TestGccChangelog(unittest.TestCase): def test_space_after_tab(self): email = self.from_patch_glob('0001-Use-Value_Range-when-applying-inferred-ranges.patch') assert (email.errors[0].message == 'extra space after tab') + + def test_CR_in_patch(self): + email = self.from_patch_glob('0001-Add-M-character.patch') + assert (email.errors[0].message == 'cannot find a ChangeLog location in message') diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt index b28de7d30b0..c378c32423a 100644 --- a/contrib/gcc-changelog/test_patches.txt +++ b/contrib/gcc-changelog/test_patches.txt @@ -3610,3 +3610,29 @@ index 0b9aa3639c5..f279371948a 100644 if (r.intersect (infer.range (x))) -- 2.38.0 + +=== 0001-Add-M-character.patch ==== +From 71ab4c18f279dc0fa0172ffe8cfac5fabcde953d Mon Sep 17 00:00:00 2001 +From: Martin Liska +Date: Fri, 9 Dec 2022 11:55:21 +0100 +Subject: [PATCH] Add ^M character + +--- + demo.txt | 5 +++++ + 1 file changed, 5 insertions(+) + create mode 100644 demo.txt + +diff --git a/demo.txt b/demo.txt +new file mode 100644 +index 0000000..d75da75 +--- /dev/null ++++ b/demo.txt +@@ -0,0 +1,5 @@ ++pub fn main () ++{ ++// { dg-error "Isolated CR" "" { target *-*-* } .+1 } ++ //! doc cr comment ++} +-- +2.38.1 + diff --git a/contrib/mklog.py b/contrib/mklog.py index 91c0dcd8864..3a6ec681b65 100755 --- a/contrib/mklog.py +++ b/contrib/mklog.py @@ -361,7 +361,7 @@ if __name__ == '__main__': if args.directory: root = args.directory - data = open(args.input) if args.input else sys.stdin + data = open(args.input, newline='\n') if args.input else sys.stdin if args.update_copyright: update_copyright(data) else: