diff options
-rw-r--r-- | support/ChangeLog | 5 | ||||
-rw-r--r-- | support/regex_internal.h | 17 |
2 files changed, 21 insertions, 1 deletions
diff --git a/support/ChangeLog b/support/ChangeLog index ccb217cf..bb275db6 100644 --- a/support/ChangeLog +++ b/support/ChangeLog @@ -1,3 +1,8 @@ +2020-01-28 Arnold D. Robbins <arnold@skeeve.com> + + * regex_internal.h: Update from GNULIB. Hopefully fixes + non-GCC issues. + 2020-01-24 Arnold D. Robbins <arnold@skeeve.com> * dfa.h, dfa.c: Update copyright years. diff --git a/support/regex_internal.h b/support/regex_internal.h index 6d436fde..8c42586c 100644 --- a/support/regex_internal.h +++ b/support/regex_internal.h @@ -142,7 +142,22 @@ # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) #endif #ifndef ULONG_WIDTH -# define ULONG_WIDTH (CHAR_BIT * sizeof (unsigned long int)) +# define ULONG_WIDTH REGEX_UINTEGER_WIDTH (ULONG_MAX) +/* The number of usable bits in an unsigned integer type with maximum + value MAX, as an int expression suitable in #if. Cover all known + practical hosts. This implementation exploits the fact that MAX is + 1 less than a power of 2, and merely counts the number of 1 bits in + MAX; "COBn" means "count the number of 1 bits in the low-order n bits". */ +# define REGEX_UINTEGER_WIDTH(max) REGEX_COB128 (max) +# define REGEX_COB128(n) (REGEX_COB64 ((n) >> 31 >> 31 >> 2) + REGEX_COB64 (n)) +# define REGEX_COB64(n) (REGEX_COB32 ((n) >> 31 >> 1) + REGEX_COB32 (n)) +# define REGEX_COB32(n) (REGEX_COB16 ((n) >> 16) + REGEX_COB16 (n)) +# define REGEX_COB16(n) (REGEX_COB8 ((n) >> 8) + REGEX_COB8 (n)) +# define REGEX_COB8(n) (REGEX_COB4 ((n) >> 4) + REGEX_COB4 (n)) +# define REGEX_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + ((n) & 1)) +# if ULONG_MAX / 2 + 1 != 1ul << (ULONG_WIDTH - 1) +# error "ULONG_MAX out of range" +# endif #endif /* The type of indexes into strings. This is signed, not size_t, |