mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-19 07:00:08 +00:00
(init_syntax_once): move below definition of
ISALNUM etc., then use ISALNUM to init the table, so that the word ops will work if i18n'ed. (SYNTAX): And subscript with 0xFF for 8bit character sets. (re_match_2_internal): Correct check for charset after exactn in loop.
This commit is contained in:
parent
587d46d904
commit
9f18fbc9ac
@ -164,46 +164,6 @@ char *realloc ();
|
|||||||
# define SWITCH_ENUM_CAST(x) (x)
|
# define SWITCH_ENUM_CAST(x) (x)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* How many characters in the character set. */
|
|
||||||
# define CHAR_SET_SIZE 256
|
|
||||||
|
|
||||||
# ifdef SYNTAX_TABLE
|
|
||||||
|
|
||||||
extern char *re_syntax_table;
|
|
||||||
|
|
||||||
# else /* not SYNTAX_TABLE */
|
|
||||||
|
|
||||||
static char re_syntax_table[CHAR_SET_SIZE];
|
|
||||||
|
|
||||||
static void
|
|
||||||
init_syntax_once ()
|
|
||||||
{
|
|
||||||
register int c;
|
|
||||||
static int done;
|
|
||||||
|
|
||||||
if (done)
|
|
||||||
return;
|
|
||||||
|
|
||||||
bzero (re_syntax_table, sizeof re_syntax_table);
|
|
||||||
|
|
||||||
for (c = 'a'; c <= 'z'; c++)
|
|
||||||
re_syntax_table[c] = Sword;
|
|
||||||
|
|
||||||
for (c = 'A'; c <= 'Z'; c++)
|
|
||||||
re_syntax_table[c] = Sword;
|
|
||||||
|
|
||||||
for (c = '0'; c <= '9'; c++)
|
|
||||||
re_syntax_table[c] = Sword;
|
|
||||||
|
|
||||||
re_syntax_table['_'] = Sword;
|
|
||||||
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# endif /* not SYNTAX_TABLE */
|
|
||||||
|
|
||||||
# define SYNTAX(c) re_syntax_table[c]
|
|
||||||
|
|
||||||
#endif /* not emacs */
|
#endif /* not emacs */
|
||||||
|
|
||||||
/* Get the interface, including the syntax bits. */
|
/* Get the interface, including the syntax bits. */
|
||||||
@ -276,6 +236,43 @@ init_syntax_once ()
|
|||||||
# define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
|
# define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef emacs
|
||||||
|
/* How many characters in the character set. */
|
||||||
|
# define CHAR_SET_SIZE 256
|
||||||
|
|
||||||
|
# ifdef SYNTAX_TABLE
|
||||||
|
|
||||||
|
extern char *re_syntax_table;
|
||||||
|
|
||||||
|
# else /* not SYNTAX_TABLE */
|
||||||
|
|
||||||
|
static char re_syntax_table[CHAR_SET_SIZE];
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_syntax_once ()
|
||||||
|
{
|
||||||
|
register int c;
|
||||||
|
static int done = 0;
|
||||||
|
|
||||||
|
if (done)
|
||||||
|
return;
|
||||||
|
bzero (re_syntax_table, sizeof re_syntax_table);
|
||||||
|
|
||||||
|
for (c = 0; c < CHAR_SET_SIZE; ++c)
|
||||||
|
if (ISALNUM (c))
|
||||||
|
re_syntax_table[c] = Sword;
|
||||||
|
|
||||||
|
re_syntax_table['_'] = Sword;
|
||||||
|
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# endif /* not SYNTAX_TABLE */
|
||||||
|
|
||||||
|
# define SYNTAX(c) re_syntax_table[((c) & 0xFF)]
|
||||||
|
|
||||||
|
#endif /* emacs */
|
||||||
|
|
||||||
/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
|
/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
|
||||||
use `alloca' instead of `malloc'. This is because using malloc in
|
use `alloca' instead of `malloc'. This is because using malloc in
|
||||||
re_search* or re_match* could cause memory leaks when C-g is used in
|
re_search* or re_match* could cause memory leaks when C-g is used in
|
||||||
@ -4836,11 +4833,11 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
|
|||||||
/* We win if the first character of the loop is not part
|
/* We win if the first character of the loop is not part
|
||||||
of the charset. */
|
of the charset. */
|
||||||
if ((re_opcode_t) p1[3] == exactn
|
if ((re_opcode_t) p1[3] == exactn
|
||||||
&& ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
|
&& ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
|
||||||
&& (p2[2 + p1[5] / BYTEWIDTH]
|
&& (p2[2 + p1[5] / BYTEWIDTH]
|
||||||
& (1 << (p1[5] % BYTEWIDTH)))))
|
& (1 << (p1[5] % BYTEWIDTH)))))
|
||||||
{
|
{
|
||||||
p[-3] = (unsigned char) pop_failure_jump;
|
p[-3] = (unsigned char) pop_failure_jump;
|
||||||
DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
|
DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user