bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: bug-gnulib@gnu.org
Subject: FYI: update-copyright: also work with two or more updatable lines
Date: Tue, 10 Jan 2023 20:37:24 -0800	[thread overview]
Message-ID: <m25yddu1ob.fsf@meyering.net> (raw)

[-- 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


             reply	other threads:[~2023-01-11  4:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  4:37 Jim Meyering [this message]
2023-01-11  5:19 ` FYI: update-copyright: also work with two or more updatable lines Jim Meyering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m25yddu1ob.fsf@meyering.net \
    --to=jim@meyering.net \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).