re_charset_t *mbcset,
int *equiv_class_alloc,
const unsigned char *name);
-static reg_errcode_t build_charclass (unsigned RE_TRANSLATE_TYPE trans,
+static reg_errcode_t build_charclass (unsigned REG_TRANSLATE_TYPE trans,
re_bitset_ptr_t sbcset,
re_charset_t *mbcset,
int *char_class_alloc,
#else /* not RE_ENABLE_I18N */
static reg_errcode_t build_equiv_class (re_bitset_ptr_t sbcset,
const unsigned char *name);
-static reg_errcode_t build_charclass (unsigned RE_TRANSLATE_TYPE trans,
+static reg_errcode_t build_charclass (unsigned REG_TRANSLATE_TYPE trans,
re_bitset_ptr_t sbcset,
const unsigned char *class_name,
reg_syntax_t syntax);
#endif /* not RE_ENABLE_I18N */
static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
- unsigned RE_TRANSLATE_TYPE trans,
+ unsigned REG_TRANSLATE_TYPE trans,
const unsigned char *class_name,
const unsigned char *extra,
int non_match, reg_errcode_t *err);
compiles PATTERN (of length LENGTH) and puts the result in BUFP.
Returns 0 if the pattern was valid, otherwise an error string.
- Assumes the `allocated' (and perhaps `buffer') and `translate' fields
+ Assumes the `re_allocated' (and perhaps `re_buffer') and `translate' fields
are set in BUFP on entry. */
const char *
/* 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, unless RE_NO_SUB is set. */
- bufp->no_sub = !!(re_syntax_options & RE_NO_SUB);
+ setting re_no_sub, unless REG_NO_SUB is set. */
+ bufp->re_no_sub = !!(re_syntax_options & REG_NO_SUB);
/* Match anchors at newline. */
- bufp->newline_anchor = 1;
+ bufp->re_newline_anchor = 1;
ret = re_compile_internal (bufp, pattern, length, re_syntax_options);
int
re_compile_fastmap (struct re_pattern_buffer *bufp)
{
- re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
- char *fastmap = bufp->fastmap;
+ re_dfa_t *dfa = (re_dfa_t *) bufp->re_buffer;
+ char *fastmap = bufp->re_fastmap;
memset (fastmap, '\0', sizeof (char) * SBC_MAX);
re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
if (dfa->init_state != dfa->init_state_begbuf)
re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
- bufp->fastmap_accurate = 1;
+ bufp->re_fastmap_accurate = 1;
return 0;
}
#ifdef _LIBC
re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
char *fastmap)
{
- re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) bufp->re_buffer;
int node_cnt;
- int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
+ int icase = (dfa->mb_cur_max == 1 && (bufp->re_syntax & REG_IGNORE_CASE));
for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
{
int node = init_state->nodes.elems[node_cnt];
{
re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
#ifdef RE_ENABLE_I18N
- if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+ if ((bufp->re_syntax & REG_IGNORE_CASE) && dfa->mb_cur_max > 1)
{
unsigned char *buf = alloca (dfa->mb_cur_max), *p;
wchar_t wc;
memset (&state, '\0', sizeof (state));
if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
- if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+ if ((bufp->re_syntax & REG_IGNORE_CASE) && dfa->mb_cur_max > 1)
{
if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
!= (size_t) -1)
{
memset (fastmap, '\1', sizeof (char) * SBC_MAX);
if (type == END_OF_RE)
- bufp->can_be_null = 1;
+ bufp->re_can_be_null = 1;
return;
}
}
PREG is a regex_t *. We do not expect any fields to be initialized,
since POSIX says we shouldn't. Thus, we set
- `buffer' to the compiled pattern;
- `used' to the length of the compiled pattern;
- `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
+ `re_buffer' to the compiled pattern;
+ `re_used' to the length of the compiled pattern;
+ `re_syntax' to REG_SYNTAX_POSIX_EXTENDED if the
REG_EXTENDED bit in CFLAGS is set; otherwise, to
- RE_SYNTAX_POSIX_BASIC;
- `newline_anchor' to REG_NEWLINE being set in CFLAGS;
- `fastmap' to an allocated space for the fastmap;
- `fastmap_accurate' to zero;
+ REG_SYNTAX_POSIX_BASIC;
+ `re_newline_anchor' to REG_NEWLINE being set in CFLAGS;
+ `re_fastmap' to an allocated space for the fastmap;
+ `re_fastmap_accurate' to zero;
`re_nsub' to the number of subexpressions in PATTERN.
PATTERN is the address of the pattern string.
regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
{
reg_errcode_t ret;
- reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
- : RE_SYNTAX_POSIX_BASIC);
+ reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? REG_SYNTAX_POSIX_EXTENDED
+ : REG_SYNTAX_POSIX_BASIC);
- preg->buffer = NULL;
- preg->allocated = 0;
- preg->used = 0;
+ preg->re_buffer = NULL;
+ preg->re_allocated = 0;
+ preg->re_used = 0;
/* Try to allocate space for the fastmap. */
- preg->fastmap = re_malloc (char, SBC_MAX);
- if (BE (preg->fastmap == NULL, 0))
+ preg->re_fastmap = re_malloc (char, SBC_MAX);
+ if (BE (preg->re_fastmap == NULL, 0))
return REG_ESPACE;
- syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
+ syntax |= (cflags & REG_ICASE) ? REG_IGNORE_CASE : 0;
/* If REG_NEWLINE is set, newlines are treated differently. */
if (cflags & REG_NEWLINE)
{ /* REG_NEWLINE implies neither . nor [^...] match newline. */
- syntax &= ~RE_DOT_NEWLINE;
- syntax |= RE_HAT_LISTS_NOT_NEWLINE;
+ syntax &= ~REG_DOT_NEWLINE;
+ syntax |= REG_HAT_LISTS_NOT_NEWLINE;
/* It also changes the matching behavior. */
- preg->newline_anchor = 1;
+ preg->re_newline_anchor = 1;
}
else
- preg->newline_anchor = 0;
- preg->no_sub = !!(cflags & REG_NOSUB);
- preg->translate = NULL;
+ preg->re_newline_anchor = 0;
+ preg->re_no_sub = !!(cflags & REG_NOSUB);
+ preg->re_translate = NULL;
ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);
if (ret == REG_ERPAREN)
ret = REG_EPAREN;
- /* We have already checked preg->fastmap != NULL. */
+ /* We have already checked preg->re_fastmap != NULL. */
if (BE (ret == REG_NOERROR, 1))
/* Compute the fastmap now, since regexec cannot modify the pattern
buffer. This function never fails in this implementation. */
else
{
/* Some error occurred while compiling the expression. */
- re_free (preg->fastmap);
- preg->fastmap = NULL;
+ re_free (preg->re_fastmap);
+ preg->re_fastmap = NULL;
}
return (int) ret;
void
regfree (regex_t *preg)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
if (BE (dfa != NULL, 1))
free_dfa_content (dfa);
- preg->buffer = NULL;
- preg->allocated = 0;
+ preg->re_buffer = NULL;
+ preg->re_allocated = 0;
- re_free (preg->fastmap);
- preg->fastmap = NULL;
+ re_free (preg->re_fastmap);
+ preg->re_fastmap = NULL;
- re_free (preg->translate);
- preg->translate = NULL;
+ re_free (preg->re_translate);
+ preg->re_translate = NULL;
}
#ifdef _LIBC
weak_alias (__regfree, regfree)
if (!s)
{
- if (!re_comp_buf.buffer)
+ if (!re_comp_buf.re_buffer)
return gettext ("No previous regular expression");
return 0;
}
- if (re_comp_buf.buffer)
+ if (re_comp_buf.re_buffer)
{
- fastmap = re_comp_buf.fastmap;
- re_comp_buf.fastmap = NULL;
+ fastmap = re_comp_buf.re_fastmap;
+ re_comp_buf.re_fastmap = NULL;
__regfree (&re_comp_buf);
memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
- re_comp_buf.fastmap = fastmap;
+ re_comp_buf.re_fastmap = fastmap;
}
- if (re_comp_buf.fastmap == NULL)
+ if (re_comp_buf.re_fastmap == NULL)
{
- re_comp_buf.fastmap = (char *) malloc (SBC_MAX);
- if (re_comp_buf.fastmap == NULL)
+ re_comp_buf.re_fastmap = (char *) malloc (SBC_MAX);
+ if (re_comp_buf.re_fastmap == NULL)
return (char *) gettext (__re_error_msgid
+ __re_error_msgid_idx[(int) REG_ESPACE]);
}
don't need to initialize the pattern buffer fields which affect it. */
/* Match anchors at newlines. */
- re_comp_buf.newline_anchor = 1;
+ re_comp_buf.re_newline_anchor = 1;
ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
re_string_t regexp;
/* Initialize the pattern buffer. */
- preg->fastmap_accurate = 0;
- preg->syntax = syntax;
- preg->not_bol = preg->not_eol = 0;
- preg->used = 0;
+ preg->re_fastmap_accurate = 0;
+ preg->re_syntax = syntax;
+ preg->re_not_bol = preg->re_not_eol = 0;
+ preg->re_used = 0;
preg->re_nsub = 0;
- preg->can_be_null = 0;
- preg->regs_allocated = REGS_UNALLOCATED;
+ preg->re_can_be_null = 0;
+ preg->re_regs_allocated = REG_UNALLOCATED;
/* Initialize the dfa. */
- dfa = (re_dfa_t *) preg->buffer;
- if (BE (preg->allocated < sizeof (re_dfa_t), 0))
+ dfa = (re_dfa_t *) preg->re_buffer;
+ if (BE (preg->re_allocated < sizeof (re_dfa_t), 0))
{
/* If zero allocated, but buffer is non-null, try to realloc
enough space. This loses if buffer's address is bogus, but
- that is the user's responsibility. If ->buffer is NULL this
+ that is the user's responsibility. If buffer is null this
is a simple allocation. */
- dfa = re_realloc (preg->buffer, re_dfa_t, 1);
+ dfa = re_realloc (preg->re_buffer, re_dfa_t, 1);
if (dfa == NULL)
return REG_ESPACE;
- preg->allocated = sizeof (re_dfa_t);
- preg->buffer = (unsigned char *) dfa;
+ preg->re_allocated = sizeof (re_dfa_t);
+ preg->re_buffer = (unsigned char *) dfa;
}
- preg->used = sizeof (re_dfa_t);
+ preg->re_used = sizeof (re_dfa_t);
__libc_lock_init (dfa->lock);
if (BE (err != REG_NOERROR, 0))
{
free_dfa_content (dfa);
- preg->buffer = NULL;
- preg->allocated = 0;
+ preg->re_buffer = NULL;
+ preg->re_allocated = 0;
return err;
}
#ifdef DEBUG
strncpy (dfa->re_str, pattern, length + 1);
#endif
- err = re_string_construct (®exp, pattern, length, preg->translate,
- syntax & RE_ICASE, dfa);
+ err = re_string_construct (®exp, pattern, length, preg->re_translate,
+ syntax & REG_IGNORE_CASE, dfa);
if (BE (err != REG_NOERROR, 0))
{
re_compile_internal_free_return:
free_workarea_compile (preg);
re_string_destruct (®exp);
free_dfa_content (dfa);
- preg->buffer = NULL;
- preg->allocated = 0;
+ preg->re_buffer = NULL;
+ preg->re_allocated = 0;
return err;
}
#ifdef RE_ENABLE_I18N
/* If possible, do searching in single byte encoding to speed things up. */
- if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
+ if (dfa->is_utf8 && !(syntax & REG_IGNORE_CASE) && preg->re_translate == NULL)
optimize_utf8 (dfa);
#endif
if (BE (err != REG_NOERROR, 0))
{
free_dfa_content (dfa);
- preg->buffer = NULL;
- preg->allocated = 0;
+ preg->re_buffer = NULL;
+ preg->re_allocated = 0;
}
return err;
static void
free_workarea_compile (regex_t *preg)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
bin_tree_storage_t *storage, *next;
for (storage = dfa->str_tree_storage; storage; storage = next)
{
static reg_errcode_t
analyze (regex_t *preg)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
reg_errcode_t ret;
/* Allocate arrays. */
/* We only need this during the prune_impossible_nodes pass in regexec.c;
skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */
- if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
+ if ((!preg->re_no_sub && preg->re_nsub > 0 && dfa->has_plural_match)
|| dfa->nbackref)
{
dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
static bin_tree_t *
lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
bin_tree_t *body = node->left;
bin_tree_t *op, *cls, *tree1, *tree;
- if (preg->no_sub
+ if (preg->re_no_sub
/* We do not optimize empty subexpressions, because otherwise we may
have bad CONCAT nodes with NULL children. This is obviously not
very common, so we do not lose much. An example that triggers
switch (c2)
{
case '|':
- if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR))
+ if (!(syntax & REG_LIMITED_OPS) && !(syntax & REG_NO_BK_VBAR))
token->type = OP_ALT;
break;
case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
- if (!(syntax & RE_NO_BK_REFS))
+ if (!(syntax & REG_NO_BK_REFS))
{
token->type = OP_BACK_REF;
token->opr.idx = c2 - '1';
}
break;
case '<':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
{
token->type = ANCHOR;
token->opr.ctx_type = WORD_FIRST;
}
break;
case '>':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
{
token->type = ANCHOR;
token->opr.ctx_type = WORD_LAST;
}
break;
case 'b':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
{
token->type = ANCHOR;
token->opr.ctx_type = WORD_DELIM;
}
break;
case 'B':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
{
token->type = ANCHOR;
token->opr.ctx_type = NOT_WORD_DELIM;
}
break;
case 'w':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
token->type = OP_WORD;
break;
case 'W':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
token->type = OP_NOTWORD;
break;
case 's':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
token->type = OP_SPACE;
break;
case 'S':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
token->type = OP_NOTSPACE;
break;
case '`':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
{
token->type = ANCHOR;
token->opr.ctx_type = BUF_FIRST;
}
break;
case '\'':
- if (!(syntax & RE_NO_GNU_OPS))
+ if (!(syntax & REG_NO_GNU_OPS))
{
token->type = ANCHOR;
token->opr.ctx_type = BUF_LAST;
}
break;
case '(':
- if (!(syntax & RE_NO_BK_PARENS))
+ if (!(syntax & REG_NO_BK_PARENS))
token->type = OP_OPEN_SUBEXP;
break;
case ')':
- if (!(syntax & RE_NO_BK_PARENS))
+ if (!(syntax & REG_NO_BK_PARENS))
token->type = OP_CLOSE_SUBEXP;
break;
case '+':
- if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+ if (!(syntax & REG_LIMITED_OPS) && (syntax & REG_BK_PLUS_QM))
token->type = OP_DUP_PLUS;
break;
case '?':
- if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM))
+ if (!(syntax & REG_LIMITED_OPS) && (syntax & REG_BK_PLUS_QM))
token->type = OP_DUP_QUESTION;
break;
case '{':
- if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+ if ((syntax & REG_INTERVALS) && (!(syntax & REG_NO_BK_BRACES)))
token->type = OP_OPEN_DUP_NUM;
break;
case '}':
- if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES)))
+ if ((syntax & REG_INTERVALS) && (!(syntax & REG_NO_BK_BRACES)))
token->type = OP_CLOSE_DUP_NUM;
break;
default:
switch (c)
{
case '\n':
- if (syntax & RE_NEWLINE_ALT)
+ if (syntax & REG_NEWLINE_ALT)
token->type = OP_ALT;
break;
case '|':
- if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR))
+ if (!(syntax & REG_LIMITED_OPS) && (syntax & REG_NO_BK_VBAR))
token->type = OP_ALT;
break;
case '*':
token->type = OP_DUP_ASTERISK;
break;
case '+':
- if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+ if (!(syntax & REG_LIMITED_OPS) && !(syntax & REG_BK_PLUS_QM))
token->type = OP_DUP_PLUS;
break;
case '?':
- if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM))
+ if (!(syntax & REG_LIMITED_OPS) && !(syntax & REG_BK_PLUS_QM))
token->type = OP_DUP_QUESTION;
break;
case '{':
- if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+ if ((syntax & REG_INTERVALS) && (syntax & REG_NO_BK_BRACES))
token->type = OP_OPEN_DUP_NUM;
break;
case '}':
- if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+ if ((syntax & REG_INTERVALS) && (syntax & REG_NO_BK_BRACES))
token->type = OP_CLOSE_DUP_NUM;
break;
case '(':
- if (syntax & RE_NO_BK_PARENS)
+ if (syntax & REG_NO_BK_PARENS)
token->type = OP_OPEN_SUBEXP;
break;
case ')':
- if (syntax & RE_NO_BK_PARENS)
+ if (syntax & REG_NO_BK_PARENS)
token->type = OP_CLOSE_SUBEXP;
break;
case '[':
token->type = OP_PERIOD;
break;
case '^':
- if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) &&
+ if (!(syntax & (REG_CONTEXT_INDEP_ANCHORS | REG_CARET_ANCHORS_HERE)) &&
re_string_cur_idx (input) != 0)
{
char prev = re_string_peek_byte (input, -1);
- if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
+ if (!(syntax & REG_NEWLINE_ALT) || prev != '\n')
break;
}
token->type = ANCHOR;
token->opr.ctx_type = LINE_FIRST;
break;
case '$':
- if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) &&
+ if (!(syntax & REG_CONTEXT_INDEP_ANCHORS) &&
re_string_cur_idx (input) + 1 != re_string_length (input))
{
re_token_t next;
}
#endif /* RE_ENABLE_I18N */
- if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
+ if (c == '\\' && (syntax & REG_BACKSLASH_ESCAPE_IN_LISTS)
&& re_string_cur_idx (input) + 1 < re_string_length (input))
{
/* In this case, '\' escape a character. */
token->type = OP_OPEN_EQUIV_CLASS;
break;
case ':':
- if (syntax & RE_CHAR_CLASSES)
+ if (syntax & REG_CHAR_CLASSES)
{
token->type = OP_OPEN_CHAR_CLASS;
break;
parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
reg_errcode_t *err)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
bin_tree_t *tree, *eor, *root;
re_token_t current_token;
dfa->syntax = syntax;
- fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+ fetch_token (¤t_token, regexp, syntax | REG_CARET_ANCHORS_HERE);
tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
reg_syntax_t syntax, int nest, reg_errcode_t *err)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
bin_tree_t *tree, *branch = NULL;
tree = parse_branch (regexp, preg, token, syntax, nest, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
while (token->type == OP_ALT)
{
- fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+ fetch_token (token, regexp, syntax | REG_CARET_ANCHORS_HERE);
if (token->type != OP_ALT && token->type != END_OF_RE
&& (nest == 0 || token->type != OP_CLOSE_SUBEXP))
{
reg_syntax_t syntax, int nest, reg_errcode_t *err)
{
bin_tree_t *tree, *exp;
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
tree = parse_expression (regexp, preg, token, syntax, nest, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
reg_syntax_t syntax, int nest, reg_errcode_t *err)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
bin_tree_t *tree;
switch (token->type)
{
dfa->has_mb_node = 1;
break;
case OP_OPEN_DUP_NUM:
- if (syntax & RE_CONTEXT_INVALID_DUP)
+ if (syntax & REG_CONTEXT_INVALID_DUP)
{
*err = REG_BADRPT;
return NULL;
case OP_DUP_ASTERISK:
case OP_DUP_PLUS:
case OP_DUP_QUESTION:
- if (syntax & RE_CONTEXT_INVALID_OPS)
+ if (syntax & REG_CONTEXT_INVALID_OPS)
{
*err = REG_BADRPT;
return NULL;
}
- else if (syntax & RE_CONTEXT_INDEP_OPS)
+ else if (syntax & REG_CONTEXT_INDEP_OPS)
{
fetch_token (token, regexp, syntax);
return parse_expression (regexp, preg, token, syntax, nest, err);
/* else fall through */
case OP_CLOSE_SUBEXP:
if ((token->type == OP_CLOSE_SUBEXP) &&
- !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
+ !(syntax & REG_UNMATCHED_RIGHT_PAREN_ORD))
{
*err = REG_ERPAREN;
return NULL;
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
/* In BRE consecutive duplications are not allowed. */
- if ((syntax & RE_CONTEXT_INVALID_DUP)
+ if ((syntax & REG_CONTEXT_INVALID_DUP)
&& (token->type == OP_DUP_ASTERISK
|| token->type == OP_OPEN_DUP_NUM))
{
parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
reg_syntax_t syntax, int nest, reg_errcode_t *err)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
bin_tree_t *tree;
size_t cur_nsub;
cur_nsub = preg->re_nsub++;
- fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
+ fetch_token (token, regexp, syntax | REG_CARET_ANCHORS_HERE);
/* The subexpression may be a null string. */
if (token->type == OP_CLOSE_SUBEXP)
if (BE (start == -2 || end == -2, 0))
{
/* Invalid sequence. */
- if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0))
+ if (BE (!(syntax & REG_INVALID_INTERVAL_ORD), 0))
{
if (token->type == END_OF_RE)
*err = REG_EBRACE;
/* Check start/end collation sequence values. */
if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0))
return REG_ECOLLATE;
- if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
+ if (BE ((syntax & REG_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
return REG_ERANGE;
/* Got valid collation sequence values, add them as a new entry.
mbcset->non_match = 1;
#endif /* not RE_ENABLE_I18N */
non_match = 1;
- if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
+ if (syntax & REG_HAT_LISTS_NOT_NEWLINE)
bitset_set (sbcset, '\0');
re_string_skip_bytes (regexp, token_len); /* Skip a token. */
token_len = peek_token_bracket (token, regexp, syntax);
is a pointer argument sinse we may update it. */
static reg_errcode_t
-build_charclass (unsigned RE_TRANSLATE_TYPE trans, re_bitset_ptr_t sbcset,
+build_charclass (unsigned REG_TRANSLATE_TYPE trans, re_bitset_ptr_t sbcset,
#ifdef RE_ENABLE_I18N
re_charset_t *mbcset, int *char_class_alloc,
#endif
/* In case of REG_ICASE "upper" and "lower" match the both of
upper and lower cases. */
- if ((syntax & RE_ICASE)
+ if ((syntax & REG_IGNORE_CASE)
&& (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
name = "alpha";
}
static bin_tree_t *
-build_charclass_op (re_dfa_t *dfa, unsigned RE_TRANSLATE_TYPE trans,
+build_charclass_op (re_dfa_t *dfa, unsigned REG_TRANSLATE_TYPE trans,
const unsigned char *class_name,
const unsigned char *extra,
int non_match, reg_errcode_t *err)
{
#ifdef RE_ENABLE_I18N
/*
- if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
+ if (syntax & REG_HAT_LISTS_NOT_NEWLINE)
bitset_set(cset->sbcset, '\0');
*/
mbcset->non_match = 1;
break;
num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
? -2 : ((num == -1) ? c - '0' : num * 10 + c - '0'));
- num = (num > RE_DUP_MAX) ? -2 : num;
+ num = (num > REG_DUP_MAX) ? -2 : num;
}
return num;
}
reg_errcode_t err;
int start, length;
#ifdef _LIBC
- re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
#endif
if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
}
__libc_lock_lock (dfa->lock);
- if (preg->no_sub)
+ if (preg->re_no_sub)
err = re_search_internal (preg, string, length, start, length - start,
length, 0, NULL, eflags);
else
the first STOP characters of the concatenation of the strings should be
concerned.
- If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match
+ If REGS is not NULL, and BUFP->re_no_sub is not set, the offsets of the match
and all groups is stroed in REGS. (For the "_2" variants, the offsets are
computed relative to the concatenation, not relative to the individual
strings.)
int nregs, rval;
int eflags = 0;
#ifdef _LIBC
- re_dfa_t *dfa = (re_dfa_t *)bufp->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) bufp->re_buffer;
#endif
/* Check for out-of-range. */
__libc_lock_lock (dfa->lock);
- eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
- eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
+ eflags |= (bufp->re_not_bol) ? REG_NOTBOL : 0;
+ eflags |= (bufp->re_not_eol) ? REG_NOTEOL : 0;
/* Compile fastmap if we haven't yet. */
- if (range > 0 && bufp->fastmap != NULL && !bufp->fastmap_accurate)
+ if (range > 0 && bufp->re_fastmap != NULL && !bufp->re_fastmap_accurate)
re_compile_fastmap (bufp);
- if (BE (bufp->no_sub, 0))
+ if (BE (bufp->re_no_sub, 0))
regs = NULL;
/* We need at least 1 register. */
if (regs == NULL)
nregs = 1;
- else if (BE (bufp->regs_allocated == REGS_FIXED &&
- regs->num_regs < bufp->re_nsub + 1, 0))
+ else if (BE (bufp->re_regs_allocated == REG_FIXED
+ && regs->rm_num_regs < bufp->re_nsub + 1, 0))
{
- nregs = regs->num_regs;
+ nregs = regs->rm_num_regs;
if (BE (nregs < 1, 0))
{
/* Nothing can be copied to regs. */
else if (regs != NULL)
{
/* If caller wants register contents data back, copy them. */
- bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
- bufp->regs_allocated);
- if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0))
+ bufp->re_regs_allocated = re_copy_regs (regs, pmatch, nregs,
+ bufp->re_regs_allocated);
+ if (BE (bufp->re_regs_allocated == REG_UNALLOCATED, 0))
rval = -2;
}
re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, int nregs,
int regs_allocated)
{
- int rval = REGS_REALLOCATE;
+ int rval = REG_REALLOCATE;
int i;
int need_regs = nregs + 1;
- /* We need one extra element beyond `num_regs' for the `-1' marker GNU code
+ /* We need one extra element beyond `rm_num_regs' for the `-1' marker GNU code
uses. */
/* Have the register data arrays been allocated? */
- if (regs_allocated == REGS_UNALLOCATED)
+ if (regs_allocated == REG_UNALLOCATED)
{ /* No. So allocate them with malloc. */
- regs->start = re_malloc (regoff_t, need_regs);
- regs->end = re_malloc (regoff_t, need_regs);
- if (BE (regs->start == NULL, 0) || BE (regs->end == NULL, 0))
- return REGS_UNALLOCATED;
- regs->num_regs = need_regs;
+ regs->rm_start = re_malloc (regoff_t, need_regs);
+ regs->rm_end = re_malloc (regoff_t, need_regs);
+ if (BE (regs->rm_start == NULL, 0) || BE (regs->rm_end == NULL, 0))
+ return REG_UNALLOCATED;
+ regs->rm_num_regs = need_regs;
}
- else if (regs_allocated == REGS_REALLOCATE)
+ else if (regs_allocated == REG_REALLOCATE)
{ /* Yes. If we need more elements than were already
allocated, reallocate them. If we need fewer, just
leave it alone. */
- if (BE (need_regs > regs->num_regs, 0))
+ if (BE (need_regs > regs->rm_num_regs, 0))
{
- regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
- regoff_t *new_end = re_realloc (regs->end, regoff_t, need_regs);
+ regoff_t *new_start =
+ re_realloc (regs->rm_start, regoff_t, need_regs);
+ regoff_t *new_end = re_realloc (regs->rm_end, regoff_t, need_regs);
if (BE (new_start == NULL, 0) || BE (new_end == NULL, 0))
- return REGS_UNALLOCATED;
- regs->start = new_start;
- regs->end = new_end;
- regs->num_regs = need_regs;
+ return REG_UNALLOCATED;
+ regs->rm_start = new_start;
+ regs->rm_end = new_end;
+ regs->rm_num_regs = need_regs;
}
}
else
{
- assert (regs_allocated == REGS_FIXED);
- /* This function may not be called with REGS_FIXED and nregs too big. */
- assert (regs->num_regs >= nregs);
- rval = REGS_FIXED;
+ assert (regs_allocated == REG_FIXED);
+ /* This function may not be called with REG_FIXED and nregs too big. */
+ assert (regs->rm_num_regs >= nregs);
+ rval = REG_FIXED;
}
/* Copy the regs. */
for (i = 0; i < nregs; ++i)
{
- regs->start[i] = pmatch[i].rm_so;
- regs->end[i] = pmatch[i].rm_eo;
+ regs->rm_start[i] = pmatch[i].rm_so;
+ regs->rm_end[i] = pmatch[i].rm_eo;
}
- for ( ; i < regs->num_regs; ++i)
- regs->start[i] = regs->end[i] = -1;
+ for ( ; i < regs->rm_num_regs; ++i)
+ regs->rm_start[i] = regs->rm_end[i] = -1;
return rval;
}
{
if (num_regs)
{
- bufp->regs_allocated = REGS_REALLOCATE;
- regs->num_regs = num_regs;
- regs->start = starts;
- regs->end = ends;
+ bufp->re_regs_allocated = REG_REALLOCATE;
+ regs->rm_num_regs = num_regs;
+ regs->rm_start = starts;
+ regs->rm_end = ends;
}
else
{
- bufp->regs_allocated = REGS_UNALLOCATED;
- regs->num_regs = 0;
- regs->start = regs->end = (regoff_t *) 0;
+ bufp->re_regs_allocated = REG_UNALLOCATED;
+ regs->rm_num_regs = 0;
+ regs->rm_start = regs->rm_end = NULL;
}
}
#ifdef _LIBC
int eflags)
{
reg_errcode_t err;
- re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
int left_lim, right_lim, incr;
int fl_longest_match, match_first, match_kind, match_last = -1;
int extra_nmatch;
#else
re_match_context_t mctx;
#endif
- char *fastmap = (preg->fastmap != NULL && preg->fastmap_accurate
- && range && !preg->can_be_null) ? preg->fastmap : NULL;
- unsigned RE_TRANSLATE_TYPE t = (unsigned RE_TRANSLATE_TYPE) preg->translate;
+ char *fastmap = (preg->re_fastmap != NULL && preg->re_fastmap_accurate
+ && range && !preg->re_can_be_null) ? preg->re_fastmap : NULL;
+ unsigned REG_TRANSLATE_TYPE t =
+ (unsigned REG_TRANSLATE_TYPE) preg->re_translate;
#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
memset (&mctx, '\0', sizeof (re_match_context_t));
nmatch -= extra_nmatch;
/* Check if the DFA haven't been compiled. */
- if (BE (preg->used == 0 || dfa->init_state == NULL
+ if (BE (preg->re_used == 0 || dfa->init_state == NULL
|| dfa->init_state_word == NULL || dfa->init_state_nl == NULL
|| dfa->init_state_begbuf == NULL, 0))
return REG_NOMATCH;
#endif
/* If initial states with non-begbuf contexts have no elements,
- the regex must be anchored. If preg->newline_anchor is set,
+ the regex must be anchored. If preg->re_newline_anchor is set,
we'll never use init_state_nl, so do not check it. */
if (dfa->init_state->nodes.nelem == 0
&& dfa->init_state_word->nodes.nelem == 0
&& (dfa->init_state_nl->nodes.nelem == 0
- || !preg->newline_anchor))
+ || !preg->re_newline_anchor))
{
if (start != 0 && start + range != 0)
return REG_NOMATCH;
fl_longest_match = (nmatch != 0 || dfa->nbackref);
err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
- preg->translate, preg->syntax & RE_ICASE, dfa);
+ preg->re_translate,
+ preg->re_syntax & REG_IGNORE_CASE, dfa);
if (BE (err != REG_NOERROR, 0))
goto free_return;
mctx.input.stop = stop;
mctx.input.raw_stop = stop;
- mctx.input.newline_anchor = preg->newline_anchor;
+ mctx.input.newline_anchor = preg->re_newline_anchor;
err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
if (BE (err != REG_NOERROR, 0))
sb = dfa->mb_cur_max == 1;
match_kind =
(fastmap
- ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0)
+ ? ((sb || !(preg->re_syntax & REG_IGNORE_CASE || t) ? 4 : 0)
| (range >= 0 ? 2 : 0)
| (t != NULL ? 1 : 0))
: 8);
else
{
mctx.match_last = match_last;
- if ((!preg->no_sub && nmatch > 1) || dfa->nbackref)
+ if ((!preg->re_no_sub && nmatch > 1) || dfa->nbackref)
{
re_dfastate_t *pstate = mctx.state_log[match_last];
mctx.last_node = check_halt_state_context (&mctx, pstate,
match_last);
}
- if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match)
+ if ((!preg->re_no_sub && nmatch > 1 && dfa->has_plural_match)
|| dfa->nbackref)
{
err = prune_impossible_nodes (&mctx);
pmatch[0].rm_so = 0;
pmatch[0].rm_eo = mctx.match_last;
- if (!preg->no_sub && nmatch > 1)
+ if (!preg->re_no_sub && nmatch > 1)
{
err = set_regs (preg, &mctx, nmatch, pmatch,
dfa->has_plural_match && dfa->nbackref > 0);
set_regs (const regex_t *preg, const re_match_context_t *mctx,
size_t nmatch, regmatch_t *pmatch, int fl_backtrack)
{
- re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
+ re_dfa_t *dfa = (re_dfa_t *) preg->re_buffer;
int idx, cur_node;
re_node_set eps_via_nodes;
struct re_fail_stack_t *fs;
else
#endif
bitset_set_all (accepts);
- if (!(dfa->syntax & RE_DOT_NEWLINE))
+ if (!(dfa->syntax & REG_DOT_NEWLINE))
bitset_clear (accepts, '\n');
- if (dfa->syntax & RE_DOT_NOT_NULL)
+ if (dfa->syntax & REG_DOT_NOT_NULL)
bitset_clear (accepts, '\0');
}
#ifdef RE_ENABLE_I18N
else if (type == OP_UTF8_PERIOD)
{
memset (accepts, 255, sizeof (unsigned int) * BITSET_UINTS / 2);
- if (!(dfa->syntax & RE_DOT_NEWLINE))
+ if (!(dfa->syntax & REG_DOT_NEWLINE))
bitset_clear (accepts, '\n');
- if (dfa->syntax & RE_DOT_NOT_NULL)
+ if (dfa->syntax & REG_DOT_NOT_NULL)
bitset_clear (accepts, '\0');
}
#endif
/* FIXME: I don't think this if is needed, as both '\n'
and '\0' are char_len == 1. */
/* '.' accepts any one character except the following two cases. */
- if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
+ if ((!(dfa->syntax & REG_DOT_NEWLINE) &&
re_string_byte_at (input, str_idx) == '\n') ||
- ((dfa->syntax & RE_DOT_NOT_NULL) &&
+ ((dfa->syntax & REG_DOT_NOT_NULL) &&
re_string_byte_at (input, str_idx) == '\0'))
return 0;
return char_len;
/* FALLTHROUGH */
#endif
case OP_PERIOD:
- if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
- || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
+ if ((ch == '\n' && !(mctx->dfa->syntax & REG_DOT_NEWLINE))
+ || (ch == '\0' && (mctx->dfa->syntax & REG_DOT_NOT_NULL)))
return 0;
break;