From: Viktor Szakats Date: Mon, 12 Jan 2026 16:21:42 +0000 (+0100) Subject: spacecheck: show line numbers of duplicate empty lines X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e52e6dac8e83dd06306e3e9eca32a39575e8fec6;p=thirdparty%2Fcurl.git spacecheck: show line numbers of duplicate empty lines Also: - drop separate check for 3 or more consecutive empty lines. Ref: https://github.com/curl/curl/pull/20266#issuecomment-3738955165 Closes #20269 --- diff --git a/scripts/spacecheck.pl b/scripts/spacecheck.pl index 0ff5234529..761200f409 100755 --- a/scripts/spacecheck.pl +++ b/scripts/spacecheck.pl @@ -147,15 +147,25 @@ while(my $filename = <$git_ls_files>) { push @err, "content: has multiple EOL at EOF"; } - if($content =~ /\n\n\n\n/ || - $content =~ /\r\n\r\n\r\n\r\n/) { - push @err, "content: has 3 or more consecutive empty lines"; - } - if(!fn_match($filename, @double_empty_lines)) { if($content =~ /\n\n\n/ || $content =~ /\r\n\r\n\r\n/) { - push @err, "content: has 2 consecutive empty lines"; + my $line = 0; + my $blank = 0; + for my $l (split(/\n/, $content)) { + chomp $l; + $line++; + if($l =~ /^$/) { + if($blank) { + my $lineno = sprintf("duplicate empty line @ line %d", $line); + push @err, $lineno; + } + $blank = 1; + } + else { + $blank = 0; + } + } } }