aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-11-10 15:48:06 +0000
committerUlrich Drepper <drepper@redhat.com>2004-11-10 15:48:06 +0000
commitbb677c9581b95720df6b28c375a3278d69e06f44 (patch)
treedc9745fd89d8cb3afbab86c2c901bce1ce2b5091 /posix/regex_internal.c
parentUpdate. (diff)
downloadglibc-bb677c9581b95720df6b28c375a3278d69e06f44.tar.gz
glibc-bb677c9581b95720df6b28c375a3278d69e06f44.tar.bz2
glibc-bb677c9581b95720df6b28c375a3278d69e06f44.zip
Update.
2004-11-09 Paolo Bonzini <bonzini@gnu.org> * posix/regexec.c (transit_state): Remove the check for out-of-bounds buffers. (check_matching): Check here for out-of-bounds buffers. (re_search_internal): Store into match_kind a set of bits indicating which incantation of fastmap scanning must be used. Use a switch statement instead of multiple ifs. Exit the final "for (;;)" with goto free_return unless the match succeeded, thus simplifying some conditionals. * posix/regex_internal.c (re_string_reconstruct, re_string_context_at): Add several branch predictions for case-sensitive matching and no transition table being used. 2004-11-10 Ulrich Drepper <drepper@redhat.com> * posix/tst-waitid.c: Don't use error to print error message, they won't end up in the .out file. * nscd/nscd_getgr_r.c: Likewise. Make map externally visible. * nscd/nscd_gethst_r.c: Likewise.
Diffstat (limited to 'posix/regex_internal.c')
-rw-r--r--posix/regex_internal.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/posix/regex_internal.c b/posix/regex_internal.c
index 609719f79c..bb1d73d9a0 100644
--- a/posix/regex_internal.c
+++ b/posix/regex_internal.c
@@ -576,7 +576,7 @@ re_string_reconstruct (pstr, idx, eflags)
int idx, eflags;
{
int offset = idx - pstr->raw_mbs_idx;
- if (offset < 0)
+ if (BE (offset < 0, 0))
{
/* Reset buffer. */
#ifdef RE_ENABLE_I18N
@@ -596,10 +596,10 @@ re_string_reconstruct (pstr, idx, eflags)
offset = idx;
}
- if (offset != 0)
+ if (BE (offset != 0, 1))
{
/* Are the characters which are already checked remain? */
- if (offset < pstr->valid_raw_len
+ if (BE (offset < pstr->valid_raw_len, 1)
#ifdef RE_ENABLE_I18N
/* Handling this would enlarge the code too much.
Accept a slowdown in that case. */
@@ -614,7 +614,7 @@ re_string_reconstruct (pstr, idx, eflags)
memmove (pstr->wcs, pstr->wcs + offset,
(pstr->valid_len - offset) * sizeof (wint_t));
#endif /* RE_ENABLE_I18N */
- if (pstr->mbs_allocated)
+ if (BE (pstr->mbs_allocated, 0))
memmove (pstr->mbs, pstr->mbs + offset,
pstr->valid_len - offset);
pstr->valid_len -= offset;
@@ -711,7 +711,7 @@ re_string_reconstruct (pstr, idx, eflags)
? CONTEXT_NEWLINE : 0));
}
}
- if (!pstr->mbs_allocated)
+ if (!BE (pstr->mbs_allocated, 0))
pstr->mbs += offset;
}
pstr->raw_mbs_idx = idx;
@@ -733,16 +733,17 @@ re_string_reconstruct (pstr, idx, eflags)
}
else
#endif /* RE_ENABLE_I18N */
+ if (BE (pstr->mbs_allocated, 0))
{
if (pstr->icase)
build_upper_buffer (pstr);
else if (pstr->trans != NULL)
re_string_translate_buffer (pstr);
- else
- pstr->valid_len = pstr->len;
}
- pstr->cur_idx = 0;
+ else
+ pstr->valid_len = pstr->len;
+ pstr->cur_idx = 0;
return REG_NOERROR;
}
@@ -840,16 +841,13 @@ re_string_context_at (input, idx, eflags)
int idx, eflags;
{
int c;
- if (idx < 0 || idx == input->len)
- {
- if (idx < 0)
- /* In this case, we use the value stored in input->tip_context,
- since we can't know the character in input->mbs[-1] here. */
- return input->tip_context;
- else /* (idx == input->len) */
- return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
- : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
- }
+ if (BE (idx < 0, 0))
+ /* In this case, we use the value stored in input->tip_context,
+ since we can't know the character in input->mbs[-1] here. */
+ return input->tip_context;
+ if (BE (idx == input->len, 0))
+ return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
+ : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
#ifdef RE_ENABLE_I18N
if (input->mb_cur_max > 1)
{