From: Paul Eggert Date: Fri, 29 Jun 2018 22:34:57 +0000 (-0700) Subject: regex: glibc does not use intprops.h X-Git-Tag: v1.0~5536 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5508825fdbcec5f2f32053c2b6793753d6af01eb;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 1b2505a1a2..e5c1e02c79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2018-06-29 Paul Eggert + + 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 regex: port to recently proposed glibc regex merge diff --git a/lib/regcomp.c b/lib/regcomp.c index 6aaa54f66d..7b5ddaad0c 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -2650,10 +2650,6 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, 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 {0,n} as ((...?)?)?... We have already created the start+1-th copy. */ diff --git a/lib/regex_internal.h b/lib/regex_internal.h index b27afbda2a..3b836ed206 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -33,7 +33,23 @@ #include #include -#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