+2018-06-29 Paul Eggert <eggert@cs.ucla.edu>
+
+ regex: glibc does not use intprops.h
+ Maybe we can talk glibc into using intprops.h someday, but
+ now doesn’t seem to be a good time.
+ * lib/regcomp.c (TYPE_SIGNED): Remove; regex_internal.h now defines.
+ * lib/regex_internal.h [_LIBC]: Do not include intprops.h.
+ (TYPE_SIGNED, INT_ADD_WRAPV): New macros.
+
2018-06-28 Paul Eggert <eggert@cs.ucla.edu>
regex: port to recently proposed glibc regex merge
if (BE (tree == NULL, 0))
goto parse_dup_op_espace;
-/* From gnulib's "intprops.h":
- True if the arithmetic type T is signed. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-
/* This loop is actually executed only when end != -1,
to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
already created the start+1-th copy. */
#include <stdbool.h>
#include <stdint.h>
-#include "intprops.h"
+/* Properties of integers. Although Gnulib has intprops.h, glibc does
+ without for now. */
+#ifndef _LIBC
+# include "intprops.h"
+#else
+/* True if the real type T is signed. */
+# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+/* True if adding the nonnegative Idx values A and B would overflow.
+ If false, set *R to A + B. A, B, and R may be evaluated more than
+ once, or zero times. Although this is not a full implementation of
+ Gnulib INT_ADD_WRAPV, it is good enough for glibc regex code.
+ FIXME: This implementation is a fragile stopgap, and this file would
+ be simpler and more robust if intprops.h were migrated into glibc. */
+# define INT_ADD_WRAPV(a, b, r) \
+ (IDX_MAX - (a) < (b) ? true : (*(r) = (a) + (b), false))
+#endif
#ifdef _LIBC
# include <libc-lock.h>