static void calc_inveclosure (re_dfa_t *dfa);
static int fetch_number (re_string_t *input, re_token_t *token,
reg_syntax_t syntax);
-static re_token_t fetch_token (re_string_t *input, reg_syntax_t syntax);
+static void fetch_token (re_token_t *result, re_string_t *input,
+ reg_syntax_t syntax);
static int peek_token (re_token_t *token, re_string_t *input,
reg_syntax_t syntax);
static int peek_token_bracket (re_token_t *token, re_string_t *input,
/* Fetch a token from INPUT.
We must not use this function inside bracket expressions. */
-static re_token_t
-fetch_token (input, syntax)
+static void
+fetch_token (result, input, syntax)
+ re_token_t *result;
re_string_t *input;
reg_syntax_t syntax;
{
- re_token_t token;
- int consumed_byte;
- consumed_byte = peek_token (&token, input, syntax);
- re_string_skip_bytes (input, consumed_byte);
- return token;
+ re_string_skip_bytes (input, peek_token (result, input, syntax));
}
/* Peek a token from INPUT, and return the length of the token.
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
bin_tree_t *tree, *eor, *root;
re_token_t current_token;
- current_token = fetch_token (regexp, syntax | RE_CARET_ANCHORS_HERE);
+ fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
while (token->type == OP_ALT)
{
re_token_t alt_token = *token;
- *token = fetch_token (regexp, syntax | RE_CARET_ANCHORS_HERE);
+ fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
if (token->type != OP_ALT && token->type != END_OF_RE
&& (nest == 0 || token->type != OP_CLOSE_SUBEXP))
{
&& !re_string_first_byte (regexp, re_string_cur_idx (regexp)))
{
bin_tree_t *mbc_remain;
- *token = fetch_token (regexp, syntax);
+ fetch_token (token, regexp, syntax);
mbc_remain = re_dfa_add_tree_node (dfa, NULL, NULL, *token);
tree = create_tree (dfa, tree, mbc_remain, CONCAT, 0);
if (BE (mbc_remain == NULL || tree == NULL, 0))
}
else if (syntax & RE_CONTEXT_INDEP_OPS)
{
- *token = fetch_token (regexp, syntax);
+ fetch_token (token, regexp, syntax);
return parse_expression (regexp, preg, token, syntax, nest, err);
}
/* else fall through */
by repetition operators.
eg. RE"^*" is invalid or "<ANCHOR(^)><CHAR(*)>",
it must not be "<ANCHOR(^)><REPEAT(*)>". */
- *token = fetch_token (regexp, syntax);
+ fetch_token (token, regexp, syntax);
return tree;
case OP_PERIOD:
tree = re_dfa_add_tree_node (dfa, NULL, NULL, *token);
#endif
return NULL;
}
- *token = fetch_token (regexp, syntax);
+ fetch_token (token, regexp, syntax);
while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
|| token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
return NULL;
}
dfa->nodes[left_par->node_idx].opr.idx = cur_nsub;
- *token = fetch_token (regexp, syntax | RE_CARET_ANCHORS_HERE);
+ fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
/* The subexpression may be a null string. */
if (token->type == OP_CLOSE_SUBEXP)
if (BE (start == 0 && end == 0, 0))
{
/* We treat "<re>{0}" and "<re>{0,0}" as null string. */
- *token = fetch_token (regexp, syntax);
+ fetch_token (token, regexp, syntax);
return NULL;
}
return NULL;
}
}
- *token = fetch_token (regexp, syntax);
+ fetch_token (token, regexp, syntax);
return tree;
parse_dup_op_espace:
unsigned char c;
while (1)
{
- *token = fetch_token (input, syntax);
+ fetch_token (token, input, syntax);
c = token->opr.c;
if (BE (token->type == END_OF_RE, 0))
return -2;
bin_tree_t *left;
bin_tree_t *right;
re_token_t token;
-{
+{
int new_idx = re_dfa_add_node (dfa, token, 0);
if (new_idx == -1)