]> Savannah Git Hosting - gnulib.git/commitdiff
regex: glibc does not use intprops.h
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 29 Jun 2018 22:34:57 +0000 (15:34 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 29 Jun 2018 22:56:35 +0000 (15:56 -0700)
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.

ChangeLog
lib/regcomp.c
lib/regex_internal.h

index 1b2505a1a27dfde77d5f1bc7d491ac059b48a8bf..e5c1e02c797515846b524117806e748dab72c5fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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
index 6aaa54f66d188ab7e9c09a777eb4b87a0e465d15..7b5ddaad0cb29ad460997fde31b81ed1c44aed9f 100644 (file)
@@ -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 <re>{0,n} as (<re>(<re>...<re>?)?)?...  We have
      already created the start+1-th copy.  */
index b27afbda2ad686e0334d1ca1e56b55ec4a7dc822..3b836ed2067a4bff6ddd489cf545af5383be0c4b 100644 (file)
 #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>