bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copyright years: mass-update every January 1


From: Joel E. Denny
Subject: Re: copyright years: mass-update every January 1
Date: Wed, 29 Jul 2009 10:38:28 -0400 (EDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Wed, 29 Jul 2009, Jim Meyering wrote:

> > You're still missing copyrights containing newline followed by a comment
> > sequence.  For example, m4/lib-check.m4.
> 
> You're right.  Thanks.
> This new version catches those, too.
> It doesn't allow trailing blanks between the final number
> and "\n#", but that's not a possibility here.

> @@ -27,7 +27,7 @@ my ($sec, $min, $hour, $mday, $month, $year) = localtime 
> (time());
>  my $this_year = $year + 1900;
>  my $holder = 'Free Software Foundation';
> 
> -if (/([- ])((?:\d\d)?\d\d)(\s+$holder)/s)
> +if (/([- ])((?:\d\d)?\d\d)((?:\n\#)?\s+$holder)/s)
>    {
>      my ($sep, $last_c_year, $rest) = ($1, $2, $3);

This isn't general enough: (1) # is not the only comment style, and (2) 
newlines plus comments could occur within $holder.  The following patch 
against coreutils implements a more general approach and fixes one 
coreutils file from case #1.  I haven't tested it very well yet, so I've 
added a diagnostic to help us catch files it can't parse.

Now that the comment style is extracted, it should be possible to extend 
this further to automatically format the added text.  I might work on that 
some other time.

>From ed7de5b95ddc6888592dbe8f38f77b2a6fd83bc9 Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Wed, 29 Jul 2009 09:59:34 -0400
Subject: [PATCH] maint: generalize update-copyright's comment handling some

* build-aux/update-copyright: Handle copyright statements within some
comment styles, and document limitations.
Report any file with an external copyright holder or parse failure.
* m4/check-decl.m4: Update copyright.

diff --git a/build-aux/update-copyright b/build-aux/update-copyright
index 1ceaf8a..aedad96 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-07-29.13:34'; # UTC
+my $VERSION = '2009-07-29.08:43'; # UTC
 
 # Copyright (C) 2009 Free Software Foundation
 #
@@ -27,7 +27,40 @@ my ($sec, $min, $hour, $mday, $month, $year) = localtime 
(time());
 my $this_year = $year + 1900;
 my $holder = 'Free Software Foundation';
 
-if (/([- ])((?:\d\d)?\d\d)((?:\n\#)?\s+$holder)/s)
+# In the copyright statement, "Copyright (C)" must appear at the
+# beginning of the line except for any comment sequence of no more than
+# 5 characters.  Iff that comment sequence is present, the same comment
+# sequence should appear at the beginning of every line within the
+# copyright statement so that it can be parsed and wrapped correctly.
+#
+# For example, these are fine:
+#
+#   # Copyright (C) 1990-2005, 2007-2009 Free Software
+#   # Foundation, Inc.
+#
+#   /*
+#    * Copyright (C) 1990-2005, 2007-2009 Free Software
+#    * Foundation, Inc.
+#    */
+#
+# This will not be parsed correctly:
+#
+#   /* Copyright (C) 1990-2005, 2007-2009 Free Software
+#    * Foundation, Inc.  */
+#
+# A warning is printed for any file for which the last copyright year
+# cannot be discovered.  The culprit may be simply that the copyright
+# holder is not the expected one, or it may be that the above
+# preconditions are not obeyed.
+
+my $comment = "";
+if (/(?:^|\n)(.{0,5})Copyright \([cC]\)/) {
+  $comment = quotemeta($1);
+}
+$holder = " $holder";
+$holder =~ s/\s/\\s*(?:\\s|\\n$comment)\\s*/g;
+
+if (/([- ])((?:\d\d)?\d\d)($holder)/s)
   {
     my ($sep, $last_c_year, $rest) = ($1, $2, $3);
 
@@ -51,6 +84,11 @@ if (/([- ])((?:\d\d)?\d\d)((?:\n\#)?\s+$holder)/s)
           }
       }
   }
+else
+  {
+    print STDERR
+      "$ARGV: warning: external copyright holder or parse failure\n";
+  }
 
 # Local variables:
 # indent-tabs-mode: nil
diff --git a/m4/check-decl.m4 b/m4/check-decl.m4
index e2d20f3..028b855 100644
--- a/m4/check-decl.m4
+++ b/m4/check-decl.m4
@@ -1,7 +1,7 @@
 #serial 24
 # Check declarations for this package.
 
-dnl Copyright (C) 1997-2001, 2003-2006, 2008
+dnl Copyright (C) 1997-2001, 2003-2006, 2008-2009
 dnl Free Software Foundation, Inc.
 
 dnl This file is free software; the Free Software Foundation
-- 
1.5.4.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]