Skip to content

Commit c76f4cb

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: improve space before tab --fix option
This test should remove all the spaces before a tab not just one space. Substitute a tab for each 8 space block before a tab and remove less than 8 spaces before a tab. This SPACE_BEFORE_TAB test is done after CODE_INDENT. If there are spaces used at the beginning of a line that should be converted to tabs, please make sure that the CODE_INDENT test and conversion is done before this SPACE_BEFORE_TAB test and conversion. Reported-by: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Joe Perches <joe@perches.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9624b8d commit c76f4cb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎scripts/checkpatch.pl‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,8 +2118,10 @@ sub process {
21182118
if (WARN("SPACE_BEFORE_TAB",
21192119
"please, no space before tabs\n" . $herevet) &&
21202120
$fix) {
2121-
$fixed[$linenr - 1] =~
2122-
s/(^\+.*) +\t/$1\t/;
2121+
while ($fixed[$linenr - 1] =~
2122+
s/(^\+.*) {8,8}+\t/$1\t\t/) {}
2123+
while ($fixed[$linenr - 1] =~
2124+
s/(^\+.*) +\t/$1\t/) {}
21232125
}
21242126
}
21252127

0 commit comments

Comments
 (0)