On 2023-05-20 01:42, Bruno Haible wrote:

Yes, please.

Done by installing the attached.
From f29bafbcc2946ac128c371292358c3a8fa03221b Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 20 May 2023 12:11:54 -0700
Subject: [PATCH] diffseq: backward compatibility for OFFSET_MAX

* lib/diffseq.h (OFFSET_MAX): Define only if not already defined.
---
 ChangeLog     |  5 +++++
 NEWS          |  2 --
 lib/diffseq.h | 11 ++++++++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a0db844229..51a88b03f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-05-20  Paul Eggert  <egg...@cs.ucla.edu>
+
+	diffseq: backward compatibility for OFFSET_MAX
+	* lib/diffseq.h (OFFSET_MAX): Define only if not already defined.
+
 2023-05-19  Bruno Haible  <br...@clisp.org>
 
 	careadlinkat: Silence gcc warning for GCC ≥ 12.
diff --git a/NEWS b/NEWS
index 8bc86311e9..1457cb1413 100644
--- a/NEWS
+++ b/NEWS
@@ -74,8 +74,6 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
-2023-05-19  diffseq         Includers should now also define OFFSET_MAX.
-
 2023-04-28  largefile-required
             year2038-required
                             Modules removed, for consistency with Autoconf
diff --git a/lib/diffseq.h b/lib/diffseq.h
index ea45d9f892..c9375cd696 100644
--- a/lib/diffseq.h
+++ b/lib/diffseq.h
@@ -48,7 +48,10 @@
      OFFSET                  A signed integer type sufficient to hold the
                              difference between two indices.  Usually
                              something like ptrdiff_t.
-     OFFSET_MAX              The maximum value of OFFSET (e.g., PTRDIFF_MAX).
+     OFFSET_MAX              (Optional) The maximum value of OFFSET (e.g.,
+                             PTRDIFF_MAX).  If omitted, it is inferred in a
+                             way portable to the vast majority of C platforms,
+                             as they lack padding bits.
      EXTRA_CONTEXT_FIELDS    Declarations of fields for 'struct context'.
      NOTE_DELETE(ctxt, xoff) Record the removal of the object xvec[xoff].
      NOTE_INSERT(ctxt, yoff) Record the insertion of the object yvec[yoff].
@@ -74,6 +77,12 @@
      #include "minmax.h"
  */
 
+/* Maximum value of type OFFSET.  */
+#ifndef OFFSET_MAX
+# define OFFSET_MAX \
+   ((((OFFSET) 1 << (sizeof (OFFSET) * CHAR_BIT - 2)) - 1) * 2 + 1)
+#endif
+
 /* Default to no early abort.  */
 #ifndef EARLY_ABORT
 # define EARLY_ABORT(ctxt) false
-- 
2.39.2

Reply via email to