aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-11-06 19:57:50 +0000
committerUlrich Drepper <drepper@redhat.com>2002-11-06 19:57:50 +0000
commit1b2c2628354003bd97af125a164e830c9d295e3a (patch)
tree32abaefed6d40cf6c559bcd6e0b47016419e7dc3
parentb14993a2356cd7b8c3f74ca2b8e743c056f9401d (diff)
downloadglibc-1b2c2628354003bd97af125a164e830c9d295e3a.tar.xz
glibc-1b2c2628354003bd97af125a164e830c9d295e3a.zip
Update.
2002-11-06 Jakub Jelinek <jakub@redhat.com> * posix/regcomp.c (re_compile_pattern): Don't set regs_allocated here. (regcomp): Don't set can_be_null here. (re_comp): Clear whole re_comp_buf with the exception of fastmap. (re_compile_internal): Clear can_be_null, set regs_allocated. * posix/regcomp.c (re_set_fastmap): New function. (re_compile_fastmap_iter): Use it. Remove redundant type == COMPLEX_BRACKET check. * posix/regexec.c (re_search_internal): Optimize searching with fastmap. Call re_string_reconstruct even if match_first is smaller than raw_mbs_idx. 2002-11-06 Isamu Hasegawa <isamu@yamato.ibm.com> * posix/regcomp (free_dfa_content): Use free_state. * posix/regex_internal.c (re_string_realloc_buffers): Don't edit pointers in case that realloc failed. (re_node_set_merge): Likewise. (register_state): Likewise. (create_newstate_common): Invoke memory release functions in case of error conditions. (create_ci_newstate): Likewise. (create_cd_newstate): Likewise. (free_state): New function. * posix/regexec.c (re_search_internal): Invoke memory release functions in case of error conditions. (sift_states_backward): Likewise. (merge_state_array): Likewise. (add_epsilon_src_nodes): Likewise. (sub_epsilon_src_nodes): Likewise. (search_subexp): Likewise. (sift_states_bkref): Likewise. (transit_state_sb): Likewise. (transit_state_mb): Likewise. (transit_state_bkref_loop): Likewise. (group_nodes_into_DFAstates): Likewise. (push_fail_stack): Don't edit pointers in case that realloc failed. (extend_buffers): Likewise. (match_ctx_add_entry): Likewise.
-rw-r--r--ChangeLog43
-rw-r--r--posix/regcomp.c35
-rw-r--r--posix/regex_internal.c607
-rw-r--r--posix/regexec.c362
4 files changed, 624 insertions, 423 deletions
diff --git a/ChangeLog b/ChangeLog
index 07bfd50665..40b5e138d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2002-11-06 Jakub Jelinek <jakub@redhat.com>
+
+ * posix/regcomp.c (re_compile_pattern): Don't set regs_allocated
+ here.
+ (regcomp): Don't set can_be_null here.
+ (re_comp): Clear whole re_comp_buf with the exception of fastmap.
+ (re_compile_internal): Clear can_be_null, set regs_allocated.
+
+ * posix/regcomp.c (re_set_fastmap): New function.
+ (re_compile_fastmap_iter): Use it. Remove redundant type ==
+ COMPLEX_BRACKET check.
+ * posix/regexec.c (re_search_internal): Optimize searching with
+ fastmap. Call re_string_reconstruct even if match_first is
+ smaller than raw_mbs_idx.
+
+2002-11-06 Isamu Hasegawa <isamu@yamato.ibm.com>
+
+ * posix/regcomp (free_dfa_content): Use free_state.
+ * posix/regex_internal.c (re_string_realloc_buffers): Don't edit
+ pointers in case that realloc failed.
+ (re_node_set_merge): Likewise.
+ (register_state): Likewise.
+ (create_newstate_common): Invoke memory release functions in case of
+ error conditions.
+ (create_ci_newstate): Likewise.
+ (create_cd_newstate): Likewise.
+ (free_state): New function.
+ * posix/regexec.c (re_search_internal): Invoke memory release
+ functions in case of error conditions.
+ (sift_states_backward): Likewise.
+ (merge_state_array): Likewise.
+ (add_epsilon_src_nodes): Likewise.
+ (sub_epsilon_src_nodes): Likewise.
+ (search_subexp): Likewise.
+ (sift_states_bkref): Likewise.
+ (transit_state_sb): Likewise.
+ (transit_state_mb): Likewise.
+ (transit_state_bkref_loop): Likewise.
+ (group_nodes_into_DFAstates): Likewise.
+ (push_fail_stack): Don't edit pointers in case that realloc failed.
+ (extend_buffers): Likewise.
+ (match_ctx_add_entry): Likewise.
+
2002-11-06 Roland McGrath <roland@redhat.com>
* configure.in: Add checks on as and ld for binutils 2.13 or later.
diff --git a/posix/regcomp.c b/posix/regcomp.c
index 3cf07b17d4..03d5cfce14 100644
--- a/posix/regcomp.c
+++ b/posix/regcomp.c
@@ -267,10 +267,6 @@ re_compile_pattern (pattern, length, bufp)
{
reg_errcode_t ret;
- /* GNU code is written to assume at least RE_NREGS registers will be set
- (and at least one extra will be -1). */
- bufp->regs_allocated = REGS_UNALLOCATED;
-
/* And GNU code determines whether or not to get register information
by passing null for the REGS argument to re_match, etc., not by
setting no_sub. */
@@ -339,6 +335,14 @@ re_compile_fastmap (bufp)
weak_alias (__re_compile_fastmap, re_compile_fastmap)
#endif
+static inline void
+re_set_fastmap (char *fastmap, int icase, int ch)
+{
+ fastmap[ch] = 1;
+ if (icase)
+ fastmap[tolower (ch)] = 1;
+}
+
/* Helper function for re_compile_fastmap.
Compile fastmap for the initial_state INIT_STATE. */
@@ -350,20 +354,21 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
{
re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
int node_cnt;
+ int icase = (MB_CUR_MAX == 1 && (bufp->syntax & RE_ICASE));
for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
{
int node = init_state->nodes.elems[node_cnt];
re_token_type_t type = dfa->nodes[node].type;
if (type == CHARACTER)
- fastmap[dfa->nodes[node].opr.c] = 1;
+ re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
else if (type == SIMPLE_BRACKET)
{
int i, j, ch;
for (i = 0, ch = 0; i < BITSET_UINTS; ++i)
for (j = 0; j < UINT_BITS; ++j, ++ch)
if (dfa->nodes[node].opr.sbcset[i] & (1 << j))
- fastmap[ch] = 1;
+ re_set_fastmap (fastmap, icase, ch);
}
#ifdef RE_ENABLE_I18N
else if (type == COMPLEX_BRACKET)
@@ -388,28 +393,24 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
for (i = 0, ch = 0; i < BITSET_UINTS; ++i)
for (j = 0; j < UINT_BITS; ++j, ++ch)
if (table[ch] < 0)
- fastmap[ch] = 1;
+ re_set_fastmap (fastmap, icase, ch);
}
# else
if (MB_CUR_MAX > 1)
for (i = 0; i < SBC_MAX; ++i)
if (__btowc (i) == WEOF)
- fastmap[i] = 1;
+ re_set_fastmap (fastmap, icase, i);
# endif /* not _LIBC */
}
for (i = 0; i < cset->nmbchars; ++i)
{
char buf[256];
wctomb (buf, cset->mbchars[i]);
- fastmap[*(unsigned char *) buf] = 1;
+ re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
}
}
#endif /* RE_ENABLE_I18N */
- else if (type == END_OF_RE || type == OP_PERIOD
-#ifdef RE_ENABLE_I18N
- || type == COMPLEX_BRACKET
-#endif /* RE_ENABLE_I18N */
- )
+ else if (type == END_OF_RE || type == OP_PERIOD)
{
memset (fastmap, '\1', sizeof (char) * SBC_MAX);
if (type == END_OF_RE)
@@ -468,7 +469,6 @@ regcomp (preg, pattern, cflags)
preg->buffer = NULL;
preg->allocated = 0;
preg->used = 0;
- preg->can_be_null = 0;
/* Try to allocate space for the fastmap. */
preg->fastmap = re_malloc (char, SBC_MAX);
@@ -667,8 +667,7 @@ re_comp (s)
fastmap = re_comp_buf.fastmap;
re_comp_buf.fastmap = NULL;
__regfree (&re_comp_buf);
- re_comp_buf.buffer = NULL;
- re_comp_buf.allocated = 0;
+ memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
re_comp_buf.fastmap = fastmap;
}
@@ -725,6 +724,8 @@ re_compile_internal (preg, pattern, length, syntax)
preg->not_bol = preg->not_eol = 0;
preg->used = 0;
preg->re_nsub = 0;
+ preg->can_be_null = 0;
+ preg->regs_allocated = REGS_UNALLOCATED;
/* Initialize the dfa. */
dfa = (re_dfa_t *) preg->buffer;
diff --git a/posix/regex_internal.c b/posix/regex_internal.c
index 69fb9a65f5..74c8e8b7f6 100644
--- a/posix/regex_internal.c
+++ b/posix/regex_internal.c
@@ -63,25 +63,25 @@
#include "regex_internal.h"
static void re_string_construct_common (const char *str, int len,
- re_string_t *pstr,
- RE_TRANSLATE_TYPE trans, int icase);
+ re_string_t *pstr,
+ RE_TRANSLATE_TYPE trans, int icase);
#ifdef RE_ENABLE_I18N
static int re_string_skip_chars (re_string_t *pstr, int new_raw_idx);
#endif /* RE_ENABLE_I18N */
static re_dfastate_t *create_newstate_common (re_dfa_t *dfa,
- const re_node_set *nodes,
- unsigned int hash);
+ const re_node_set *nodes,
+ unsigned int hash);
static reg_errcode_t register_state (re_dfa_t *dfa, re_dfastate_t *newstate,
- unsigned int hash);
+ unsigned int hash);
static re_dfastate_t *create_ci_newstate (re_dfa_t *dfa,
- const re_node_set *nodes,
- unsigned int hash);
+ const re_node_set *nodes,
+ unsigned int hash);
static re_dfastate_t *create_cd_newstate (re_dfa_t *dfa,
- const re_node_set *nodes,
- unsigned int context,
- unsigned int hash);
+ const re_node_set *nodes,
+ unsigned int context,
+ unsigned int hash);
static unsigned int inline calc_state_hash (const re_node_set *nodes,
- unsigned int context);
+ unsigned int context);
/* Functions for string operation. */
@@ -105,10 +105,10 @@ re_string_allocate (pstr, str, len, init_len, trans, icase)
return ret;
pstr->mbs_case = (MBS_CASE_ALLOCATED (pstr) ? pstr->mbs_case
- : (unsigned char *) str);
+ : (unsigned char *) str);
pstr->mbs = MBS_ALLOCATED (pstr) ? pstr->mbs : pstr->mbs_case;
pstr->valid_len = (MBS_CASE_ALLOCATED (pstr) || MBS_ALLOCATED (pstr)
- || MB_CUR_MAX > 1) ? pstr->valid_len : len;
+ || MB_CUR_MAX > 1) ? pstr->valid_len : len;
return REG_NOERROR;
}
@@ -131,34 +131,34 @@ re_string_construct (pstr, str, len, trans, icase)
{
ret = re_string_realloc_buffers (pstr, len + 1);
if (BE (ret != REG_NOERROR, 0))
- return ret;
+ return ret;
}
pstr->mbs_case = (MBS_CASE_ALLOCATED (pstr) ? pstr->mbs_case
- : (unsigned char *) str);
+ : (unsigned char *) str);
pstr->mbs = MBS_ALLOCATED (pstr) ? pstr->mbs : pstr->mbs_case;
if (icase)
{
#ifdef RE_ENABLE_I18N
if (MB_CUR_MAX > 1)
- build_wcs_upper_buffer (pstr);
+ build_wcs_upper_buffer (pstr);
else
#endif /* RE_ENABLE_I18N */
- build_upper_buffer (pstr);
+ build_upper_buffer (pstr);
}
else
{
#ifdef RE_ENABLE_I18N
if (MB_CUR_MAX > 1)
- build_wcs_buffer (pstr);
+ build_wcs_buffer (pstr);
else
#endif /* RE_ENABLE_I18N */
- {
- if (trans != NULL)
- re_string_translate_buffer (pstr);
- else
- pstr->valid_len = len;
- }
+ {
+ if (trans != NULL)
+ re_string_translate_buffer (pstr);
+ else
+ pstr->valid_len = len;
+ }
}
/* Initialized whole buffers, then valid_len == bufs_len. */
@@ -176,24 +176,29 @@ re_string_realloc_buffers (pstr, new_buf_len)
#ifdef RE_ENABLE_I18N
if (MB_CUR_MAX > 1)
{
- pstr->wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
- if (BE (pstr->wcs == NULL, 0))
- return REG_ESPACE;
+ wint_t *new_array = re_realloc (pstr->wcs, wint_t, new_buf_len);
+ if (BE (new_array == NULL, 0))
+ return REG_ESPACE;
+ pstr->wcs = new_array;
}
#endif /* RE_ENABLE_I18N */
if (MBS_ALLOCATED (pstr))
{
- pstr->mbs = re_realloc (pstr->mbs, unsigned char, new_buf_len);
- if (BE (pstr->mbs == NULL, 0))
- return REG_ESPACE;
+ unsigned char *new_array = re_realloc (pstr->mbs, unsigned char,
+ new_buf_len);
+ if (BE (new_array == NULL, 0))
+ return REG_ESPACE;
+ pstr->mbs = new_array;
}
if (MBS_CASE_ALLOCATED (pstr))
{
- pstr->mbs_case = re_realloc (pstr->mbs_case, unsigned char, new_buf_len);
- if (BE (pstr->mbs_case == NULL, 0))
- return REG_ESPACE;
+ unsigned char *new_array = re_realloc (pstr->mbs_case, unsigned char,
+ new_buf_len);
+ if (BE (new_array == NULL, 0))
+ return REG_ESPACE;
+ pstr->mbs_case = new_array;
if (!MBS_ALLOCATED (pstr))
- pstr->mbs = pstr->mbs_case;
+ pstr->mbs = pstr->mbs_case;
}
pstr->bufs_len = new_buf_len;
return REG_NOERROR;
@@ -243,32 +248,32 @@ build_wcs_buffer (pstr)
remain_len = end_idx - byte_idx;
prev_st = pstr->cur_state;
mbclen = mbrtowc (&wc, ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
- + byte_idx), remain_len, &pstr->cur_state);
+ + byte_idx), remain_len, &pstr->cur_state);
if (BE (mbclen == (size_t) -2, 0))
- {
- /* The buffer doesn't have enough space, finish to build. */
- pstr->cur_state = prev_st;
- break;
- }
+ {
+ /* The buffer doesn't have enough space, finish to build. */
+ pstr->cur_state = prev_st;
+ break;
+ }
else if (BE (mbclen == (size_t) -1 || mbclen == 0, 0))
- {
- /* We treat these cases as a singlebyte character. */
- mbclen = 1;
- wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
- pstr->cur_state = prev_st;
- }
+ {
+ /* We treat these cases as a singlebyte character. */
+ mbclen = 1;
+ wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
+ pstr->cur_state = prev_st;
+ }
/* Apply the translateion if we need. */
if (pstr->trans != NULL && mbclen == 1)
- {
- int ch = pstr->trans[pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]];
- pstr->mbs_case[byte_idx] = ch;
- }
+ {
+ int ch = pstr->trans[pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]];
+ pstr->mbs_case[byte_idx] = ch;
+ }
/* Write wide character and padding. */
pstr->wcs[byte_idx++] = wc;
/* Write paddings. */
for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
- pstr->wcs[byte_idx++] = WEOF;
+ pstr->wcs[byte_idx++] = WEOF;
}
pstr->valid_len = byte_idx;
}
@@ -291,40 +296,40 @@ build_wcs_upper_buffer (pstr)
remain_len = end_idx - byte_idx;
prev_st = pstr->cur_state;
mbclen = mbrtowc (&wc, ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
- + byte_idx), remain_len, &pstr->cur_state);
+ + byte_idx), remain_len, &pstr->cur_state);
if (BE (mbclen == (size_t) -2, 0))
- {
- /* The buffer doesn't have enough space, finish to build. */
- pstr->cur_state = prev_st;
- break;
- }
+ {
+ /* The buffer doesn't have enough space, finish to build. */
+ pstr->cur_state = prev_st;
+ break;
+ }
else if (mbclen == 1 || mbclen == (size_t) -1 || mbclen == 0)
- {
- /* In case of a singlebyte character. */
- int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
- /* Apply the translateion if we need. */
- if (pstr->trans != NULL && mbclen == 1)
- {
- ch = pstr->trans[ch];
- pstr->mbs_case[byte_idx] = ch;
- }
- pstr->wcs[byte_idx] = iswlower (wc) ? toupper (wc) : wc;
- pstr->mbs[byte_idx++] = islower (ch) ? toupper (ch) : ch;
- if (BE (mbclen == (size_t) -1, 0))
- pstr->cur_state = prev_st;
- }
+ {
+ /* In case of a singlebyte character. */
+ int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
+ /* Apply the translateion if we need. */
+ if (pstr->trans != NULL && mbclen == 1)
+ {
+ ch = pstr->trans[ch];
+ pstr->mbs_case[byte_idx] = ch;
+ }
+ pstr->wcs[byte_idx] = iswlower (wc) ? toupper (wc) : wc;
+ pstr->mbs[byte_idx++] = islower (ch) ? toupper (ch) : ch;
+ if (BE (mbclen == (size_t) -1, 0))
+ pstr->cur_state = prev_st;
+ }
else /* mbclen > 1 */
- {
- if (iswlower (wc))
- wcrtomb ((char *) pstr->mbs + byte_idx, towupper (wc), &prev_st);
- else
- memcpy (pstr->mbs + byte_idx,
- pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen);
- pstr->wcs[byte_idx++] = iswlower (wc) ? toupper (wc) : wc;
- /* Write paddings. */
- for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
- pstr->wcs[byte_idx++] = WEOF;
- }
+ {
+ if (iswlower (wc))
+ wcrtomb ((char *) pstr->mbs + byte_idx, towupper (wc), &prev_st);
+ else
+ memcpy (pstr->mbs + byte_idx,
+ pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen);
+ pstr->wcs[byte_idx++] = iswlower (wc) ? toupper (wc) : wc;
+ /* Write paddings. */
+ for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
+ pstr->wcs[byte_idx++] = WEOF;
+ }
}
pstr->valid_len = byte_idx;
}
@@ -347,13 +352,13 @@ re_string_skip_chars (pstr, new_raw_idx)
int remain_len = pstr->len - rawbuf_idx;
prev_st = pstr->cur_state;
mbclen = mbrlen ((const char *) pstr->raw_mbs + rawbuf_idx, remain_len,
- &pstr->cur_state);
+ &pstr->cur_state);
if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
- {
- /* We treat these cases as a singlebyte character. */
- mbclen = 1;
- pstr->cur_state = prev_st;
- }
+ {
+ /* We treat these cases as a singlebyte character. */
+ mbclen = 1;
+ pstr->cur_state = prev_st;
+ }
/* Then proceed the next character. */
rawbuf_idx += mbclen;
}
@@ -361,7 +366,7 @@ re_string_skip_chars (pstr, new_raw_idx)
}
#endif /* RE_ENABLE_I18N */
-/* Build the buffer PSTR->MBS, and apply the translation if we need.
+/* Build the buffer PSTR->MBS, and apply the translation if we need.
This function is used in case of REG_ICASE. */
static void
@@ -375,14 +380,14 @@ build_upper_buffer (pstr)
{
int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
if (pstr->trans != NULL)
- {
- ch = pstr->trans[ch];
- pstr->mbs_case[char_idx] = ch;
- }
+ {
+ ch = pstr->trans[ch];
+ pstr->mbs_case[char_idx] = ch;
+ }
if (islower (ch))
- pstr->mbs[char_idx] = toupper (ch);
+ pstr->mbs[char_idx] = toupper (ch);
else
- pstr->mbs[char_idx] = ch;
+ pstr->mbs[char_idx] = ch;
}
pstr->valid_len = char_idx;
}
@@ -420,65 +425,65 @@ re_string_reconstruct (pstr, idx, eflags, newline)
/* Reset buffer. */
#ifdef RE_ENABLE_I18N
if (MB_CUR_MAX > 1)
- memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
+ memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
#endif /* RE_ENABLE_I18N */
pstr->len += pstr->raw_mbs_idx;
pstr->stop += pstr->raw_mbs_idx;
pstr->valid_len = pstr->raw_mbs_idx = 0;
pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
- : CONTEXT_NEWLINE | CONTEXT_BEGBUF);
+ : CONTEXT_NEWLINE | CONTEXT_BEGBUF);
if (!MBS_CASE_ALLOCATED (pstr))
- pstr->mbs_case = (unsigned char *) pstr->raw_mbs;
+ pstr->mbs_case = (unsigned char *) pstr->raw_mbs;
if (!MBS_ALLOCATED (pstr) && !MBS_CASE_ALLOCATED (pstr))
- pstr->mbs = (unsigned char *) pstr->raw_mbs;
+ pstr->mbs = (unsigned char *) pstr->raw_mbs;
offset = idx;
}
if (offset != 0)
{
pstr->tip_context = re_string_context_at (pstr, offset - 1, eflags,
- newline);
+ newline);
/* Are the characters which are already checked remain? */
if (offset < pstr->valid_len)
- {
- /* Yes, move them to the front of the buffer. */
+ {
+ /* Yes, move them to the front of the buffer. */
#ifdef RE_ENABLE_I18N
- if (MB_CUR_MAX > 1)
- memmove (pstr->wcs, pstr->wcs + offset,
- (pstr->valid_len - offset) * sizeof (wint_t));
+ if (MB_CUR_MAX > 1)
+ memmove (pstr->wcs, pstr->wcs + offset,
+ (pstr->valid_len - offset) * sizeof (wint_t));
#endif /* RE_ENABLE_I18N */
- if (MBS_ALLOCATED (pstr))
- memmove (pstr->mbs, pstr->mbs + offset,
- pstr->valid_len - offset);
- if (MBS_CASE_ALLOCATED (pstr))
- memmove (pstr->mbs_case, pstr->mbs_case + offset,
- pstr->valid_len - offset);
- pstr->valid_len -= offset;
+ if (MBS_ALLOCATED (pstr))
+ memmove (pstr->mbs, pstr->mbs + offset,
+ pstr->valid_len - offset);
+ if (MBS_CASE_ALLOCATED (pstr))
+ memmove (pstr->mbs_case, pstr->mbs_case + offset,
+ pstr->valid_len - offset);
+ pstr->valid_len -= offset;
#if DEBUG
- assert (pstr->valid_len > 0);
+ assert (pstr->valid_len > 0);
#endif
- }
+ }
else
- {
- /* No, skip all characters until IDX. */
- pstr->valid_len = 0;
+ {
+ /* No, skip all characters until IDX. */
+ pstr->valid_len = 0;
#ifdef RE_ENABLE_I18N
- if (MB_CUR_MAX > 1)
- {
- int wcs_idx;
- pstr->valid_len = re_string_skip_chars (pstr, idx) - idx;
- for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
- pstr->wcs[wcs_idx] = WEOF;
- }
+ if (MB_CUR_MAX > 1)
+ {
+ int wcs_idx;
+ pstr->valid_len = re_string_skip_chars (pstr, idx) - idx;
+ for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
+ pstr->wcs[wcs_idx] = WEOF;
+ }
#endif /* RE_ENABLE_I18N */
- }
+ }
if (!MBS_CASE_ALLOCATED (pstr))
- {
- pstr->mbs_case += offset;
- /* In case of !MBS_ALLOCATED && !MBS_CASE_ALLOCATED. */
- if (!MBS_ALLOCATED (pstr))
- pstr->mbs += offset;
- }
+ {
+ pstr->mbs_case += offset;
+ /* In case of !MBS_ALLOCATED && !MBS_CASE_ALLOCATED. */
+ if (!MBS_ALLOCATED (pstr))
+ pstr->mbs += offset;
+ }
}
pstr->raw_mbs_idx = idx;
pstr->len -= offset;
@@ -489,17 +494,17 @@ re_string_reconstruct (pstr, idx, eflags, newline)
if (MB_CUR_MAX > 1)
{
if (pstr->icase)
- build_wcs_upper_buffer (pstr);
+ build_wcs_upper_buffer (pstr);
else
- build_wcs_buffer (pstr);
+ build_wcs_buffer (pstr);
}
else
#endif /* RE_ENABLE_I18N */
{
if (pstr->icase)
- build_upper_buffer (pstr);
+ build_upper_buffer (pstr);
else if (pstr->trans != NULL)
- re_string_translate_buffer (pstr);
+ re_string_translate_buffer (pstr);
}
pstr->cur_idx = 0;
@@ -530,12 +535,12 @@ re_string_context_at (input, idx, eflags, newline_anchor)
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;
+ /* 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);
+ return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
+ : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
}
c = re_string_byte_at (input, idx);
if (IS_WORD_CHAR (c))
@@ -590,15 +595,15 @@ re_node_set_init_2 (set, elem1, elem2)
{