summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-10-11 09:03:59 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-10-11 09:05:15 -0700
commit429b3497d18814557195b83008700d0893a3b342 (patch)
tree4820e2b668f5edceb000c64833b49c4516b2b894 /src
parent1dd9bbe724624220a6ea136a1199d5172e5c1312 (diff)
downloadgrep-429b3497d18814557195b83008700d0893a3b342.tar.gz
maint: prefer stdckdint.h to intprops.h
Prefer the standard C23 ckd_* macros to Gnulib’s *_WRAPV macros. * bootstrap.conf (gnulib_modules): Add stdckdint. * src/grep.c, src/kwset.c, src/pcresearch.c: Include stdckdint.h, and prefer ckd_* to *_WRAPV. Include intprops.h only if needed.
Diffstat (limited to 'src')
-rw-r--r--src/grep.c5
-rw-r--r--src/kwset.c5
-rw-r--r--src/pcresearch.c5
3 files changed, 9 insertions, 6 deletions
diff --git a/src/grep.c b/src/grep.c
index 9b9407d6..40ddfea0 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -24,6 +24,7 @@
#include <wchar.h>
#include <inttypes.h>
#include <stdarg.h>
+#include <stdckdint.h>
#include <stdint.h>
#include <stdio.h>
#include "system.h"
@@ -898,7 +899,7 @@ static intmax_t
add_count (intmax_t a, idx_t b)
{
intmax_t sum;
- if (!INT_ADD_OK (a, b, &sum))
+ if (ckd_add (&sum, a, b))
die (EXIT_TROUBLE, 0, _("input is too large to count"));
return sum;
}
@@ -982,7 +983,7 @@ fillbuf (idx_t save, struct stat const *st)
off_t to_be_read = st->st_size - bufoffset;
ptrdiff_t a;
if (0 <= to_be_read
- && INT_ADD_OK (to_be_read, save + min_after_buflim, &a))
+ && !ckd_add (&a, to_be_read, save + min_after_buflim))
alloc_max = MAX (a, bufalloc + incr_min);
}
diff --git a/src/kwset.c b/src/kwset.c
index fc25a94e..ec1bc69d 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -27,10 +27,11 @@
#include "kwset.h"
+#include <stdckdint.h>
#include <stdint.h>
#include <sys/types.h>
+
#include "system.h"
-#include "intprops.h"
#include "memchr2.h"
#include "obstack.h"
#include "xalloc.h"
@@ -674,7 +675,7 @@ bmexec_trans (kwset_t kwset, char const *text, idx_t size)
/* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
idx_t len12;
- if (INT_MULTIPLY_OK (len, 12, &len12) && len12 < size)
+ if (!ckd_mul (&len12, len, 12) && len12 < size)
/* 11 is not a bug, the initial offset happens only once. */
for (ep = text + size - 11 * len; tp <= ep; )
{
diff --git a/src/pcresearch.c b/src/pcresearch.c
index fd8ea0cc..6ccfac07 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -20,7 +20,8 @@
#include "search.h"
#include "die.h"
-#include "intprops.h"
+
+#include <stdckdint.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
@@ -106,7 +107,7 @@ jit_exec (struct pcre_comp *pc, char const *subject, idx_t search_bytes,
{
uint32_t lim;
pcre2_config (PCRE2_CONFIG_DEPTHLIMIT, &lim);
- if (INT_MULTIPLY_WRAPV (lim, 2, &lim))
+ if (ckd_mul (&lim, lim, 2))
return e;
if (!pc->mcontext)
pc->mcontext = pcre2_match_context_create (pc->gcontext);