[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] diffseq: don’t assume integers lack padding
From: |
Paul Eggert |
Subject: |
[PATCH] diffseq: don’t assume integers lack padding |
Date: |
Fri, 19 May 2023 08:58:26 -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 | 8 ++++++++
NEWS | 2 ++
lib/diffseq.h | 5 +----
lib/fstrcmp.c | 1 +
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8e980741c5..426cc797be 100644
--- 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 1457cb1413..8bc86311e9 100644
--- 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
diff --git a/lib/diffseq.h b/lib/diffseq.h
index dfaf4f295e..ea45d9f892 100644
--- a/lib/diffseq.h
+++ b/lib/diffseq.h
@@ -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].
@@ -73,10 +74,6 @@
#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
diff --git a/lib/fstrcmp.c b/lib/fstrcmp.c
index ab4cb03ed3..02f935a969 100644
--- a/lib/fstrcmp.c
+++ b/lib/fstrcmp.c
@@ -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; \
--
2.39.2
- [PATCH] diffseq: don’t assume integers lack padding,
Paul Eggert <=