# HG changeset patch # User Jim Meyering # Date 1357205010 -3600 # Node ID aa1920a5636c2882db6fb20fbb32708c3968b2ee # Parent 28b073aabf32cf0e23f8b37959de20c084aa9ab8 update-copyright: avoid copyright notice date corruption Given a sequence of copyright year numbers in which the final one was a two-digit number that happened to be a substring of a preceding four-digit year number, we would mistakenly update the substring (from two- to four-digit) rather than the two-digit number at the end, which, combined with the addition of the current 4-digit year number would yield two 5-digit year numbers, e.g., here, it would convert the first "99" to "1999, 2013" rather than the final one: 1991, 99 11999, 20131, 1999 * build-aux/update-copyright: Tighten a regexp. * tests/test-update-copyright.sh: Add a test case to trigger the bug. Reported by Joseph Myers in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/32281 diff -r 28b073aabf32 -r aa1920a5636c ChangeLog --- a/ChangeLog Tue Jan 01 16:27:46 2013 -0800 +++ b/ChangeLog Thu Jan 03 10:23:30 2013 +0100 @@ -1,3 +1,21 @@ +2013-01-03 Jim Meyering + + update-copyright: avoid copyright notice date corruption + Given a sequence of copyright year numbers in which the final + one was a two-digit number that happened to be a substring of + a preceding four-digit year number, we would mistakenly update + the substring (from two- to four-digit) rather than the two-digit + number at the end, which, combined with the addition of the current + 4-digit year number would yield two 5-digit year numbers, e.g., + here, it would convert the first "99" to "1999, 2013" rather than + the final one: + 1991, 99 + 11999, 20131, 1999 + * build-aux/update-copyright: Tighten a regexp. + * tests/test-update-copyright.sh: Add a test case to trigger the bug. + Reported by Joseph Myers in + http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/32281 + 2013-01-01 Paul Eggert regex: omit needless signed-pointer casts diff -r 28b073aabf32 -r aa1920a5636c build-aux/update-copyright --- a/build-aux/update-copyright Tue Jan 01 16:27:46 2013 -0800 +++ b/build-aux/update-copyright Thu Jan 03 10:23:30 2013 +0100 @@ -3,7 +3,7 @@ if 0; # Update an FSF copyright year list to include the current year. -my $VERSION = '2012-02-05.21:39'; # UTC +my $VERSION = '2013-01-03.09:41'; # UTC # Copyright (C) 2009-2013 Free Software Foundation, Inc. # @@ -192,7 +192,7 @@ if ($final_year != $this_year) { # Update the year. - $stmt =~ s/$final_year_orig/$final_year, $this_year/; + $stmt =~ s/\b$final_year_orig\b/$final_year, $this_year/; } if ($final_year != $this_year || $ENV{'UPDATE_COPYRIGHT_FORCE'}) { diff -r 28b073aabf32 -r aa1920a5636c tests/test-update-copyright.sh --- a/tests/test-update-copyright.sh Tue Jan 01 16:27:46 2013 -0800 +++ b/tests/test-update-copyright.sh Thu Jan 03 10:23:30 2013 +0100 @@ -505,6 +505,9 @@ /* Copyright 1987, 1988, 1991, 1992 Free Software Foundation, Inc. *** * End of comments. */ EOF +cat > $TMP.two-digit-final-is-substr-of-first < $TMP-stdout 2> $TMP-stderr compare /dev/null $TMP-stdout || exit 1 @@ -536,6 +539,9 @@ Inc. *** * End of comments. */ EOF +compare - $TMP.two-digit-final-is-substr-of-first <