From 0e293bacb19831362cadc68d3ed5cb6192b38209 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 28 Jan 2023 11:22:35 +0100 Subject: copyright.pl: cease doing year verifications As we have (mostly) removed the copyright year ranges. Reported-by: Ryan Schmidt Fixes #10345 Closes #10352 --- scripts/copyright.pl | 48 ++++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'scripts') diff --git a/scripts/copyright.pl b/scripts/copyright.pl index 7c4ce659d..f295107ad 100755 --- a/scripts/copyright.pl +++ b/scripts/copyright.pl @@ -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 { -- cgit v1.2.1