History

checkpatch: trailing statement indent: fix end of statement location

Fix end of statement location. Where the last line of the statement is replaced we are miss reporting the newly added replacement an incorrectly indented trailing statement for the negative context. We are also incorrectly reporting negative statements generally.

Andy Whitcroft committed 18 years ago

Commit 548596d1 parent a3bb97a1 file · +10 −5Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+10−5
@@ -1249,17 +1249,22 @@ sub process { · 1248 unmodified lines
1249 my $pre_ctx = "$1$2";1249 my $pre_ctx = "$1$2";
1250 1250
1251 my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);1251 my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
1252 my $ctx_ln = $linenr + $#ctx + 1;
1253 my $ctx_cnt = $realcnt - $#ctx - 1;1252 my $ctx_cnt = $realcnt - $#ctx - 1;
1254 my $ctx = join("\n", @ctx);1253 my $ctx = join("\n", @ctx);
1255 1254
1256 ##warn "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";1255 my $ctx_ln = $linenr;
1256 my $ctx_skip = $realcnt;
1257 1257
1258 # Skip over any removed lines in the context following statement.1258 while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt &&
1259 while (defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^-/) {1259 defined $lines[$ctx_ln - 1] &&
1260 $lines[$ctx_ln - 1] =~ /^-/)) {
1261 ##print "SKIP<$ctx_skip> CNT<$ctx_cnt>\n";
1262 $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
1260 $ctx_ln++;1263 $ctx_ln++;
1261 }1264 }
1262 ##warn "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";1265
1266 ##print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
1267 ##print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
1263 1268
1264 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {1269 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
1265 ERROR("that open brace { should be on the previous line\n" .1270 ERROR("that open brace { should be on the previous line\n" .