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>
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]