From 9ebada6af6d3c3c4195e6b56b3d65dcf20568fba Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 24 Dec 2013 10:27:53 -0800 Subject: [PATCH] Automate the procedure for updating copyright year. * admin/merge-gnulib (GNULIB_MODULES): Add update-copyright. * admin/notes/years: Mention admin/update-copyright. * admin/update-copyright: New file. * build-aux/update-copyright: New file. * make-dist: Distribute it. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * msdos/autogen/Makefile.in: Update copyright year. --- ChangeLog | 8 ++ admin/ChangeLog | 7 + admin/merge-gnulib | 3 +- admin/notes/years | 6 +- admin/update-copyright | 75 ++++++++++ build-aux/update-copyright | 274 +++++++++++++++++++++++++++++++++++++ lib/gnulib.mk | 9 +- m4/gnulib-comp.m4 | 2 + make-dist | 3 +- msdos/autogen/Makefile.in | 4 +- 10 files changed, 383 insertions(+), 8 deletions(-) create mode 100755 admin/update-copyright create mode 100755 build-aux/update-copyright diff --git a/ChangeLog b/ChangeLog index 417172e5852..3630d570b28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-12-24 Paul Eggert + + Automate the procedure for updating copyright year. + * build-aux/update-copyright: New file. + * make-dist: Distribute it. + * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. + * msdos/autogen/Makefile.in: Update copyright year. + 2013-12-23 Andreas Schwab * configure.ac: Replace obsolete macro AC_CONFIG_HEADER by diff --git a/admin/ChangeLog b/admin/ChangeLog index 40d1e069f03..ea47a6798b5 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog @@ -1,3 +1,10 @@ +2013-12-24 Paul Eggert + + Automate the procedure for updating copyright year. + * merge-gnulib (GNULIB_MODULES): Add update-copyright. + * notes/years: Mention admin/update-copyright. + * update-copyright: New file. + 2013-12-24 Xue Fuqiao * admin.el (add-release-logs): diff --git a/admin/merge-gnulib b/admin/merge-gnulib index af9300edbec..a86630f9e17 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -37,7 +37,8 @@ GNULIB_MODULES=' pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat - sys_time time timer-time timespec-add timespec-sub unsetenv utimens + sys_time time timer-time timespec-add timespec-sub + unsetenv update-copyright utimens warnings ' diff --git a/admin/notes/years b/admin/notes/years index e6b38c5aefd..57cb5ad7e4f 100644 --- a/admin/notes/years +++ b/admin/notes/years @@ -2,6 +2,8 @@ HOW TO MAINTAIN COPYRIGHT YEARS FOR GNU EMACS Maintaining copyright years is now very simple: every time a new year rolls around, add that year to every FSF (and AIST) copyright notice. +Do this by running the 'admin/update-copyright' script on a fresh bzr +checkout. Inspect the results for plausiblity, then commit them. There's no need to worry about whether an individual file has changed in a given year - it's sufficient that Emacs as a whole has changed. @@ -28,10 +30,10 @@ but should keep the full list in a comment in the source. since Emacs 21 came out in 2001, all the subsequent years[1]. We don't need to check whether *that file* was changed in those years. It's sufficient that *Emacs* was changed in those years (and it was!). - + For those files that have been added since then, we should add the year it was added to Emacs, and all subsequent years." - + --RMS, 2005-07-13 [1] Note that this includes 2001 - see diff --git a/admin/update-copyright b/admin/update-copyright new file mode 100755 index 00000000000..64653d97237 --- /dev/null +++ b/admin/update-copyright @@ -0,0 +1,75 @@ +#! /bin/sh +# Update the copyright dates in Emacs sources. +# Typical usage: +# +# admin/update-copyright +# +# By default, this script uses the local-time calendar year. +# Set the UPDATE_COPYRIGHT_YEAR environment variable to override the default. + +# Copyright 2013 Free Software Foundation, Inc. + +# This file is part of GNU Emacs. + +# GNU Emacs 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 of the License, or +# (at your option) any later version. + +# GNU Emacs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs. If not, see . + +# written by Paul Eggert + +# FIXME: The file 'notes/copyright' says that the AIST copyright years +# should be updated, but by inspection it appears that some should be +# updated and some should not be, due to registration numbers, so +# this script leaves these copyright years alone for now. + +: ${UPDATE_COPYRIGHT_USE_INTERVALS=1} +export UPDATE_COPYRIGHT_USE_INTERVALS + +: ${UPDATE_COPYRIGHT_YEAR=$(date +%Y)} +export UPDATE_COPYRIGHT_YEAR + +emacsver=etc/refcards/emacsver.tex +sed 's/\\def\\year[{][0-9]*[}]/\\def\\year{'"$UPDATE_COPYRIGHT_YEAR"'}'/g \ + $emacsver >$emacsver.aux && +{ cmp -s $emacsver $emacsver.aux || + cp $emacsver.aux $emacsver +} && +rm $emacsver.aux && + +bzr_files=$(bzr ls -RV --kind file) && + +# Do not update the copyright of files that have one or more of the +# following problems: +# . They are license files, maintained by the FSF, with their own dates. +# . Their format cannot withstand changing the contents of copyright strings. + +updatable_files=$(find $bzr_files \ + ! -name COPYING \ + ! -name doclicense.texi \ + ! -name gpl.texi \ + ! -name '*-gzipped' \ + ! -name '*.ico' \ + ! -name '*.icns' \ + ! -name '*.pbm' \ + ! -name '*.pdf' \ + ! -name '*.png' \ + ! -name '*.sig' \ + ! -name '*.tar' \ + ! -name '*.tiff' \ + ! -name '*.xpm' \ + ! -name eterm-color \ + ! -name hand.cur \ + ! -name key.pub \ + ! -name key.sec \ + -print) && + +build-aux/update-copyright $updatable_files diff --git a/build-aux/update-copyright b/build-aux/update-copyright new file mode 100755 index 00000000000..c72d0e67da7 --- /dev/null +++ b/build-aux/update-copyright @@ -0,0 +1,274 @@ +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 = '2013-01-03.09:41'; # UTC + +# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# +# 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. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Written by Jim Meyering and Joel E. Denny + +# The arguments to this script should be names of files that contain +# copyright statements to be updated. The copyright holder's name +# defaults to "Free Software Foundation, Inc." but may be changed to +# any other name by using the "UPDATE_COPYRIGHT_HOLDER" environment +# variable. +# +# For example, you might wish to use the update-copyright target rule +# in maint.mk from gnulib's maintainer-makefile module. +# +# Iff a 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 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 copyright +# statement is recognized. +# +# Each file's copyright statement must be formatted correctly in +# order to be recognized. For example, each of these is fine: +# +# Copyright @copyright{} 1990-2005, 2007-2009 Free Software +# Foundation, Inc. +# +# # Copyright (C) 1990-2005, 2007-2009 Free Software +# # Foundation, Inc. +# +# /* +# * Copyright © 90,2005,2007-2009 +# * Free Software Foundation, Inc. +# */ +# +# However, the following format is not recognized because the line +# prefix changes after the first line: +# +# ## Copyright (C) 1990-2005, 2007-2009 Free Software +# # Foundation, Inc. +# +# However, any correctly formatted copyright statement following +# a non-matching copyright statements would be recognized. +# +# The exact conditions that a file's copyright statement must meet +# to be recognized are: +# +# 1. It is the first copyright statement that meets all of the +# following conditions. Subsequent copyright statements are +# ignored. +# 2. Its format is "Copyright (C)", then a list of copyright years, +# and then the name of the copyright holder. +# 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 -- including white space. +# 5. Iff such a prefix is present, the same prefix appears at the +# beginning of each remaining line within the FSF copyright +# statement. There is one exception in order to support C-style +# comments: if the first line's prefix contains nothing but +# whitespace surrounding a "/*", then the prefix for all subsequent +# lines is the same as the first line's prefix except with each of +# "/" and possibly "*" replaced by a " ". The replacement of "*" +# by " " is consistent throughout all subsequent lines. +# 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 appear after commas. +# +# Environment variables: +# +# 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. +# If UPDATE_COPYRIGHT_USE_INTERVALS=2, convert a sequence with gaps +# to the minimal containing range. For example, convert +# 2000, 2004-2007, 2009 to 2000-2009. +# 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. +# 5. Set UPDATE_COPYRIGHT_HOLDER if the copyright holder is other +# than "Free Software Foundation, Inc.". + +use strict; +use warnings; + +my $copyright_re = 'Copyright'; +my $circle_c_re = '(?:\([cC]\)|@copyright{}|©)'; +my $holder = $ENV{UPDATE_COPYRIGHT_HOLDER}; +$holder ||= 'Free Software Foundation, Inc.'; +my $prefix_max = 5; +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}; +if (!$this_year || $this_year !~ m/^\d{4}$/) + { + my ($sec, $min, $hour, $mday, $month, $year) = localtime (time ()); + $this_year = $year + 1900; + } + +# Unless the file consistently uses "\r\n" as the EOL, use "\n" instead. +my $eol = /(?:^|[^\r])\n/ ? "\n" : "\r\n"; + +my $leading; +my $prefix; +my $ws_re; +my $stmt_re; +while (/(^|\n)(.{0,$prefix_max})$copyright_re/g) + { + $leading = "$1$2"; + $prefix = $2; + if ($prefix =~ /^(\s*\/)\*(\s*)$/) + { + $prefix =~ s,/, ,; + my $prefix_ws = $prefix; + $prefix_ws =~ s/\*/ /; # Only whitespace. + if (/\G(?:[^*\n]|\*[^\/\n])*\*?\n$prefix_ws/) + { + $prefix = $prefix_ws; + } + } + $ws_re = '[ \t\r\f]'; # \s without \n + $ws_re = + "(?:$ws_re*(?:$ws_re|\\n" . quotemeta($prefix) . ")$ws_re*)"; + my $holder_re = $holder; + $holder_re =~ s/\s/$ws_re/g; + my $stmt_remainder_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) . "($copyright_re$stmt_remainder_re)"; + last; + } + } +if (defined $stmt_re) + { + /$stmt_re/ or die; # Should never die. + my $stmt = $1; + my $final_year_orig = $2; + + # Handle two-digit year numbers like "98" and "99". + my $final_year = $final_year_orig; + $final_year <= 99 + and $final_year += 1900; + + if ($final_year != $this_year) + { + # Update the year. + $stmt =~ s/\b$final_year_orig\b/$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; + + # Put spaces after commas. + $stmt =~ s/, ?/, /g; + + # Convert 2-digit to 4-digit years. + $stmt =~ s/(\b\d\d\b)/19$1/g; + + # Make the use of intervals consistent. + if (!$ENV{UPDATE_COPYRIGHT_USE_INTERVALS}) + { + $stmt =~ s/(\d{4})-(\d{4})/join(', ', $1..$2)/eg; + } + else + { + $stmt =~ + s/ + (\d{4}) + (?: + (,\ |-) + ((??{ + if ($2 eq '-') { '\d{4}'; } + elsif (!$3) { $1 + 1; } + else { $3 + 1; } + })) + )+ + /$1-$3/gx; + + # When it's 2, emit a single range encompassing all year numbers. + $ENV{UPDATE_COPYRIGHT_USE_INTERVALS} == 2 + and $stmt =~ s/\b(\d{4})\b.*\b(\d{4})\b/$1-$2/; + } + + # Format within margin. + my $stmt_wrapped; + my $text_margin = $margin - length($prefix); + if ($prefix =~ /^(\t+)/) + { + $text_margin -= length($1) * ($tab_width - 1); + } + while (length $stmt) + { + if (($stmt =~ s/^(.{1,$text_margin})(?: |$)//) + || ($stmt =~ s/^([\S]+)(?: |$)//)) + { + my $line = $1; + $stmt_wrapped .= $stmt_wrapped ? "$eol$prefix" : $leading; + $stmt_wrapped .= $line; + } + else + { + # Should be unreachable, but we don't want an infinite + # loop if it can be reached. + die; + } + } + + # Replace the old copyright statement. + s/$stmt_re/$stmt_wrapped/; + } + } +else + { + print STDERR "$ARGV: warning: copyright statement not found\n"; + } + +# Local variables: +# mode: perl +# indent-tabs-mode: nil +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "my $VERSION = '" +# time-stamp-format: "%:y-%02m-%02d.%02H:%02M" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "'; # UTC" +# End: diff --git a/lib/gnulib.mk b/lib/gnulib.mk index 16a4ed8700a..9748ce115dc 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv update-copyright utimens warnings MOSTLYCLEANFILES += core *.stackdump @@ -1802,6 +1802,13 @@ EXTRA_libgnu_a_SOURCES += unsetenv.c ## end gnulib module unsetenv +## begin gnulib module update-copyright + + +EXTRA_DIST += $(top_srcdir)/build-aux/update-copyright + +## end gnulib module update-copyright + ## begin gnulib module utimens libgnu_a_SOURCES += utimens.c diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 3a04c84ac90..cdb671c3d14 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -150,6 +150,7 @@ AC_DEFUN([gl_EARLY], # Code from module u64: # Code from module unistd: # Code from module unsetenv: + # Code from module update-copyright: # Code from module utimens: # Code from module verify: # Code from module warnings: @@ -791,6 +792,7 @@ AC_DEFUN([gl_FILE_LIST], [ build-aux/snippet/arg-nonnull.h build-aux/snippet/c++defs.h build-aux/snippet/warn-on-use.h + build-aux/update-copyright lib/acl-errno-valid.c lib/acl-internal.h lib/acl.h diff --git a/make-dist b/make-dist index 17f54419606..03e9763089c 100755 --- a/make-dist +++ b/make-dist @@ -344,7 +344,8 @@ echo "Making links to \`leim' and its subdirectories" echo "Making links to \`build-aux'" (cd build-aux ln compile config.guess config.sub depcomp msys-to-w32 ../${tempdir}/build-aux - ln install-sh missing move-if-change update-subdirs ../${tempdir}/build-aux + ln install-sh missing move-if-change ../${tempdir}/build-aux + ln update-copyright update-subdirs ../${tempdir}/build-aux ln dir_top make-info-dir ../${tempdir}/build-aux) echo "Making links to \`build-aux/snippet'" diff --git a/msdos/autogen/Makefile.in b/msdos/autogen/Makefile.in index 11bcb600f7e..99adcab17ed 100644 --- a/msdos/autogen/Makefile.in +++ b/msdos/autogen/Makefile.in @@ -1,9 +1,7 @@ # Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1994-2009, 2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -- 2.39.2