From: Bruno Haible Date: Sun, 6 Dec 2020 11:31:08 +0000 (+0100) Subject: fnmatch: Use idx_t for nonnegative ptrdiff_t variables. X-Git-Tag: v1.0~3416 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=6b0f10dd650c687c21ee0e301fe82f4d486c1f1a;p=gnulib.git fnmatch: Use idx_t for nonnegative ptrdiff_t variables. * lib/fnmatch.c: Include idx.h. In glibc, define idx_t directly. * lib/fnmatch_loop.c (EXT): Mark slen, new_used, plensize as nonnegative. * modules/fnmatch (Depends-on): Add idx. --- diff --git a/ChangeLog b/ChangeLog index 41bb0ca2a7..ad31f361a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2020-12-06 Bruno Haible + + fnmatch: Use idx_t for nonnegative ptrdiff_t variables. + * lib/fnmatch.c: Include idx.h. In glibc, define idx_t directly. + * lib/fnmatch_loop.c (EXT): Mark slen, new_used, plensize as + nonnegative. + * modules/fnmatch (Depends-on): Add idx. + 2020-12-06 Bruno Haible c-stack: Use idx_t for nonnegative ptrdiff_t variables. diff --git a/lib/fnmatch.c b/lib/fnmatch.c index 30144286f3..c80809e783 100644 --- a/lib/fnmatch.c +++ b/lib/fnmatch.c @@ -76,6 +76,12 @@ extern int fnmatch (const char *pattern, const char *string, int flags); #include #include +#ifdef _LIBC +typedef ptrdiff_t idx_t; +#else +# include "idx.h" +#endif + /* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */ #define NO_LEADING_PERIOD(flags) \ ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD)) diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c index d9be16f4c5..c533107a2a 100644 --- a/lib/fnmatch_loop.c +++ b/lib/fnmatch_loop.c @@ -1036,9 +1036,9 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, struct patternlist *newp; \ size_t plen = (opt == L_('?') || opt == L_('@') \ ? pattern_len : (p - startp + 1UL)); \ - ptrdiff_t slen = FLEXSIZEOF (struct patternlist, str, 0); \ - ptrdiff_t new_used = alloca_used + slen; \ - ptrdiff_t plensize; \ + idx_t slen = FLEXSIZEOF (struct patternlist, str, 0); \ + idx_t new_used = alloca_used + slen; \ + idx_t plensize; \ if (INT_MULTIPLY_WRAPV (plen, sizeof (CHAR), &plensize) \ || INT_ADD_WRAPV (new_used, plensize, &new_used)) \ { \ diff --git a/modules/fnmatch b/modules/fnmatch index f547670214..2cb69a7e94 100644 --- a/modules/fnmatch +++ b/modules/fnmatch @@ -14,6 +14,7 @@ attribute [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] btowc [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] builtin-expect [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] flexmember [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] +idx [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] intprops [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] isblank [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1] iswctype [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]