Skip to content

Commit

Permalink
regex: don't assume uint64_t or uint32_t
Browse files Browse the repository at this point in the history
* lib/regcomp.c (init_word_char): Don't assume that the types
uint64_t and uint32_t exist.  The C standard doesn't guarantee
them, and on some 32-bit compilers there is no uint64_t.
Problem reported by Gianluigi Tiesi in
<http://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00154.html>.
  • Loading branch information
eggert committed May 27, 2012
1 parent 4fb7ea2 commit 252b524
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
@@ -1,3 +1,12 @@
2012-05-26 Paul Eggert <eggert@cs.ucla.edu>

regex: don't assume uint64_t or uint32_t
* lib/regcomp.c (init_word_char): Don't assume that the types
uint64_t and uint32_t exist. The C standard doesn't guarantee
them, and on some 32-bit compilers there is no uint64_t.
Problem reported by Gianluigi Tiesi in
<http://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00154.html>.

2012-05-25 Jim Meyering <meyering@redhat.com>

maint.mk: add strncpy-prohibiting syntax-check rule
Expand Down
16 changes: 10 additions & 6 deletions lib/regcomp.c
Expand Up @@ -956,18 +956,22 @@ init_word_char (re_dfa_t *dfa)
int ch = 0;
if (BE (dfa->map_notascii == 0, 1))
{
bitset_word_t bits0 = 0x00000000;
bitset_word_t bits1 = 0x03ff0000;
bitset_word_t bits2 = 0x87fffffe;
bitset_word_t bits3 = 0x07fffffe;
if (BITSET_WORD_BITS == 64)
{
dfa->word_char[0] = UINT64_C (0x03ff000000000000);
dfa->word_char[1] = UINT64_C (0x07fffffe87fffffe);
dfa->word_char[0] = bits1 << 31 << 1 | bits0;
dfa->word_char[1] = bits3 << 31 << 1 | bits2;
i = 2;
}
else if (BITSET_WORD_BITS == 32)
{
dfa->word_char[0] = UINT32_C (0x00000000);
dfa->word_char[1] = UINT32_C (0x03ff0000);
dfa->word_char[2] = UINT32_C (0x87fffffe);
dfa->word_char[3] = UINT32_C (0x07fffffe);
dfa->word_char[0] = bits0;
dfa->word_char[1] = bits1;
dfa->word_char[2] = bits2;
dfa->word_char[3] = bits3;
i = 4;
}
else
Expand Down

0 comments on commit 252b524

Please sign in to comment.