From 48ecb786a96e5e9a547b3f294a29c65a41b9f049 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Wed, 5 Aug 2009 20:51:27 -0400 Subject: [PATCH] update-copyright: support omitted "(C)" * build-aux/update-copyright: Implement and document. Also, allow variable whitespace before "(C)". * tests/test-update-copyright.sh: Test. --- ChangeLog | 7 +++++++ build-aux/update-copyright | 45 +++++++++++++++++++++++++----------------- tests/test-update-copyright.sh | 21 ++++++++++++++++++++ 3 files changed, 55 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 996baca51..602f69d37 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2009-08-05 Joel E. Denny + 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 + update-copyright: don't trip on non-FSF copyright statements * build-aux/update-copyright: Fix so that the first correctly formatted FSF copyright statement is recognized no matter what diff --git a/build-aux/update-copyright b/build-aux/update-copyright index dd0d758ec..b124bb9aa 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-05.20:47'; # UTC +my $VERSION = '2009-08-06.01:08'; # UTC # 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: # -# 1. The format is "Copyright (C)" (where "(C)" can also be "(c)", -# "@copyright{}", or "©"), 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. © +# +# 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{}|©)'; +my $copyright_re = 'Copyright'; +my $circle_c_re = '(?:\([cC]\)|@copyright{}|©)'; 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 = - "$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; } } diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh index 0f5de4b30..69dadbf7a 100755 --- a/tests/test-update-copyright.sh +++ b/tests/test-update-copyright.sh @@ -334,4 +334,25 @@ EOF compare $TMP-exp $TMP || exit 1 rm $TMP* +## --------------- ## +## Omitted "(C)". ## +## --------------- ## + +TMP=$TMP_BASE-omitted-circle-c +cat > $TMP < $TMP-stdout 2> $TMP-stderr +compare /dev/null $TMP-stdout || exit 1 +compare /dev/null $TMP-stderr || exit 1 +compare - $TMP <