]> Savannah Git Hosting - gnulib.git/commitdiff
diffseq: don’t assume integers lack padding
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 May 2023 15:57:29 +0000 (08:57 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 May 2023 15:58:04 +0000 (08:58 -0700)
* NEWS: Mention this.
* lib/diffseq.h (OFFSET_MAX): Don’t define;
this is now the user’s responsibility.
* lib/fstrcmp.c (OFFSET_MAX): Define to PTRDIFF_MAX.

ChangeLog
NEWS
lib/diffseq.h
lib/fstrcmp.c

index 8e980741c55c8126aaadc551529db54fd72d72cd..426cc797be354cfe6c352a5468f364d98b9114f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-05-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+       diffseq: don’t assume integers lack padding
+       * NEWS: Mention this.
+       * lib/diffseq.h (OFFSET_MAX): Don’t define;
+       this is now the user’s responsibility.
+       * lib/fstrcmp.c (OFFSET_MAX): Define to PTRDIFF_MAX.
+
 2023-05-18  Bruno Haible  <bruno@clisp.org>
 
        getndelim2: Silence gcc warning.
diff --git a/NEWS b/NEWS
index 1457cb1413f8b8904852bae15ac1df1e183f1342..8bc86311e9e77aa6b2151f6ff9f30c6d52b63745 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,8 @@ 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
index dfaf4f295e8119d4264df90794fe14bd06802ec0..ea45d9f89215d3a382b71f12923c58f9d7490bf0 100644 (file)
@@ -48,6 +48,7 @@
      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).
      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].
      #include "minmax.h"
  */
 
-/* Maximum value of type OFFSET.  */
-#define OFFSET_MAX \
-  ((((OFFSET)1 << (sizeof (OFFSET) * CHAR_BIT - 2)) - 1) * 2 + 1)
-
 /* Default to no early abort.  */
 #ifndef EARLY_ABORT
 # define EARLY_ABORT(ctxt) false
index ab4cb03ed31b495cff61cae874340b01e0c10d8b..02f935a969e0bfabe9d3e95c6fa5cd2a3ac7dbfb 100644 (file)
@@ -37,6 +37,7 @@
 #define ELEMENT char
 #define EQUAL(x,y) ((x) == (y))
 #define OFFSET ptrdiff_t
+#define OFFSET_MAX PTRDIFF_MAX
 #define EXTRA_CONTEXT_FIELDS \
   /* The number of edits beyond which the computation can be aborted. */ \
   ptrdiff_t edit_count_limit; \