update-copyright: support omitted "(C)"
authorJoel E. Denny <jdenny@clemson.edu>
Thu, 6 Aug 2009 00:51:27 +0000 (20:51 -0400)
committerJim Meyering <meyering@redhat.com>
Thu, 6 Aug 2009 05:32:25 +0000 (07:32 +0200)
* build-aux/update-copyright: Implement and document.  Also,
allow variable whitespace before "(C)".
* tests/test-update-copyright.sh: Test.

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

index 996baca516bf579dbd5e3e432e9f54d8c52a88d1..602f69d37b93b4f4ba830fbcea89facc37ede7ad 100644 (file)
--- 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
 2009-08-05  Joel E. Denny  <jdenny@clemson.edu>
 
        update-copyright: don't trip on non-FSF copyright statements
index dd0d758ec0b32306ca970d1ffab68f1a30de8db9..b124bb9aa7bbe02e929178db0ede669d4a32d499 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -0777 -pi
 # Update an FSF copyright year list to include the current year.
 
 #!/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.
 #
 
 # Copyright (C) 2009 Free Software Foundation, Inc.
 #
@@ -72,28 +72,36 @@ my $VERSION = '2009-08-05.20:47'; # UTC
 # The exact conditions that a file's FSF copyright statement must meet
 # to be recognized are:
 #
 # 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.
 #      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.
 #      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.
 #      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;
 
 
 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;
 my $holder = 'Free Software Foundation, Inc.';
 my $prefix_max = 5;
 my $margin = 72;
@@ -123,13 +131,14 @@ while (/(^|\n)(.{0,$prefix_max})$copyright_re/g)
     my $holder_re = $holder;
     $holder_re =~ s/\s/$ws_re/g;
     my $stmt_remainder_re =
     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 =
       . "((?:\\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;
       }
   }
         last;
       }
   }
index 0f5de4b302d9ac7fde62935207aace66941a7fc0..69dadbf7a8c007767b6d6bdf7865912742b933e1 100755 (executable)
@@ -334,4 +334,25 @@ EOF
 compare $TMP-exp $TMP || exit 1
 rm $TMP*
 
 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
 exit 0