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,
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;
sub checkfile {
my ($file, $skipped, $pattern) = @_;
- my $fine = 0;
- @copyright=();
$spdx = 0;
my $found = scanfile($file);
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 {