changeset 11784:72e645655421

update-copyright: support omitted "(C)" * build-aux/update-copyright: Implement and document. Also, allow variable whitespace before "(C)". * tests/test-update-copyright.sh: Test.
author Joel E. Denny <jdenny@clemson.edu>
date Wed, 05 Aug 2009 20:51:27 -0400
parents f70f84ee690a
children 4b93f30470cf
files ChangeLog build-aux/update-copyright tests/test-update-copyright.sh
diffstat 3 files changed, 55 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-05  Joel E. Denny  <jdenny@clemson.edu>
+
+	update-copyright: support omitted "(C)"
+	* build-aux/update-copyright: Implement and document.  Also,
+	allow variable whitespace before "(C)".
+	* tests/test-update-copyright.sh: Test.
+
 2009-08-05  Joel E. Denny  <jdenny@clemson.edu>
 
 	update-copyright: don't trip on non-FSF copyright statements
--- 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-05.20:47'; # UTC
+my $VERSION = '2009-08-06.01:08'; # UTC
 
 # Copyright (C) 2009 Free Software Foundation, Inc.
 #
@@ -72,28 +72,36 @@
 # The exact conditions that a file's FSF copyright statement must meet
 # to be recognized are:
 #
-#   1. The format is "Copyright (C)" (where "(C)" can also be "(c)",
-#      "@copyright{}", or "&copy;"), then a list of copyright years, and
-#      then the name of the copyright holder, which is "Free Software
-#      Foundation, Inc.".
-#   2. The "Copyright (C)" appears at the beginning of a line except
-#      that it may be prefixed by any sequence (e.g., a comment) of no
-#      more than 5 characters.
-#   3. Iff such a prefix is present, the same prefix appears at the
+#   1. It is the first FSF copyright statement that meets all of the
+#      following conditions.  Subsequent FSF copyright statements are
+#      ignored.
+#   2. Its format is "Copyright (C)", then a list of copyright years,
+#      and then the name of the copyright holder, which is "Free
+#      Software Foundation, Inc.".
+#   3. The "(C)" takes one of the following forms or is omitted
+#      entirely:
+#
+#        A. (C)
+#        B. (c)
+#        C. @copyright{}
+#        D. &copy;
+#
+#   4. The "Copyright" appears at the beginning of a line except that it
+#      may be prefixed by any sequence (e.g., a comment) of no more than
+#      5 characters.
+#   5. Iff such a prefix is present, the same prefix appears at the
 #      beginning of each remaining line within the FSF copyright
 #      statement.
-#   4. Blank lines, even if preceded by the prefix, do not appear
+#   6. Blank lines, even if preceded by the prefix, do not appear
 #      within the FSF copyright statement.
-#   5. Each copyright year is 2 or 4 digits, and years are separated by
+#   7. Each copyright year is 2 or 4 digits, and years are separated by
 #      commas or dashes.  Whitespace may occur after commas.
-#   6. It is the first FSF copyright statement that meets all of the
-#      above conditions.  Subsequent FSF copyright statements are
-#      ignored.
 
 use strict;
 use warnings;
 
-my $copyright_re = 'Copyright (?:\([cC]\)|@copyright{}|&copy;)';
+my $copyright_re = 'Copyright';
+my $circle_c_re = '(?:\([cC]\)|@copyright{}|&copy;)';
 my $holder = 'Free Software Foundation, Inc.';
 my $prefix_max = 5;
 my $margin = 72;
@@ -123,13 +131,14 @@
     my $holder_re = $holder;
     $holder_re =~ s/\s/$ws_re/g;
     my $stmt_remainder_re =
-      "$ws_re(?:(?:\\d\\d)?\\d\\d(,$ws_re?|-))*"
+      "(?:$ws_re$circle_c_re)?"
+      . "$ws_re(?:(?:\\d\\d)?\\d\\d(,$ws_re?|-))*"
       . "((?:\\d\\d)?\\d\\d)$ws_re$holder_re";
     if (/\G$stmt_remainder_re/)
       {
         $stmt_re =
-           quotemeta("$leading$prefix")
-           . "($copyright_re$stmt_remainder_re)";
+          quotemeta("$leading$prefix")
+          . "($copyright_re$stmt_remainder_re)";
         last;
       }
   }
--- a/tests/test-update-copyright.sh
+++ b/tests/test-update-copyright.sh
@@ -334,4 +334,25 @@
 compare $TMP-exp $TMP || exit 1
 rm $TMP*
 
+## --------------- ##
+## Omitted "(C)".  ##
+## --------------- ##
+
+TMP=$TMP_BASE-omitted-circle-c
+cat > $TMP <<EOF
+  Copyright 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
+UPDATE_COPYRIGHT_YEAR=2010 \
+  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 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.
+EOF
+rm $TMP*
+
 exit 0