On 2023-06-17 08:25, Jim Meyering wrote:

Thanks. However, I noticed that this change makes it so our
semi-automated copyright year updates would fail to change this usage:
that script doesn't account for the use of "\en" in place of "-". It's
an already too-complex script, and I am loath to complicate it further
just to support this use case, so am inclined to revert this one hunk:

I hope it's OK if I took the time to add support for \(en to that script instead, by installing the attached patch into Gnulib. It wasn't as bad as I thought it might be, as it added only two lines to the script.

I have weakness for troff, having written my PhD thesis in it. This was the original 7th Edition Unix troff, using the C/A/T phototypesetter that was troff's main target in the 1970s. I spent waaay too much time in the 1970s writing troff macros, just as I suppose I spend too much time today hacking on Perl scripts....
From 3a29557bf901f94cc213e1e5b8b1eb5f03d6cac7 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 18 Jun 2023 00:27:52 -0700
Subject: [PATCH] Update \(en in copyright notices

* build-aux/update-copyright (ndash_re): New var, matching \(en too.
(stmt_remainder_re, stmt): Use it.
(stmt): Match year in constructs like "\(en2023".
(ndash): Now \(en in man pages.
---
 ChangeLog                  |  8 ++++++++
 build-aux/update-copyright | 20 ++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 381c5037e3..dece396c4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-06-18  Paul Eggert  <egg...@cs.ucla.edu>
+
+	Update \(en in copyright notices
+	* build-aux/update-copyright (ndash_re): New var, matching \(en too.
+	(stmt_remainder_re, stmt): Use it.
+	(stmt): Match year in constructs like "\(en2023".
+	(ndash): Now \(en in man pages.
+
 2023-06-17  Bruno Haible  <br...@clisp.org>
 
 	gettext: Update to gettext 0.22.
diff --git a/build-aux/update-copyright b/build-aux/update-copyright
index 99196fceef..0343eaa72c 100755
--- a/build-aux/update-copyright
+++ b/build-aux/update-copyright
@@ -98,7 +98,8 @@
 #   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 "--".  Whitespace may appear after commas.
+#      commas, "-", "--", or "\(en" (for troff).  Whitespace may appear
+#      after commas.
 #
 # Environment variables:
 #
@@ -137,7 +138,7 @@
 eval 'exec perl -wSx -0777 -pi "$0" "$@"'
      if 0;
 
-my $VERSION = '2023-01-11.04:24'; # UTC
+my $VERSION = '2023-06-18.01:14'; # 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
@@ -148,6 +149,7 @@ use warnings;
 
 my $copyright_re = 'Copyright';
 my $circle_c_re = '(?:\([cC]\)|@copyright\{}|\\\\\(co|&copy;|©)';
+my $ndash_re = '(?:--?|\\\\\(en)';
 my $holder = $ENV{UPDATE_COPYRIGHT_HOLDER};
 $holder ||= 'Free Software Foundation, Inc.';
 my $prefix_max = 5;
@@ -192,7 +194,7 @@ while (/(^|\n)(.{0,$prefix_max})$copyright_re/g)
     $holder_re =~ s/\s/$ws_re/g;
     my $stmt_remainder_re =
       "(?:$ws_re$circle_c_re)?"
-      . "$ws_re(?:(?:\\d\\d)?\\d\\d(?:,$ws_re?|--?))*"
+      . "$ws_re(?:(?:\\d\\d)?\\d\\d(?:,$ws_re?|$ndash_re))*"
       . "((?:\\d\\d)?\\d\\d)$ws_re$holder_re";
     if (/\G$stmt_remainder_re/)
       {
@@ -215,7 +217,7 @@ if (defined $stmt_re)
     if ($final_year != $this_year)
       {
         # Update the year.
-        $stmt =~ s/\b$final_year_orig\b/$final_year, $this_year/;
+        $stmt =~ s/(^|[^\d])$final_year_orig\b/$1$final_year, $this_year/;
       }
     if ($final_year != $this_year || $ENV{'UPDATE_COPYRIGHT_FORCE'})
       {
@@ -231,17 +233,19 @@ if (defined $stmt_re)
         # Make the use of intervals consistent.
         if (!$ENV{UPDATE_COPYRIGHT_USE_INTERVALS})
           {
-            $stmt =~ s/(\d{4})--?(\d{4})/join(', ', $1..$2)/eg;
+            $stmt =~ s/(\d{4})$ndash_re(\d{4})/join(', ', $1..$2)/eg;
           }
         else
           {
-            my $ndash = $ARGV =~ /\.tex(i(nfo)?)?$/ ? "--" : "-";
+            my $ndash = ($ARGV =~ /\.tex(i(nfo)?)?$/ ? "--"
+                         : $ARGV =~ /\.(\d[a-z]*|man)$/ ? "\\(en"
+                         : "-");
 
             $stmt =~
               s/
                 (\d{4})
                 (?:
-                  (,\ |--?)
+                  (,\ |$ndash_re)
                   ((??{
                     if   ($2 ne ', ') { '\d{4}'; }
                     elsif (!$3)       { $1 + 1;  }
@@ -252,7 +256,7 @@ if (defined $stmt_re)
 
             # 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$ndash$2/;
+              and $stmt =~ s/(^|[^\d])(\d{4})\b.*(?:[^\d])(\d{4})\b/$1$2$ndash$3/;
           }
 
         # Format within margin.
-- 
2.39.2

Reply via email to