FYI, I've just pushed this fix. I noticed this bug when attempting to update gzip's copyright dates. It has a few files with two copyright lines. The old version of this script would update only the first one.
>From 7f1b32336b063be3a672e9285f62c6b8ce5eb6e1 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@fb.com> Date: Mon, 2 Jan 2023 22:52:08 -0800 Subject: [PATCH] update-copyright: also work with two or more updatable lines in a file * build-aux/update-copyright: Replace every occurrence of the copyright line, not just the first one. * tests/test-update-copyright.sh: Add a test case for this. --- ChangeLog | 7 +++++++ build-aux/update-copyright | 4 ++-- tests/test-update-copyright.sh | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 673da843c1..7868d312bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-01-10 Jim Meyering <meyer...@fb.com> + + update-copyright: also work with two or more updatable lines in a file + * build-aux/update-copyright: Replace every occurrence of the copyright + line, not just the first one. + * tests/test-update-copyright.sh: Add a test case for this. + 2023-01-10 Bruno Haible <br...@clisp.org> immutable: Fix initialization failure on Android. diff --git a/build-aux/update-copyright b/build-aux/update-copyright index ce919bac72..99196fceef 100755 --- a/build-aux/update-copyright +++ b/build-aux/update-copyright @@ -137,7 +137,7 @@ eval 'exec perl -wSx -0777 -pi "$0" "$@"' if 0; -my $VERSION = '2020-04-04.15:07'; # UTC +my $VERSION = '2023-01-11.04:24'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook @@ -280,7 +280,7 @@ if (defined $stmt_re) } # Replace the old copyright statement. - s/$stmt_re/$stmt_wrapped/; + s/$stmt_re/$stmt_wrapped/g; } } else diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh index 377cf8731e..a84ae34512 100755 --- a/tests/test-update-copyright.sh +++ b/tests/test-update-copyright.sh @@ -115,6 +115,10 @@ Copyright (C) 1990-2005, 2007-2009 Acme, Inc. # Copyright (C) 1990-2005, 2007-2009 Free Software # Foundation, Inc. EOF +cat > $TMP.8 <<EOF +Copyright (C) 2008 Free Software Foundation, Inc. +Copyright (C) 2008 Free Software Foundation, Inc. +EOF UPDATE_COPYRIGHT_YEAR=2009 \ update-copyright $TMP.? 1> $TMP-stdout 2> $TMP-stderr @@ -157,6 +161,10 @@ Copyright (C) 1990-2005, 2007-2009 Acme, Inc. # Copyright (C) 1990-2005, 2007-2009 Free Software # Foundation, Inc. EOF +compare - $TMP.8 <<EOF || exit 1 +Copyright (C) 2008, 2009 Free Software Foundation, Inc. +Copyright (C) 2008, 2009 Free Software Foundation, Inc. +EOF UPDATE_COPYRIGHT_YEAR=2010 UPDATE_COPYRIGHT_USE_INTERVALS=1 \ update-copyright $TMP.? 1> $TMP-stdout 2> $TMP-stderr -- 2.39.0.132.g8a4e8f6a67