Skip to content

Commit

Permalink
checkpatch: report missing spaces around trigraphs with --strict
Browse files Browse the repository at this point in the history
Spaces around trigraphs are specified by CodingStyle but checkpatch is
currently silent about them because there are many current instances
without them.

Make missing spaces around trigraphs a --strict message.

Signed-off-by: Joe Perches <[email protected]>
Reviewed-by: Josh Triplett <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Nov 13, 2013
1 parent 6bc080d commit 8473162
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2838,7 +2838,7 @@ sub process {
\+=|-=|\*=|\/=|%=|\^=|\|=|&=|
=>|->|<<|>>|<|>|=|!|~|
&&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
\?|:
\?:|\?|:
}x;
my @elements = split(/($ops|;)/, $opline);

Expand Down Expand Up @@ -3061,15 +3061,13 @@ sub process {
$ok = 1;
}

# Ignore ?:
if (($opv eq ':O' && $ca =~ /\?$/) ||
($op eq '?' && $cc =~ /^:/)) {
$ok = 1;
}

# messages are ERROR, but ?: are CHK
if ($ok == 0) {
if (ERROR("SPACING",
"spaces required around that '$op' $at\n" . $hereptr)) {
my $msg_type = \&ERROR;
$msg_type = \&CHK if (($op eq '?:' || $op eq '?' || $op eq ':') && $ctx =~ /VxV/);

if (&{$msg_type}("SPACING",
"spaces required around that '$op' $at\n" . $hereptr)) {
$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
if (defined $fix_elements[$n + 2]) {
$fix_elements[$n + 2] =~ s/^\s+//;
Expand Down

0 comments on commit 8473162

Please sign in to comment.