update-copyright: convert 2-digit to 4-digit years
authorJoel E. Denny <jdenny@clemson.edu>
Fri, 14 Aug 2009 02:40:34 +0000 (22:40 -0400)
committerJim Meyering <meyering@redhat.com>
Fri, 14 Aug 2009 06:53:23 +0000 (08:53 +0200)
* build-aux/update-copyright: Implement and document.
* tests/test-update-copyright.sh: Update.

ChangeLog
build-aux/update-copyright
tests/test-update-copyright.sh

index ab455e1..9d5187a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-14  Joel E. Denny  <jdenny@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-14  Jim Meyering  <meyering@redhat.com>
 
        test-exclude: avoid coreutils "make check" failure
index 68440f8..fb1c7d2 100755 (executable)
@@ -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);
index 9997df4..d0e3083 100755 (executable)
@@ -123,7 +123,7 @@ compare - $TMP.2 <<EOF || exit 1
 EOF
 compare - $TMP.3 <<EOF || exit 1
 /*
- * Copyright &copy; 90, 2005, 2007-2010 Free Software Foundation, Inc.
+ * Copyright &copy; 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,