Skip to content

Commit

Permalink
checkpatch: improve space before tab --fix option
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Joe Perches <[email protected]>
Cc: Josh Triplett <[email protected]>
Cc: Andy Whitcroft <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Jan 24, 2014
1 parent 9624b8d commit c76f4cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2118,8 +2118,10 @@ sub process {
if (WARN("SPACE_BEFORE_TAB",
"please, no space before tabs\n" . $herevet) &&
$fix) {
$fixed[$linenr - 1] =~
s/(^\+.*) +\t/$1\t/;
while ($fixed[$linenr - 1] =~
s/(^\+.*) {8,8}+\t/$1\t\t/) {}
while ($fixed[$linenr - 1] =~
s/(^\+.*) +\t/$1\t/) {}
}
}

Expand Down

0 comments on commit c76f4cb

Please sign in to comment.