From: Jim Meyering Date: Wed, 29 Jul 2009 08:25:24 +0000 (+0200) Subject: maint: make update-copyright handle more cases X-Git-Tag: v7.5~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d87a45b2fb0fcf5239227b71345a507933636c0;p=platform%2Fupstream%2Fcoreutils.git maint: make update-copyright handle more cases * build-aux/update-copyright: Handle cases in which the final year number and copyright holder are on separate lines. Prompted by a report from Joel E. Denny. Also, do not invoke localtime for each line we process. --- diff --git a/build-aux/update-copyright b/build-aux/update-copyright index 42579c2..9039b7c 100755 --- a/build-aux/update-copyright +++ b/build-aux/update-copyright @@ -1,7 +1,7 @@ -#!/usr/bin/perl -w -pi +#!/usr/bin/perl -0777 -pi # Update an FSF copyright year list to include the current year. -my $VERSION = '2009-06-04 08:53'; # UTC +my $VERSION = '2009-07-29.08:18'; # UTC # Copyright (C) 2009 Free Software Foundation # @@ -21,15 +21,19 @@ my $VERSION = '2009-06-04 08:53'; # UTC # Written by Jim Meyering use strict; +use warnings; -my ($sec, $min, $hour, $mday, $month, $this_year) = localtime (time()); -$this_year += 1900; - +my $this_year; my $holder = 'Free Software Foundation'; -if (/([- ])((?:\d\d)?\d\d)\s+$holder/) +BEGIN { + my ($sec, $min, $hour, $mday, $month, $year) = localtime (time()); + $this_year = $year + 1900; +} + +if (/([- ])((?:\d\d)?\d\d)(\s+$holder)/s) { - my ($sep, $last_c_year) = ($1, $2); + my ($sep, $last_c_year, $rest) = ($1, $2, $3); # Handle two-digit year numbers like "98" and "99". $last_c_year <= 99 @@ -39,15 +43,15 @@ if (/([- ])((?:\d\d)?\d\d)\s+$holder/) { if ($sep eq '-' && $last_c_year + 1 == $this_year) { - s//-$this_year $holder/; + s//-$this_year$rest/; } elsif ($sep eq ' ' && $last_c_year + 1 == $this_year) { - s// $last_c_year-$this_year $holder/; + s// $last_c_year-$this_year$rest/; } else { - s//$sep$last_c_year, $this_year $holder/; + s//$sep$last_c_year, $this_year$rest/; } } } @@ -56,7 +60,7 @@ if (/([- ])((?:\d\d)?\d\d)\s+$holder/) # indent-tabs-mode: nil # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "my $VERSION = '" -# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-format: "%:y-%02m-%02d.%02H:%02M" # time-stamp-time-zone: "UTC" # time-stamp-end: "'; # UTC" # End: