diff options
author | Joel E. Denny <jdenny@clemson.edu> | 2009-08-14 01:10:08 -0400 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-08-14 09:47:36 +0200 |
commit | 1978084a56315dc7563f99b4315564be1843ecae (patch) | |
tree | 529a594234a500ab69675593c45402f96ef81164 /build-aux/update-copyright | |
parent | bde528ccc0614e7df112e1e1d9f08843741e8321 (diff) | |
download | gnulib-1978084a56315dc7563f99b4315564be1843ecae.tar.gz |
update-copyright: much ado about intervals
* build-aux/update-copyright: Implement and document
UPDATE_COPYRIGHT_USE_INTERVALS to control expansion and collapse
of copyright year intervals.
Also, document UPDATE_COPYRIGHT_YEAR.
* tests/test-update-copyright.sh: Test it.
Diffstat (limited to 'build-aux/update-copyright')
-rwxr-xr-x | build-aux/update-copyright | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/build-aux/update-copyright b/build-aux/update-copyright index fb1c7d2b79..d8445fee08 100755 --- a/build-aux/update-copyright +++ b/build-aux/update-copyright @@ -1,7 +1,7 @@ #!/usr/bin/perl -0777 -pi # Update an FSF copyright year list to include the current year. -my $VERSION = '2009-08-14.02:23'; # UTC +my $VERSION = '2009-08-14.05:03'; # UTC # Copyright (C) 2009 Free Software Foundation, Inc. # @@ -92,6 +92,16 @@ my $VERSION = '2009-08-14.02:23'; # UTC # within the FSF copyright statement. # 7. Each copyright year is 2 or 4 digits, and years are separated by # commas or dashes. Whitespace may occur after commas. +# +# Environment variables: +# +# 1. If UPDATE_COPYRIGHT_USE_INTERVALS=1, every series of consecutive +# copyright years (such as 90, 1991, 1992-2007, 2008) in an updated +# FSF copyright statement is collapsed to a single interval (such +# as 1990-2008). If unset or set to 0, all existing copyright year +# intervals are expanded. +# 2. For testing purposes, you can set the assumed current year in +# UPDATE_COPYRIGHT_YEAR. use strict; use warnings; @@ -138,7 +148,7 @@ while (/(^|\n)(.{0,$prefix_max})$copyright_re/g) $holder_re =~ s/\s/$ws_re/g; my $stmt_remainder_re = "(?:$ws_re$circle_c_re)?" - . "$ws_re(?:(?:\\d\\d)?\\d\\d(,$ws_re?|-))*" + . "$ws_re(?:(?:\\d\\d)?\\d\\d(?:,$ws_re?|-))*" . "((?:\\d\\d)?\\d\\d)$ws_re$holder_re"; if (/\G$stmt_remainder_re/) { @@ -151,8 +161,7 @@ if (defined $stmt_re) { /$stmt_re/ or die; # Should never die. my $stmt = $1; - my $sep = $2 ? $2 : ""; - my $final_year_orig = $3; + my $final_year_orig = $2; # Handle two-digit year numbers like "98" and "99". my $final_year = $final_year_orig; @@ -162,18 +171,7 @@ if (defined $stmt_re) if ($final_year != $this_year) { # Update the year. - if ($sep eq '-' && $final_year + 1 == $this_year) - { - $stmt =~ s/$final_year_orig/$this_year/; - } - elsif ($sep ne '-' && $final_year + 1 == $this_year) - { - $stmt =~ s/$final_year_orig/$final_year-$this_year/; - } - else - { - $stmt =~ s/$final_year_orig/$final_year, $this_year/; - } + $stmt =~ s/$final_year_orig/$final_year, $this_year/; # Normalize all whitespace including newline-prefix sequences. $stmt =~ s/$ws_re/ /g; @@ -184,6 +182,27 @@ if (defined $stmt_re) # Convert 2-digit to 4-digit years. $stmt =~ s/(\b\d\d\b)/19$1/g; + # Make the use of intervals consistent. + if (!$ENV{UPDATE_COPYRIGHT_USE_INTERVALS}) + { + $stmt =~ s/(\d{4})-(\d{4})/join(', ', $1..$2)/eg; + } + else + { + $stmt =~ + s/ + (\d{4}) + (?: + (,\ |-) + ((??{ + if ($2 eq '-') { '\d{4}'; } + elsif (!$3) { $1 + 1; } + else { $3 + 1; } + })) + )+ + /$1-$3/gx; + } + # Format within margin. my $stmt_wrapped; my $text_margin = $margin - length($prefix); |