diff options
author | Christopher Faylor <me@cgf.cx> | 2013-01-20 23:56:26 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2013-01-20 23:56:26 +0000 |
commit | 0413f0bd404d61e8a7807f356346b2c522d81dd9 (patch) | |
tree | 535d6f4e9e932f359ce078005ca82215557cd4f0 | |
parent | 4713b1b294d8eacbf42b65aa794acb15bb18edee (diff) | |
download | newlib-0413f0bd404d61e8a7807f356346b2c522d81dd9.zip newlib-0413f0bd404d61e8a7807f356346b2c522d81dd9.tar.gz newlib-0413f0bd404d61e8a7807f356346b2c522d81dd9.tar.bz2 |
* update-copyright: Update standard copyright information based on cvs log and
current sandbox status.
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rwxr-xr-x | winsup/cygwin/update-copyright | 80 |
2 files changed, 85 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2c5b7e3..e61c451 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,10 @@ 2013-01-20 Christopher Faylor <me.cygwin2013@cgf.cx> + * update-copyright: Update standard copyright information based on cvs + log and current sandbox status. + +2013-01-20 Christopher Faylor <me.cygwin2013@cgf.cx> + * malloc_wrapper.cc: Change 'use_internal_malloc' to 'use_internal' throughout. (export_malloc_called): Delete. diff --git a/winsup/cygwin/update-copyright b/winsup/cygwin/update-copyright new file mode 100755 index 0000000..1ea2a53 --- /dev/null +++ b/winsup/cygwin/update-copyright @@ -0,0 +1,80 @@ +#!/usr/bin/perl +use strict; +use File::stat; +sub update_maybe($%); + +my $year = (split ' ', ~~localtime)[4]; +my %dates = (); +my %files = (); +my $cvs; +open $cvs, '-|', '/usr/bin/cvs', 'update', @ARGV or die "cvs update failed - $!\n"; +while (<$cvs>) { + /^M (.*)$/o and $files{$1}{$year} = 1; +} +close $cvs; + +open $cvs, '-|', '/usr/bin/cvs', 'log', '-N', '-b', @ARGV or die "cvs log failed - $!\n"; +my $file; +while (<$cvs>) { + if (/^Working file: (.*)$/o) { + $file = $1; + } elsif (/^date: (\d+)/o) { + $files{$file}{$1} = 1; + } elsif (/^=+$/o) { + update_maybe($file, %{delete $files{$file}}); + } +} +close $cvs; + +exit 0; + +sub addwrap($$) { + my $copyright = shift; + my $indent = shift; + return $copyright if length($copyright) <= 80; + my @lines; + while (length($copyright) > 80) { + my $i = index($copyright, ' ', 80 - 6); + push @lines, substr($copyright, 0, $i) . "\n"; + substr($copyright, 0, $i + 1) = $indent; + } + push @lines, $copyright unless $copyright =~ /^\s*$/o; + return @lines; +} + +sub update_maybe($%) { + my $f = shift; + local @ARGV = $f; + my %dates = @_; + my @file = (); + my $copyright = ''; + my $modified = 1; + while (<>) { + if ($copyright) { + push @file, $_; + } elsif (/^\s*Copyright/o) { + $copyright = $_; + $copyright .= scalar <> while $copyright =~ /,\s*$/o; + 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); + } else { + push @file, $_; + } + } + if ($modified) { + my $fcopy = "$f.copyright"; + rename $f, $fcopy or die "$0: couldn't rename $f -> $fcopy - $!\n"; + my $st = stat($fcopy); + open my $fd, '>', $f; + chmod $st->mode & 07777, $f; + print $fd @file; + close $fd; + } +} + |