[gcc r17-2772] contrib: add support for tabs in the middle of the line
Torbjorn Svensson via Gcc-cvs <[email protected]> Wed, 29 Jul 2026 05:07:44 +0000 (GMT)
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:5dfea15a44343841a5d3d18ee736eaeb4f48fb1d commit r17-2772-g5dfea15a44343841a5d3d18ee736eaeb4f48fb1d Author: Torbjörn SVENSSON <[email protected]> Date: Tue Jul 28 22:15:28 2026 +0200 contrib: add support for tabs in the middle of the line When running the style checker, it can incorrectly, report an error for too wide lines if the tab is not at the start of the line. In below example, I'm using ^I to visualise a tab. bool begun;^I^I^I^I/* True if begin initialized output state. */ Without this patch, the line above is reported to be longer than 80 characters, but it's only 78 characters long. With the patch, its correct length is used and the check passes. contrib/ChangeLog: * check_GNU_style_lib.py: Use visual tab size rather than blindly using 8 spaces as replacement. Signed-off-by: Torbjörn SVENSSON <[email protected]> Diff: --- contrib/check_GNU_style_lib.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py index a7c4e2b0bd55..d057faa51cd3 100755 --- a/contrib/check_GNU_style_lib.py +++ b/contrib/check_GNU_style_lib.py @@ -78,10 +78,9 @@ class CheckError: class LineLengthCheck: def __init__(self): self.limit = 80 - self.expanded_tab = ' ' * ts def check(self, filename, lineno, line): - line_expanded = line.replace('\t', self.expanded_tab) + line_expanded = line.expandtabs(ts) if not filename.endswith(".opt") and len(line_expanded) > self.limit: return CheckError(filename, lineno, line_expanded[:self.limit]