mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-30 02:50:25 +08:00
* update-copyright: Silently skip nonexistent files. Display filename on
update. Don't update non-Red Hat copyrights.
This commit is contained in:
parent
0413f0bd40
commit
eb0876b22f
@ -1,3 +1,8 @@
|
||||
2013-01-20 Christopher Faylor <me.cygwin2013@cgf.cx>
|
||||
|
||||
* update-copyright: Silently skip nonexistent files. Display filename
|
||||
on update. Don't update non-Red Hat copyrights.
|
||||
|
||||
2013-01-20 Christopher Faylor <me.cygwin2013@cgf.cx>
|
||||
|
||||
* update-copyright: Update standard copyright information based on cvs
|
||||
|
@ -21,7 +21,8 @@ while (<$cvs>) {
|
||||
} elsif (/^date: (\d+)/o) {
|
||||
$files{$file}{$1} = 1;
|
||||
} elsif (/^=+$/o) {
|
||||
update_maybe($file, %{delete $files{$file}});
|
||||
my $rec = delete $files{$file};
|
||||
update_maybe($file, %{$rec}) if -e $file;
|
||||
}
|
||||
}
|
||||
close $cvs;
|
||||
@ -29,8 +30,9 @@ close $cvs;
|
||||
exit 0;
|
||||
|
||||
sub addwrap($$) {
|
||||
my $copyright = shift;
|
||||
my $indent = shift;
|
||||
my $copyright = shift;
|
||||
$copyright =~ s/Red Hat\n/Red Hat, Inc.\n/so;
|
||||
return $copyright if length($copyright) <= 80;
|
||||
my @lines;
|
||||
while (length($copyright) > 80) {
|
||||
@ -39,7 +41,7 @@ sub addwrap($$) {
|
||||
substr($copyright, 0, $i + 1) = $indent;
|
||||
}
|
||||
push @lines, $copyright unless $copyright =~ /^\s*$/o;
|
||||
return @lines;
|
||||
return join('', @lines);
|
||||
}
|
||||
|
||||
sub update_maybe($%) {
|
||||
@ -48,26 +50,33 @@ sub update_maybe($%) {
|
||||
my %dates = @_;
|
||||
my @file = ();
|
||||
my $copyright = '';
|
||||
my $modified = 1;
|
||||
my $modified = 0;
|
||||
while (<>) {
|
||||
if ($copyright) {
|
||||
push @file, $_;
|
||||
} elsif (/^\s*Copyright/o) {
|
||||
$copyright = $_;
|
||||
$copyright .= scalar <> while $copyright =~ /,\s*$/o;
|
||||
if ($copyright !~ /Red Hat, Inc\.\n/o) {
|
||||
push @file, $copyright;
|
||||
next;
|
||||
}
|
||||
for my $date ($copyright =~ /(\d+)/g) {
|
||||
$dates{$date} = 1;
|
||||
}
|
||||
my $indent = ($copyright =~ /\A(\s*)/o)[0];
|
||||
$copyright = $indent . 'Copyright ' .
|
||||
(join ', ', sort {$a <=> $b} sort keys %dates) .
|
||||
" Red Hat\n";
|
||||
push @file, addwrap($copyright, $indent);
|
||||
my $newcopyright = addwrap $indent,
|
||||
$indent . 'Copyright ' .
|
||||
(join ', ', sort {$a <=> $b} sort keys %dates) .
|
||||
" Red Hat, Inc.\n";
|
||||
push @file, $newcopyright;
|
||||
$modified = $newcopyright ne $copyright;
|
||||
} else {
|
||||
push @file, $_;
|
||||
}
|
||||
}
|
||||
if ($modified) {
|
||||
print "updating $f\n";
|
||||
my $fcopy = "$f.copyright";
|
||||
rename $f, $fcopy or die "$0: couldn't rename $f -> $fcopy - $!\n";
|
||||
my $st = stat($fcopy);
|
||||
|
Loading…
x
Reference in New Issue
Block a user