bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] update-copyright: use en dashes in .texi ranges * build-aux/upda


From: Paul Eggert
Subject: [PATCH] update-copyright: use en dashes in .texi ranges * build-aux/update-copyright: Update ranges in .tex, .texi, and .texinfo files to use en dashes instead of hyphens.
Date: Mon, 14 Oct 2019 13:38:03 -0700

---
 ChangeLog                  |  6 ++++--
 build-aux/update-copyright | 14 ++++++++------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ae7adbbd5..db63a4be0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,10 @@
 2019-10-14  Paul Eggert  <address@hidden>
 
-       update-copyright: allow en dashes in year ranges
+       update-copyright: use en dashes in .texi ranges
        * build-aux/update-copyright: Match year ranges like "1998--2019",
-       which are used in the Autoconf manual.
+       which are used in the Autoconf manual.  Also, update ranges in
+       .tex, .texi, and .texinfo files to use en dashes instead of
+       hyphens.
 
 2019-10-13  Paul Eggert  <address@hidden>
 
diff --git a/build-aux/update-copyright b/build-aux/update-copyright
index 89ca9bac9..e4809f620 100755
--- a/build-aux/update-copyright
+++ b/build-aux/update-copyright
@@ -98,7 +98,7 @@
 #   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 dashes.  Whitespace may appear after commas.
+#      commas, "-", or "--".  Whitespace may appear after commas.
 #
 # Environment variables:
 #
@@ -231,26 +231,28 @@ 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})--?(\d{4})/join(', ', $1..$2)/eg;
           }
         else
           {
+            my $ndash = $ARGV =~ /\.tex(i(nfo)?)?$/ ? "--" : "-";
+
             $stmt =~
               s/
                 (\d{4})
                 (?:
-                  (,\ |-)
+                  (,\ |--?)
                   ((??{
-                    if    ($2 eq '-') { '\d{4}'; }
+                    if   ($2 ne ', ') { '\d{4}'; }
                     elsif (!$3)       { $1 + 1;  }
                     else              { $3 + 1;  }
                   }))
                 )+
-              /$1-$3/gx;
+              /$1$ndash$3/gx;
 
             # 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-$2/;
+              and $stmt =~ s/\b(\d{4})\b.*\b(\d{4})\b/$1$ndash$2/;
           }
 
         # Format within margin.
-- 
2.21.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]