From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 11A673858400; Mon, 18 Oct 2021 09:08:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11A673858400 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4469] gcc-changelog: update error message location X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/heads/master X-Git-Oldrev: 47e4ab6559dc857df66403824909b5ab73891fd2 X-Git-Newrev: 85ce673378e7091ce603b033fac213a9d0d1f83a Message-Id: <20211018090835.11A673858400@sourceware.org> Date: Mon, 18 Oct 2021 09:08:35 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Oct 2021 09:08:35 -0000 https://gcc.gnu.org/g:85ce673378e7091ce603b033fac213a9d0d1f83a commit r12-4469-g85ce673378e7091ce603b033fac213a9d0d1f83a Author: Martin Liska Date: Mon Oct 18 10:44:11 2021 +0200 gcc-changelog: update error message location contrib/ChangeLog: * gcc-changelog/git_commit.py: Update location of 'bad parentheses wrapping'. * gcc-changelog/test_email.py: Test it. Diff: --- contrib/gcc-changelog/git_commit.py | 14 +++++++------- contrib/gcc-changelog/test_email.py | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index f26dc3b4135..cf29f761964 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -217,7 +217,7 @@ class ChangeLogEntry: self.lines = [] self.files = [] self.file_patterns = [] - self.opened_parentheses = 0 + self.parentheses_stack = [] def parse_file_names(self): # Whether the content currently processed is between a star prefix the @@ -551,7 +551,7 @@ class GitCommit: m = star_prefix_regex.match(line) if m: if (len(m.group('spaces')) != 1 and - last_entry.opened_parentheses == 0): + not last_entry.parentheses_stack): msg = 'one space should follow asterisk' self.errors.append(Error(msg, line)) else: @@ -576,13 +576,13 @@ class GitCommit: def process_parentheses(self, last_entry, line): for c in line: if c == '(': - last_entry.opened_parentheses += 1 + last_entry.parentheses_stack.append(line) elif c == ')': - if last_entry.opened_parentheses == 0: + if not last_entry.parentheses_stack: msg = 'bad wrapping of parenthesis' self.errors.append(Error(msg, line)) else: - last_entry.opened_parentheses -= 1 + del last_entry.parentheses_stack[-1] def parse_file_names(self): for entry in self.changelog_entries: @@ -608,9 +608,9 @@ class GitCommit: def check_for_broken_parentheses(self): for entry in self.changelog_entries: - if entry.opened_parentheses != 0: + if entry.parentheses_stack: msg = 'bad parentheses wrapping' - self.errors.append(Error(msg, entry.lines[0])) + self.errors.append(Error(msg, entry.parentheses_stack[-1])) def get_file_changelog_location(self, changelog_file): for file in self.info.modified_files: diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py index dae7c27c707..a4796dbbe94 100755 --- a/contrib/gcc-changelog/test_email.py +++ b/contrib/gcc-changelog/test_email.py @@ -415,6 +415,7 @@ class TestGccChangelog(unittest.TestCase): def test_multiline_bad_parentheses(self): email = self.from_patch_glob('0002-Wrong-macro-changelog.patch') assert email.errors[0].message == 'bad parentheses wrapping' + assert email.errors[0].line == ' * config/i386/i386.md (*fix_trunc_i387_1,' def test_changelog_removal(self): email = self.from_patch_glob('0001-ChangeLog-removal.patch')