bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* FYI: update-copyright: also work with two or more updatable lines
@ 2023-01-11  4:37 Jim Meyering
  2023-01-11  5:19 ` Jim Meyering
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Meyering @ 2023-01-11  4:37 UTC (permalink / raw)
  To: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 211 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: update-copyright.diff --]
[-- Type: text/x-patch, Size: 2803 bytes --]

From 7f1b32336b063be3a672e9285f62c6b8ce5eb6e1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@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  <meyering@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  <bruno@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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-11  5:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11  4:37 FYI: update-copyright: also work with two or more updatable lines Jim Meyering
2023-01-11  5:19 ` Jim Meyering

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).