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
12491249 my $pre_ctx = "$1$2";
12501250
12511251 my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
1252− my $ctx_ln = $linenr + $#ctx + 1;
12531252 my $ctx_cnt = $realcnt - $#ctx - 1;
12541253 my $ctx = join("\n", @ctx);
12551254
1256− ##warn "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
1255+ my $ctx_ln = $linenr;
1256+ my $ctx_skip = $realcnt;
12571257
1258− # Skip over any removed lines in the context following statement.
1259− while (defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^-/) {
1258+ while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt &&
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] !~ /^-/);
12601263 $ctx_ln++;
12611264 }
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";
12631268
12641269 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
12651270 ERROR("that open brace { should be on the previous line\n" .