]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
spacecheck: show line numbers of duplicate empty lines
authorViktor Szakats <commit@vsz.me>
Mon, 12 Jan 2026 16:21:42 +0000 (17:21 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 12 Jan 2026 21:21:01 +0000 (22:21 +0100)
Also:
- drop separate check for 3 or more consecutive empty lines.

Ref: https://github.com/curl/curl/pull/20266#issuecomment-3738955165

Closes #20269

scripts/spacecheck.pl

index 0ff52345291baabe0628455cbb7cf25b43ea43cd..761200f40940cebc7d8f7a2879d3cf9ba48b8cbe 100755 (executable)
@@ -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;
+                }
+            }
         }
     }