]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
copyright.pl: cease doing year verifications
authorDaniel Stenberg <daniel@haxx.se>
Sat, 28 Jan 2023 10:22:35 +0000 (11:22 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 29 Jan 2023 09:27:28 +0000 (10:27 +0100)
As we have (mostly) removed the copyright year ranges.

Reported-by: Ryan Schmidt
Fixes #10345
Closes #10352

scripts/copyright.pl

index 7c4ce659d7acfcb6d9f8eba86ea945a02a14d029..f295107ad6de62aae6e9639a95f2039d9aff2df8 100755 (executable)
@@ -59,7 +59,8 @@ sub scanfile {
         chomp;
         my $l = $_;
         # check for a copyright statement and save the years
-        if($l =~ /.* ?copyright .* *\d\d\d\d/i) {
+        if($l =~ /.* ?copyright .* (\d\d\d\d|)/i) {
+            my $count = 0;
             while($l =~ /([\d]{4})/g) {
                 push @copyright, {
                   year => $1,
@@ -67,8 +68,19 @@ sub scanfile {
                   col => index($l, $1),
                   code => $l
                 };
-                $found++;
+                $count++;
             }
+            if(!$count) {
+                # year-less
+                push @copyright, {
+                    year => -1,
+                    line => $line,
+                    col => index($l, $1),
+                    code => $l
+                };
+                $count++;
+            }
+            $found = $count;
         }
         if($l =~ /SPDX-License-Identifier:/) {
             $spdx = 1;
@@ -84,8 +96,6 @@ sub scanfile {
 
 sub checkfile {
     my ($file, $skipped, $pattern) = @_;
-    my $fine = 0;
-    @copyright=();
     $spdx = 0;
     my $found = scanfile($file);
 
@@ -113,38 +123,12 @@ sub checkfile {
         return 2;
     }
 
-    my $commityear = undef;
-    @copyright = sort {$$b{year} cmp $$a{year}} @copyright;
-
-    # if the file is modified, assume commit year this year
-    if(`git status -s -- $file` =~ /^ [MARCU]/) {
-        $commityear = (localtime(time))[5] + 1900;
-    }
-    else {
-        # min-parents=1 to ignore wrong initial commit in truncated repos
-        my $grl = `git rev-list --max-count=1 --min-parents=1 --timestamp HEAD -- $file`;
-        if($grl) {
-            chomp $grl;
-            $commityear = (localtime((split(/ /, $grl))[0]))[5] + 1900;
-        }
-    }
-
-    if(defined($commityear) && scalar(@copyright) &&
-       $copyright[0]{year} != $commityear) {
-        printf "$file:%d: copyright year out of date, should be $commityear, " .
-            "is $copyright[0]{year}\n",
-            $copyright[0]{line} if(!$skipped || $verbose);
-        $skips{$pattern}++ if($skipped);
-    }
-    else {
-        $fine = 1;
-    }
-    if($skipped && $fine) {
+    if($skipped) {
         print "$file:1: ignored superfluously by $pattern\n" if($verbose);
         $superf{$pattern}++;
     }
 
-    return $fine;
+    return 1;
 }
 
 sub dep5 {