On Thu, 13 Aug 2009, Eric Blake wrote: > According to Akim Demaille on 8/13/2009 1:59 AM: > >> - Copyright (C) 89, 90, 91, 1995-2006, 2008-2009 Free Software > >> - Foundation, Inc. > >> + Copyright (C) 89, 90, 91, 1995-2006, 2008-2009 Free Software > >> Foundation, Inc. > > > > While at it, why not standardize everything to 4 digits (I don't think > > we need to address the Y10k issues yet :), and to introduce intervals > > where applicable? Is there some legal thingy that forbids it? It might > > help making some lines smaller. > > Yes - see this post: > http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00184.html > > I'm not personally opposed to compressed years, but if you want the tool > to output compressed years instead of longhand, it should be an option > (and more importantly, we should also fix the tool to allow longhand years > for maintainers that want longhand).
Below are some patches to implement that. >From 75dd6c0c64ee03ebb4eb7b0b14cf8905b9ad65ad Mon Sep 17 00:00:00 2001 From: Joel E. Denny <jde...@clemson.edu> Date: Thu, 13 Aug 2009 22:40:34 -0400 Subject: [PATCH] update-copyright: convert 2-digit to 4-digit years * build-aux/update-copyright: Implement and document. * tests/test-update-copyright.sh: Update. --- ChangeLog | 6 ++++++ build-aux/update-copyright | 13 +++++++++---- tests/test-update-copyright.sh | 36 ++++++++++++++++++------------------ 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6c3670..8ceadbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-08-14 Joel E. Denny <jde...@clemson.edu> + + update-copyright: convert 2-digit to 4-digit years + * build-aux/update-copyright: Implement and document. + * tests/test-update-copyright.sh: Update. + 2009-08-13 Eric Blake <e...@byu.net> test-dup2: fix bad assumption diff --git a/build-aux/update-copyright b/build-aux/update-copyright index 68440f8..fb1c7d2 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-06.01:08'; # UTC +my $VERSION = '2009-08-14.02:23'; # UTC # Copyright (C) 2009 Free Software Foundation, Inc. # @@ -26,9 +26,11 @@ my $VERSION = '2009-08-06.01:08'; # UTC # maintainer-makefile module. # # Iff an FSF copyright statement is discovered in a file and the final -# year is not the current year, the statement is updated for the new -# year and reformatted to fit within 72 columns. A warning is printed -# for every file for which no FSF copyright statement is discovered. +# year is not the current year, then the statement is updated for the +# new year, 2-digit years are converted to 4-digit years by prepending +# "19", and the statement is reformatted to fit within 72 columns. A +# warning is printed for every file for which no FSF copyright statement +# is discovered. # # Each file's FSF copyright statement must be formated correctly in # order to be recognized. For example, each of these is fine: @@ -179,6 +181,9 @@ if (defined $stmt_re) # Put spaces after commas. $stmt =~ s/, ?/, /g; + # Convert 2-digit to 4-digit years. + $stmt =~ s/(\b\d\d\b)/19$1/g; + # Format within margin. my $stmt_wrapped; my $text_margin = $margin - length($prefix); diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh index 9997df4..d0e3083 100755 --- a/tests/test-update-copyright.sh +++ b/tests/test-update-copyright.sh @@ -123,7 +123,7 @@ compare - $TMP.2 <<EOF || exit 1 EOF compare - $TMP.3 <<EOF || exit 1 /* - * Copyright © 90, 2005, 2007-2010 Free Software Foundation, Inc. + * Copyright © 1990, 2005, 2007-2010 Free Software Foundation, Inc. */ EOF compare - $TMP.4 <<EOF || exit 1 @@ -284,9 +284,9 @@ UPDATE_COPYRIGHT_YEAR=2010 \ compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP <<EOF || exit 1 - Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, - 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, + 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009-2010 Free Software Foundation, Inc. EOF rm $TMP* @@ -305,9 +305,9 @@ UPDATE_COPYRIGHT_YEAR=2010 \ compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP <<EOF || exit 1 - # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, - # 1996, 1997, 98, 1999, 2000, 2001, 2002, 2003, 2004, - # 2005, 2006, 2007, 2008, 2009-2010 Free Software + # Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, + # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, + # 2004, 2005, 2006, 2007, 2008, 2009-2010 Free Software # Foundation, Inc. EOF rm $TMP* @@ -327,8 +327,8 @@ UPDATE_COPYRIGHT_YEAR=2010 \ compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 tr @ '\015' > $TMP-exp <<\EOF -Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,@ -Rem 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@ +Rem Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@ +Rem 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@ Rem 2009-2010 Free Software Foundation, Inc.@ EOF compare $TMP-exp $TMP || exit 1 @@ -349,9 +349,9 @@ UPDATE_COPYRIGHT_YEAR=2010 \ compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP <<EOF || exit 1 - Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009-2010 Free - Software Foundation, Inc. + Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009-2010 + Free Software Foundation, Inc. EOF rm $TMP* @@ -371,7 +371,7 @@ cat > $TMP.space <<EOF 2009 Free Software Foundation, Inc. */ EOF cat > $TMP.single-line <<EOF -/* Copyright 87, 88, 1991, 1992 Free Software Foundation, Inc. */ +/* Copyright 87, 1991, 1992 Free Software Foundation, Inc. */ EOF cat > $TMP.single-line-wrapped <<EOF /* Copyright 1988, 1991, 1992, 1993 Free Software Foundation, Inc. */ @@ -389,17 +389,17 @@ UPDATE_COPYRIGHT_YEAR=2010 \ compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP.star <<EOF || exit 1 -/* Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98, - * 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, +/* Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + * 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, * 2009-2010 Free Software Foundation, Inc. */ EOF compare - $TMP.space <<EOF || exit 1 - /*Copyright 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + /*Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009-2010 Free Software Foundation, Inc. */ EOF compare - $TMP.single-line <<EOF || exit 1 -/* Copyright 87, 88, 1991, 1992, 2010 Free Software Foundation, Inc. */ +/* Copyright 1987, 1991, 1992, 2010 Free Software Foundation, Inc. */ EOF compare - $TMP.single-line-wrapped <<EOF || exit 1 /* Copyright 1988, 1991, 1992, 1993, 2010 Free Software Foundation, -- 1.5.4.3 >From 95c6e15a4bf7cffb02d7eed528acff69addd49fe Mon Sep 17 00:00:00 2001 From: Joel E. Denny <jde...@clemson.edu> Date: Fri, 14 Aug 2009 01:10:08 -0400 Subject: [PATCH] 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. --- ChangeLog | 9 ++++ build-aux/update-copyright | 51 +++++++++++++++------- tests/test-update-copyright.sh | 93 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 129 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8ceadbf..9437a90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2009-08-14 Joel E. Denny <jde...@clemson.edu> + 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. + +2009-08-14 Joel E. Denny <jde...@clemson.edu> + update-copyright: convert 2-digit to 4-digit years * build-aux/update-copyright: Implement and document. * tests/test-update-copyright.sh: Update. diff --git a/build-aux/update-copyright b/build-aux/update-copyright index fb1c7d2..d8445fe 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); diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh index d0e3083..ac47b9b 100755 --- a/tests/test-update-copyright.sh +++ b/tests/test-update-copyright.sh @@ -107,7 +107,7 @@ Copyright (C) 1990-2005, 2007-2009 Acme, Inc. # Foundation, Inc. EOF -UPDATE_COPYRIGHT_YEAR=2010 \ +UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 compare - $TMP-stderr <<EOF || exit 1 @@ -145,6 +145,52 @@ Copyright (C) 1990-2005, 2007-2009 Acme, Inc. # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc. EOF +UPDATE_COPYRIGHT_YEAR=2011 \ + update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare - $TMP-stderr <<EOF || exit 1 +$TMP.4: warning: FSF copyright statement not found +$TMP.5: warning: FSF copyright statement not found +EOF +compare - $TMP.1 <<EOF || exit 1 +Copyright @copyright{} 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, +1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, +2011 Free Software Foundation, Inc. +EOF +compare - $TMP.2 <<EOF || exit 1 +# Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, +# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 +# Free Software Foundation, Inc. +EOF +compare - $TMP.3 <<EOF || exit 1 +/* + * Copyright © 1990, 2005, 2007, 2008, 2009, 2010, 2011 Free + * Software Foundation, Inc. + */ +EOF +compare - $TMP.4 <<EOF || exit 1 +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +EOF +compare - $TMP.5 <<EOF || exit 1 +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. +EOF +compare - $TMP.6 <<EOF || exit 1 +## Copyright (C) 1990-2005, 2007-2009 Free Software +# Foundation, Inc. + +Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, +1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 +Free Software Foundation, Inc. +EOF +compare - $TMP.7 <<EOF || exit 1 +Copyright (C) 1990-2005, 2007-2009 Acme, Inc. + +# Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, +# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 +# Free Software Foundation, Inc. +EOF + rm $TMP* ## -------------- ## @@ -164,6 +210,13 @@ compare /dev/null $TMP-stderr || exit 1 compare - $TMP <<EOF || exit 1 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc. EOF +UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 +'\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc. +EOF rm $TMP* ## ------------------ ## @@ -209,6 +262,14 @@ compare - $TMP <<EOF || exit 1 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc. EOF +UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 +#### Copyright (C) 1976-1988, 1999-2008, 2010-2011 Free Software +#### Foundation, Inc. +EOF rm $TMP* ## ------------------- ## @@ -286,7 +347,15 @@ compare /dev/null $TMP-stderr || exit 1 compare - $TMP <<EOF || exit 1 Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009-2010 Free Software Foundation, Inc. + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + Copyright (C) 1987-1988, 1991-2011 Free Software Foundation, + Inc. EOF rm $TMP* @@ -296,7 +365,7 @@ rm $TMP* TMP=$TMP_BASE-unusual-ws cat > $TMP <<EOF - # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + # Copyright (C) 87-88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, # 98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, # 2009 Free Software Foundation, Inc. EOF @@ -307,7 +376,15 @@ compare /dev/null $TMP-stderr || exit 1 compare - $TMP <<EOF || exit 1 # Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - # 2004, 2005, 2006, 2007, 2008, 2009-2010 Free Software + # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software + # Foundation, Inc. +EOF +UPDATE_COPYRIGHT_YEAR=2011 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <<EOF || exit 1 + # Copyright (C) 1987-1988, 1991-2011 Free Software # Foundation, Inc. EOF rm $TMP* @@ -329,7 +406,7 @@ compare /dev/null $TMP-stderr || exit 1 tr @ '\015' > $TMP-exp <<\EOF Rem Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997,@ Rem 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@ -Rem 2009-2010 Free Software Foundation, Inc.@ +Rem 2009, 2010 Free Software Foundation, Inc.@ EOF compare $TMP-exp $TMP || exit 1 rm $TMP* @@ -350,7 +427,7 @@ compare /dev/null $TMP-stdout || exit 1 compare /dev/null $TMP-stderr || exit 1 compare - $TMP <<EOF || exit 1 Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009-2010 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. EOF rm $TMP* @@ -391,12 +468,12 @@ compare /dev/null $TMP-stderr || exit 1 compare - $TMP.star <<EOF || exit 1 /* Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, * 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - * 2009-2010 Free Software Foundation, Inc. */ + * 2009, 2010 Free Software Foundation, Inc. */ EOF compare - $TMP.space <<EOF || exit 1 /*Copyright 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009-2010 Free Software Foundation, Inc. */ + 2009, 2010 Free Software Foundation, Inc. */ EOF compare - $TMP.single-line <<EOF || exit 1 /* Copyright 1987, 1991, 1992, 2010 Free Software Foundation, Inc. */ -- 1.5.4.3