From eb0876b22f1ea035959416cb1780236df011222a Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 21 Jan 2013 03:55:55 +0000 Subject: [PATCH] * update-copyright: Silently skip nonexistent files. Display filename on update. Don't update non-Red Hat copyrights. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/update-copyright | 25 +++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e61c45108..5ababd9bc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2013-01-20 Christopher Faylor + + * update-copyright: Silently skip nonexistent files. Display filename + on update. Don't update non-Red Hat copyrights. + 2013-01-20 Christopher Faylor * update-copyright: Update standard copyright information based on cvs diff --git a/winsup/cygwin/update-copyright b/winsup/cygwin/update-copyright index 1ea2a5376..47ab14f32 100755 --- a/winsup/cygwin/update-copyright +++ b/winsup/cygwin/update-copyright @@ -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);