mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
checkpatch: Merge continuation-header handling from .38.
This commit is a cherry pick and squash of commits: 85c2ee62d37c19456c6dc83db262123956f010ac 4bc7c6001daba7d4037f54f67bae7fa90f759402 checkpatch: Handle continuation headers. Continuation headers baffle checkpatch, as it can only operate on one line of context at a time. When continuation headers are found, put them up with the header they're continuing so the whole thing can be parsed in a single line of context. checkpatch: Don't treat diffs as patches. The patch-header cleanup code assumed that it would only ever see patches, which was of course hogwash. This lead to crazy results as it tried to wrap what it thought were continuation lines at the beginnings of raw diffs. Signed-off-by: Gregory Bean <gbean@codeaurora.org> (cherry picked from commit 57d50ae730a057ee1099a94a397475bfd147d97b) Conflicts: scripts/checkpatch.pl Change-Id: I60b2d914ada9a8690b89ffb8c1e32a8b81a5e715
This commit is contained in:
parent
5bc97df95b
commit
20a44b003b
1 changed files with 29 additions and 0 deletions
|
@ -1341,6 +1341,33 @@ sub check_absolute_file {
|
|||
}
|
||||
}
|
||||
|
||||
sub cleanup_continuation_headers {
|
||||
# Collapse any header-continuation lines into a single line so they
|
||||
# can be parsed meaningfully, as the parser only has one line
|
||||
# of context to work with.
|
||||
my $again;
|
||||
do {
|
||||
$again = 0;
|
||||
foreach my $n (0 .. scalar(@rawlines) - 2) {
|
||||
if ($rawlines[$n]=~/^\s*$/) {
|
||||
# A blank line means there's no more chance
|
||||
# of finding headers. Shortcut to done.
|
||||
return;
|
||||
}
|
||||
if ($rawlines[$n]=~/^[\x21-\x39\x3b-\x7e]+:/ &&
|
||||
$rawlines[$n+1]=~/^\s+/) {
|
||||
# Continuation header. Collapse it.
|
||||
my $line = splice @rawlines, $n+1, 1;
|
||||
$line=~s/^\s+/ /;
|
||||
$rawlines[$n] .= $line;
|
||||
# We've 'destabilized' the list, so restart.
|
||||
$again = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
} while ($again);
|
||||
}
|
||||
|
||||
sub pos_last_openparen {
|
||||
my ($line) = @_;
|
||||
|
||||
|
@ -1431,7 +1458,9 @@ sub process {
|
|||
my $shorttext_exspc = 0;
|
||||
|
||||
sanitise_line_reset();
|
||||
cleanup_continuation_headers();
|
||||
my $line;
|
||||
|
||||
foreach my $rawline (@rawlines) {
|
||||
$linenr++;
|
||||
$line = $rawline;
|
||||
|
|
Loading…
Reference in a new issue