]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
contrib: add support for tabs in the middle of the line
authorTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Tue, 28 Jul 2026 20:15:28 +0000 (22:15 +0200)
committerTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Wed, 29 Jul 2026 05:07:22 +0000 (07:07 +0200)
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 <torbjorn.svensson@foss.st.com>
contrib/check_GNU_style_lib.py

index a7c4e2b0bd5567d7c38f6e51816b03dd094ce9c3..d057faa51cd32297aafeea9c78b5bc863d17b737 100755 (executable)
@@ -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]