posix-modules: Ignore backup files of documentation files.
[gnulib.git] / build-aux / update-copyright
index d8445fe..28ff441 100755 (executable)
@@ -1,11 +1,13 @@
-#!/usr/bin/perl -0777 -pi
+eval '(exit $?0)' && eval 'exec perl -wS -0777 -pi "$0" ${1+"$@"}'
+  & eval 'exec perl -wS -0777 -pi "$0" $argv:q'
+    if 0;
 # Update an FSF copyright year list to include the current year.
 
-my $VERSION = '2009-08-14.05:03'; # UTC
+my $VERSION = '2009-12-28.11:09'; # UTC
 
-# Copyright (C) 2009 Free Software Foundation, Inc.
+# Copyright (C) 2009-2010 Free Software Foundation, Inc.
 #
-# This program is free software; you can redistribute it and/or modify
+# This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3, or (at your option)
 # any later version.
@@ -25,12 +27,17 @@ my $VERSION = '2009-08-14.05:03'; # UTC
 # use the update-copyright target rule in maint.mk from gnulib's
 # maintainer-makefile module.
 #
-# Iff an FSF copyright statement is discovered in a file and the final
+# Iff an FSF copyright statement is recognized in a file and the final
 # 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.
+# new year and it is reformatted to:
+#
+#   1. Fit within 72 columns.
+#   2. Convert 2-digit years to 4-digit years by prepending "19".
+#   3. Expand copyright year intervals.  (See "Environment variables"
+#      below.)
+#
+# A warning is printed for every file for which no FSF copyright
+# statement is recognized.
 #
 # Each file's FSF copyright statement must be formated correctly in
 # order to be recognized.  For example, each of these is fine:
@@ -91,17 +98,24 @@ my $VERSION = '2009-08-14.05:03'; # UTC
 #   6. Blank lines, even if preceded by the prefix, do not appear
 #      within the FSF copyright statement.
 #   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 appear after commas.
 #
 # Environment variables:
 #
-#   1. If UPDATE_COPYRIGHT_USE_INTERVALS=1, every series of consecutive
-#      copyright years (such as 90, 1991, 1992-2007, 2008) in an updated
-#      FSF copyright statement is collapsed to a single interval (such
-#      as 1990-2008).  If unset or set to 0, all existing copyright year
-#      intervals are expanded.
-#   2. For testing purposes, you can set the assumed current year in
+#   1. If UPDATE_COPYRIGHT_FORCE=1, a recognized FSF copyright statement
+#      is reformatted even if it does not need updating for the new
+#      year.  If unset or set to 0, only updated FSF copyright
+#      statements are reformatted.
+#   2. If UPDATE_COPYRIGHT_USE_INTERVALS=1, every series of consecutive
+#      copyright years (such as 90, 1991, 1992-2007, 2008) in a
+#      reformatted FSF copyright statement is collapsed to a single
+#      interval (such as 1990-2008).  If unset or set to 0, all existing
+#      copyright year intervals in a reformatted FSF copyright statement
+#      are expanded instead.
+#   3. For testing purposes, you can set the assumed current year in
 #      UPDATE_COPYRIGHT_YEAR.
+#   4. The default maximum line length for a copyright line is 72.
+#      Set UPDATE_COPYRIGHT_MAX_LINE_LENGTH to use a different length.
 
 use strict;
 use warnings;
@@ -110,7 +124,10 @@ my $copyright_re = 'Copyright';
 my $circle_c_re = '(?:\([cC]\)|@copyright{}|©)';
 my $holder = 'Free Software Foundation, Inc.';
 my $prefix_max = 5;
-my $margin = 72;
+my $margin = $ENV{UPDATE_COPYRIGHT_MAX_LINE_LENGTH};
+!$margin || $margin !~ m/^\d+$/
+  and $margin = 72;
+
 my $tab_width = 8;
 
 my $this_year = $ENV{UPDATE_COPYRIGHT_YEAR};
@@ -172,7 +189,9 @@ if (defined $stmt_re)
       {
         # Update the year.
         $stmt =~ s/$final_year_orig/$final_year, $this_year/;
-
+      }
+    if ($final_year != $this_year || $ENV{'UPDATE_COPYRIGHT_FORCE'})
+      {
         # Normalize all whitespace including newline-prefix sequences.
         $stmt =~ s/$ws_re/ /g;
 
@@ -237,6 +256,7 @@ else
   }
 
 # Local variables:
+# mode: perl
 # indent-tabs-mode: nil
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "my $VERSION = '"