]> Savannah Git Hosting - gnulib.git/commitdiff
fnmatch: Use idx_t for nonnegative ptrdiff_t variables.
authorBruno Haible <bruno@clisp.org>
Sun, 6 Dec 2020 11:31:08 +0000 (12:31 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 6 Dec 2020 11:31:08 +0000 (12:31 +0100)
* 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.

ChangeLog
lib/fnmatch.c
lib/fnmatch_loop.c
modules/fnmatch

index 41bb0ca2a72ef1386a7d91e909749675c8f35350..ad31f361a447b7e06197fe3a3e94d0a3199f8204 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-12-06  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        c-stack: Use idx_t for nonnegative ptrdiff_t variables.
index 30144286f33721c1b78519ce22ce5f36c62c86ee..c80809e78351fda2666c45bb483201c870d0f552 100644 (file)
@@ -76,6 +76,12 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
 #include <intprops.h>
 #include <flexmember.h>
 
+#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))
index d9be16f4c509037cf502acce65fd009cdbbdc4de..c533107a2a7f5141c25a93efe2a745540b35b3fe 100644 (file)
@@ -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))             \
               {                                                               \
index f547670214d5c57c6fe2230d2ac0e6143bfbfb9a..2cb69a7e9424d48d7684a7b71f595afcbeb90584 100644 (file)
@@ -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]