diff options
| author | Paul Eggert | 2020-01-27 23:27:46 -0800 |
|---|---|---|
| committer | Paul Eggert | 2020-01-27 23:29:18 -0800 |
| commit | da7267e889a72edd86896f7487a6a8e4d1216441 (patch) | |
| tree | 5bc96132203b8bd736fc3877a728bdfe6c5ec64f /lib/regex_internal.h | |
| parent | a02b179242a55aba20158aa245e5643a04d07576 (diff) | |
| download | emacs-da7267e889a72edd86896f7487a6a8e4d1216441.tar.gz emacs-da7267e889a72edd86896f7487a6a8e4d1216441.zip | |
Update from Gnulib
This incorporates:
2020-01-27 regex: port to non-GCC pre-IEC-60559
2020-01-24 regex: port to Gawk on nonstandard platforms
2020-01-21 regex: fix bug with >=16 subexpressions
2020-01-21 regex: simplify definition of BITSET_WORD_BITS
* lib/regex.c, lib/regex_internal.h: Copy from Gnulib.
Diffstat (limited to 'lib/regex_internal.h')
| -rw-r--r-- | lib/regex_internal.h | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 5c9cbf3b4fe..f6ebfb003e8 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h | |||
| @@ -141,6 +141,24 @@ | |||
| 141 | #ifndef SSIZE_MAX | 141 | #ifndef SSIZE_MAX |
| 142 | # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) | 142 | # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) |
| 143 | #endif | 143 | #endif |
| 144 | #ifndef ULONG_WIDTH | ||
| 145 | # define ULONG_WIDTH REGEX_UINTEGER_WIDTH (ULONG_MAX) | ||
| 146 | /* The number of usable bits in an unsigned integer type with maximum | ||
| 147 | value MAX, as an int expression suitable in #if. Cover all known | ||
| 148 | practical hosts. This implementation exploits the fact that MAX is | ||
| 149 | 1 less than a power of 2, and merely counts the number of 1 bits in | ||
| 150 | MAX; "COBn" means "count the number of 1 bits in the low-order n bits". */ | ||
| 151 | # define REGEX_UINTEGER_WIDTH(max) REGEX_COB128 (max) | ||
| 152 | # define REGEX_COB128(n) (REGEX_COB64 ((n) >> 31 >> 31 >> 2) + REGEX_COB64 (n)) | ||
| 153 | # define REGEX_COB64(n) (REGEX_COB32 ((n) >> 31 >> 1) + REGEX_COB32 (n)) | ||
| 154 | # define REGEX_COB32(n) (REGEX_COB16 ((n) >> 16) + REGEX_COB16 (n)) | ||
| 155 | # define REGEX_COB16(n) (REGEX_COB8 ((n) >> 8) + REGEX_COB8 (n)) | ||
| 156 | # define REGEX_COB8(n) (REGEX_COB4 ((n) >> 4) + REGEX_COB4 (n)) | ||
| 157 | # define REGEX_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + ((n) & 1)) | ||
| 158 | # if ULONG_MAX / 2 + 1 != 1ul << (ULONG_WIDTH - 1) | ||
| 159 | # error "ULONG_MAX out of range" | ||
| 160 | # endif | ||
| 161 | #endif | ||
| 144 | 162 | ||
| 145 | /* The type of indexes into strings. This is signed, not size_t, | 163 | /* The type of indexes into strings. This is signed, not size_t, |
| 146 | since the API requires indexes to fit in regoff_t anyway, and using | 164 | since the API requires indexes to fit in regoff_t anyway, and using |
| @@ -164,36 +182,8 @@ typedef __re_size_t re_hashval_t; | |||
| 164 | typedef unsigned long int bitset_word_t; | 182 | typedef unsigned long int bitset_word_t; |
| 165 | /* All bits set in a bitset_word_t. */ | 183 | /* All bits set in a bitset_word_t. */ |
| 166 | #define BITSET_WORD_MAX ULONG_MAX | 184 | #define BITSET_WORD_MAX ULONG_MAX |
| 167 | 185 | /* Number of bits in a bitset_word_t. */ | |
| 168 | /* Number of bits in a bitset_word_t. For portability to hosts with | 186 | #define BITSET_WORD_BITS ULONG_WIDTH |
| 169 | padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)'; | ||
| 170 | instead, deduce it directly from BITSET_WORD_MAX. Avoid | ||
| 171 | greater-than-32-bit integers and unconditional shifts by more than | ||
| 172 | 31 bits, as they're not portable. */ | ||
| 173 | #if BITSET_WORD_MAX == 0xffffffffUL | ||
| 174 | # define BITSET_WORD_BITS 32 | ||
| 175 | #elif BITSET_WORD_MAX >> 31 >> 4 == 1 | ||
| 176 | # define BITSET_WORD_BITS 36 | ||
| 177 | #elif BITSET_WORD_MAX >> 31 >> 16 == 1 | ||
| 178 | # define BITSET_WORD_BITS 48 | ||
| 179 | #elif BITSET_WORD_MAX >> 31 >> 28 == 1 | ||
| 180 | # define BITSET_WORD_BITS 60 | ||
| 181 | #elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1 | ||
| 182 | # define BITSET_WORD_BITS 64 | ||
| 183 | #elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1 | ||
| 184 | # define BITSET_WORD_BITS 72 | ||
| 185 | #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1 | ||
| 186 | # define BITSET_WORD_BITS 128 | ||
| 187 | #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1 | ||
| 188 | # define BITSET_WORD_BITS 256 | ||
| 189 | #elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1 | ||
| 190 | # define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */ | ||
| 191 | # if BITSET_WORD_BITS <= SBC_MAX | ||
| 192 | # error "Invalid SBC_MAX" | ||
| 193 | # endif | ||
| 194 | #else | ||
| 195 | # error "Add case for new bitset_word_t size" | ||
| 196 | #endif | ||
| 197 | 187 | ||
| 198 | /* Number of bitset_word_t values in a bitset_t. */ | 188 | /* Number of bitset_word_t values in a bitset_t. */ |
| 199 | #define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) | 189 | #define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) |
| @@ -601,9 +591,8 @@ struct re_backref_cache_entry | |||
| 601 | Idx str_idx; | 591 | Idx str_idx; |
| 602 | Idx subexp_from; | 592 | Idx subexp_from; |
| 603 | Idx subexp_to; | 593 | Idx subexp_to; |
| 594 | bitset_word_t eps_reachable_subexps_map; | ||
| 604 | char more; | 595 | char more; |
| 605 | char unused; | ||
| 606 | unsigned short int eps_reachable_subexps_map; | ||
| 607 | }; | 596 | }; |
| 608 | 597 | ||
| 609 | typedef struct | 598 | typedef struct |