summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-08-23 19:41:09 +0000
committerJim Meyering <jim@meyering.net>2005-08-23 19:41:09 +0000
commit6cd08ed8ea28628817f6cd54b0430458a268820a (patch)
treea41812aaea4c03642343c146a060085808938ab9 /lib
parent88b1cd5a539d58396ee2b85f7fb902666ac32cc5 (diff)
downloadcoreutils-6cd08ed8ea28628817f6cd54b0430458a268820a.tar.xz
Update from gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/regcomp.c387
-rw-r--r--lib/regex.c8
-rw-r--r--lib/regex.h86
-rw-r--r--lib/regex_internal.c261
-rw-r--r--lib/regex_internal.h11
-rw-r--r--lib/regexec.c458
6 files changed, 444 insertions, 767 deletions
diff --git a/lib/regcomp.c b/lib/regcomp.c
index c0541f324..26a55b22f 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -23,7 +23,6 @@ static void re_compile_fastmap_iter (regex_t *bufp,
const re_dfastate_t *init_state,
char *fastmap);
static reg_errcode_t init_dfa (re_dfa_t *dfa, int pat_len);
-static void init_word_char (re_dfa_t *dfa);
#ifdef RE_ENABLE_I18N
static void free_charset (re_charset_t *cset);
#endif /* RE_ENABLE_I18N */
@@ -33,7 +32,6 @@ static reg_errcode_t create_initial_state (re_dfa_t *dfa);
static void optimize_utf8 (re_dfa_t *dfa);
#endif
static reg_errcode_t analyze (regex_t *preg);
-static reg_errcode_t create_initial_state (re_dfa_t *dfa);
static reg_errcode_t preorder (bin_tree_t *root,
reg_errcode_t (fn (void *, bin_tree_t *)),
void *extra);
@@ -47,11 +45,7 @@ static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg,
static reg_errcode_t calc_first (void *extra, bin_tree_t *node);
static reg_errcode_t calc_next (void *extra, bin_tree_t *node);
static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node);
-static reg_errcode_t duplicate_node_closure (re_dfa_t *dfa, int top_org_node,
- int top_clone_node, int root_node,
- unsigned int constraint);
-static reg_errcode_t duplicate_node (int *new_idx, re_dfa_t *dfa, int org_idx,
- unsigned int constraint);
+static int duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint);
static int search_duplicated_node (re_dfa_t *dfa, int org_node,
unsigned int constraint);
static reg_errcode_t calc_eclosure (re_dfa_t *dfa);
@@ -60,12 +54,8 @@ static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa,
static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
static int fetch_number (re_string_t *input, re_token_t *token,
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,
- reg_syntax_t syntax);
static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
reg_syntax_t syntax, reg_errcode_t *err);
static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
@@ -95,24 +85,6 @@ static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
re_string_t *regexp,
re_token_t *token);
-#ifndef _LIBC
-# ifdef RE_ENABLE_I18N
-static reg_errcode_t build_range_exp (re_bitset_ptr_t sbcset,
- re_charset_t *mbcset, int *range_alloc,
- bracket_elem_t *start_elem,
- bracket_elem_t *end_elem);
-static reg_errcode_t build_collating_symbol (re_bitset_ptr_t sbcset,
- re_charset_t *mbcset,
- int *coll_sym_alloc,
- const unsigned char *name);
-# else /* not RE_ENABLE_I18N */
-static reg_errcode_t build_range_exp (re_bitset_ptr_t sbcset,
- bracket_elem_t *start_elem,
- bracket_elem_t *end_elem);
-static reg_errcode_t build_collating_symbol (re_bitset_ptr_t sbcset,
- const unsigned char *name);
-# endif /* not RE_ENABLE_I18N */
-#endif /* not _LIBC */
#ifdef RE_ENABLE_I18N
static reg_errcode_t build_equiv_class (re_bitset_ptr_t sbcset,
re_charset_t *mbcset,
@@ -238,10 +210,8 @@ const size_t __re_error_msgid_idx[] attribute_hidden =
are set in BUFP on entry. */
const char *
-re_compile_pattern (pattern, length, bufp)
- const char *pattern;
- size_t length;
- struct re_pattern_buffer *bufp;
+re_compile_pattern (const char *pattern, size_t length,
+ struct re_pattern_buffer *bufp)
{
reg_errcode_t ret;
@@ -279,8 +249,7 @@ reg_syntax_t re_syntax_options;
defined in regex.h. We return the old syntax. */
reg_syntax_t
-re_set_syntax (syntax)
- reg_syntax_t syntax;
+re_set_syntax (reg_syntax_t syntax)
{
reg_syntax_t ret = re_syntax_options;
@@ -292,8 +261,7 @@ weak_alias (__re_set_syntax, re_set_syntax)
#endif
int
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
+re_compile_fastmap (struct re_pattern_buffer *bufp)
{
re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
char *fastmap = bufp->fastmap;
@@ -326,10 +294,8 @@ re_set_fastmap (char *fastmap, int icase, int ch)
Compile fastmap for the initial_state INIT_STATE. */
static void
-re_compile_fastmap_iter (bufp, init_state, fastmap)
- regex_t *bufp;
- const re_dfastate_t *init_state;
- char *fastmap;
+re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
+ char *fastmap)
{
re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
int node_cnt;
@@ -471,10 +437,7 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
the return codes and their meanings.) */
int
-regcomp (preg, pattern, cflags)
- regex_t *__restrict preg;
- const char *__restrict pattern;
- int cflags;
+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
@@ -533,11 +496,7 @@ weak_alias (__regcomp, regcomp)
from either regcomp or regexec. We don't use PREG here. */
size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- const regex_t *preg;
- char *errbuf;
- size_t errbuf_size;
+regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
{
const char *msg;
size_t msg_size;
@@ -645,8 +604,7 @@ free_dfa_content (re_dfa_t *dfa)
/* Free dynamically allocated space used by PREG. */
void
-regfree (preg)
- regex_t *preg;
+regfree (regex_t *preg)
{
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
if (BE (dfa != NULL, 1))
@@ -738,11 +696,8 @@ libc_freeres_fn (free_mem)
SYNTAX indicate regular expression's syntax. */
static reg_errcode_t
-re_compile_internal (preg, pattern, length, syntax)
- regex_t *preg;
- const char * pattern;
- int length;
- reg_syntax_t syntax;
+re_compile_internal (regex_t *preg, const char * pattern, int length,
+ reg_syntax_t syntax)
{
reg_errcode_t err = REG_NOERROR;
re_dfa_t *dfa;
@@ -839,9 +794,7 @@ re_compile_internal (preg, pattern, length, syntax)
as the initial length of some arrays. */
static reg_errcode_t
-init_dfa (dfa, pat_len)
- re_dfa_t *dfa;
- int pat_len;
+init_dfa (re_dfa_t *dfa, int pat_len)
{
int table_size;
#ifndef _LIBC
@@ -939,8 +892,7 @@ init_dfa (dfa, pat_len)
character used by some operators like "\<", "\>", etc. */
static void
-init_word_char (dfa)
- re_dfa_t *dfa;
+init_word_char (re_dfa_t *dfa)
{
int i, j, ch;
dfa->word_ops_used = 1;
@@ -953,8 +905,7 @@ init_word_char (dfa)
/* Free the work area which are only used while compiling. */
static void
-free_workarea_compile (preg)
- regex_t *preg;
+free_workarea_compile (regex_t *preg)
{
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
bin_tree_storage_t *storage, *next;
@@ -973,8 +924,7 @@ free_workarea_compile (preg)
/* Create initial states for all contexts. */
static reg_errcode_t
-create_initial_state (dfa)
- re_dfa_t *dfa;
+create_initial_state (re_dfa_t *dfa)
{
int first, i;
reg_errcode_t err;
@@ -1056,8 +1006,7 @@ create_initial_state (dfa)
DFA nodes where needed. */
static void
-optimize_utf8 (dfa)
- re_dfa_t *dfa;
+optimize_utf8 (re_dfa_t *dfa)
{
int node, i, mb_chars = 0, has_period = 0;
@@ -1124,8 +1073,7 @@ optimize_utf8 (dfa)
"eclosure", and "inveclosure". */
static reg_errcode_t
-analyze (preg)
- regex_t *preg;
+analyze (regex_t *preg)
{
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
reg_errcode_t ret;
@@ -1188,10 +1136,8 @@ analyze (preg)
implement parse tree visits. Instead, we use parent pointers and
some hairy code in these two functions. */
static reg_errcode_t
-postorder (root, fn, extra)
- bin_tree_t *root;
- reg_errcode_t (fn (void *, bin_tree_t *));
- void *extra;
+postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra)
{
bin_tree_t *node, *prev;
@@ -1222,10 +1168,8 @@ postorder (root, fn, extra)
}
static reg_errcode_t
-preorder (root, fn, extra)
- bin_tree_t *root;
- reg_errcode_t (fn (void *, bin_tree_t *));
- void *extra;
+preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
+ void *extra)
{
bin_tree_t *node;
@@ -1257,9 +1201,7 @@ preorder (root, fn, extra)
re_search_internal to map the inner one's opr.idx to this one's. Adjust
backreferences as well. Requires a preorder visit. */
static reg_errcode_t
-optimize_subexps (extra, node)
- void *extra;
- bin_tree_t *node;
+optimize_subexps (void *extra, bin_tree_t *node)
{
re_dfa_t *dfa = (re_dfa_t *) extra;
@@ -1290,9 +1232,7 @@ optimize_subexps (extra, node)
/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation
of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */
static reg_errcode_t
-lower_subexps (extra, node)
- void *extra;
- bin_tree_t *node;
+lower_subexps (void *extra, bin_tree_t *node)
{
regex_t *preg = (regex_t *) extra;
reg_errcode_t err = REG_NOERROR;
@@ -1314,10 +1254,7 @@ lower_subexps (extra, node)
}
static bin_tree_t *
-lower_subexp (err, preg, node)
- reg_errcode_t *err;
- regex_t *preg;
- bin_tree_t *node;
+lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
{
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
bin_tree_t *body = node->left;
@@ -1353,9 +1290,7 @@ lower_subexp (err, preg, node)
/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton
nodes. Requires a postorder visit. */
static reg_errcode_t
-calc_first (extra, node)
- void *extra;
- bin_tree_t *node;
+calc_first (void *extra, bin_tree_t *node)
{
re_dfa_t *dfa = (re_dfa_t *) extra;
if (node->token.type == CONCAT)
@@ -1375,9 +1310,7 @@ calc_first (extra, node)
/* Pass 2: compute NEXT on the tree. Preorder visit. */
static reg_errcode_t
-calc_next (extra, node)
- void *extra;
- bin_tree_t *node;
+calc_next (void *extra, bin_tree_t *node)
{
switch (node->token.type)
{
@@ -1400,9 +1333,7 @@ calc_next (extra, node)
/* Pass 3: link all DFA nodes to their NEXT node (any order will do). */
static reg_errcode_t
-link_nfa_nodes (extra, node)
- void *extra;
- bin_tree_t *node;
+link_nfa_nodes (void *extra, bin_tree_t *node)
{
re_dfa_t *dfa = (re_dfa_t *) extra;
int idx = node->node_idx;
@@ -1462,13 +1393,9 @@ link_nfa_nodes (extra, node)
to their own constraint. */
static reg_errcode_t
-duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node,
- init_constraint)
- re_dfa_t *dfa;
- int top_org_node, top_clone_node, root_node;
- unsigned int init_constraint;
+duplicate_node_closure (re_dfa_t *dfa, int top_org_node, int top_clone_node,
+ int root_node, unsigned int init_constraint)
{
- reg_errcode_t err;
int org_node, clone_node, ret;
unsigned int constraint = init_constraint;
for (org_node = top_org_node, clone_node = top_clone_node;;)
@@ -1482,9 +1409,9 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node,
edests of the back reference. */
org_dest = dfa->nexts[org_node];
re_node_set_empty (dfa->edests + clone_node);
- err = duplicate_node (&clone_dest, dfa, org_dest, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (BE (clone_dest == -1, 0))
+ return REG_ESPACE;
dfa->nexts[clone_node] = dfa->nexts[org_node];
ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
if (BE (ret < 0, 0))
@@ -1520,9 +1447,9 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node,
}
constraint |= dfa->nodes[org_node].opr.ctx_type;
}
- err = duplicate_node (&clone_dest, dfa, org_dest, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (BE (clone_dest == -1, 0))
+ return REG_ESPACE;
ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
if (BE (ret < 0, 0))
return REG_ESPACE;
@@ -1538,9 +1465,10 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node,
if (clone_dest == -1)
{
/* There are no such a duplicated node, create a new one. */
- err = duplicate_node (&clone_dest, dfa, org_dest, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
+ reg_errcode_t err;
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (BE (clone_dest == -1, 0))
+ return REG_ESPACE;
ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
if (BE (ret < 0, 0))
return REG_ESPACE;
@@ -1559,9 +1487,9 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node,
}
org_dest = dfa->edests[org_node].elems[1];
- err = duplicate_node (&clone_dest, dfa, org_dest, constraint);
- if (BE (err != REG_NOERROR, 0))
- return err;
+ clone_dest = duplicate_node (dfa, org_dest, constraint);
+ if (BE (clone_dest == -1, 0))
+ return REG_ESPACE;
ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
if (BE (ret < 0, 0))
return REG_ESPACE;
@@ -1576,10 +1504,7 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node,
satisfies the constraint CONSTRAINT. */
static int
-search_duplicated_node (dfa, org_node, constraint)
- re_dfa_t *dfa;
- int org_node;
- unsigned int constraint;
+search_duplicated_node (re_dfa_t *dfa, int org_node, unsigned int constraint)
{
int idx;
for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx)
@@ -1592,35 +1517,28 @@ search_duplicated_node (dfa, org_node, constraint)
}
/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT.
- The new index will be stored in NEW_IDX and return REG_NOERROR if succeeded,
- otherwise return the error code. */
+ Return the index of the new node, or -1 if insufficient storage is
+ available. */
-static reg_errcode_t
-duplicate_node (new_idx, dfa, org_idx, constraint)
- re_dfa_t *dfa;
- int *new_idx, org_idx;
- unsigned int constraint;
+static int
+duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint)
{
int dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
- if (BE (dup_idx == -1, 0))
+ if (BE (dup_idx != -1, 1))
{
- IF_LINT (*new_idx = -1);
- return REG_ESPACE;
- }
- dfa->nodes[dup_idx].constraint = constraint;
- if (dfa->nodes[org_idx].type == ANCHOR)
- dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type;
- dfa->nodes[dup_idx].duplicated = 1;
+ dfa->nodes[dup_idx].constraint = constraint;
+ if (dfa->nodes[org_idx].type == ANCHOR)
+ dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type;
+ dfa->nodes[dup_idx].duplicated = 1;
- /* Store the index of the original node. */
- dfa->org_indices[dup_idx] = org_idx;
- *new_idx = dup_idx;
- return REG_NOERROR;
+ /* Store the index of the original node. */
+ dfa->org_indices[dup_idx] = org_idx;
+ }
+ return dup_idx;
}
static reg_errcode_t
-calc_inveclosure (dfa)
- re_dfa_t *dfa;
+calc_inveclosure (re_dfa_t *dfa)
{
int src, idx, ret;
for (idx = 0; idx < dfa->nodes_len; ++idx)
@@ -1643,8 +1561,7 @@ calc_inveclosure (dfa)
/* Calculate "eclosure" for all the node in DFA. */
static reg_errcode_t
-calc_eclosure (dfa)
- re_dfa_t *dfa;
+calc_eclosure (re_dfa_t *dfa)
{
int node_idx, incomplete;
#ifdef DEBUG
@@ -1688,10 +1605,7 @@ calc_eclosure (dfa)
/* Calculate epsilon closure of NODE. */
static reg_errcode_t
-calc_eclosure_iter (new_set, dfa, node, root)
- re_node_set *new_set;
- re_dfa_t *dfa;
- int node, root;
+calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, int node, int root)
{
reg_errcode_t err;
unsigned int constraint;
@@ -1771,10 +1685,7 @@ calc_eclosure_iter (new_set, dfa, node, root)
We must not use this function inside bracket expressions. */
static void
-fetch_token (result, input, syntax)
- re_token_t *result;
- re_string_t *input;
- reg_syntax_t syntax;
+fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
{
re_string_skip_bytes (input, peek_token (result, input, syntax));
}
@@ -1783,10 +1694,7 @@ fetch_token (result, input, syntax)
We must not use this function inside bracket expressions. */
static int
-peek_token (token, input, syntax)
- re_token_t *token;
- re_string_t *input;
- reg_syntax_t syntax;
+peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
{
unsigned char c;
@@ -2024,10 +1932,7 @@ peek_token (token, input, syntax)
We must not use this function out of bracket expressions. */
static int
-peek_token_bracket (token, input, syntax)
- re_token_t *token;
- re_string_t *input;
- reg_syntax_t syntax;
+peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
{
unsigned char c;
if (re_string_eoi (input))
@@ -2123,11 +2028,8 @@ peek_token_bracket (token, input, syntax)
EOR means end of regular expression. */
static bin_tree_t *
-parse (regexp, preg, syntax, err)
- re_string_t *regexp;
- regex_t *preg;
- reg_syntax_t syntax;
- reg_errcode_t *err;
+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;
bin_tree_t *tree, *eor, *root;
@@ -2160,13 +2062,8 @@ parse (regexp, preg, syntax, err)
ALT means alternative, which represents the operator `|'. */
static bin_tree_t *
-parse_reg_exp (regexp, preg, token, syntax, nest, err)
- re_string_t *regexp;
- regex_t *preg;
- re_token_t *token;
- reg_syntax_t syntax;
- int nest;
- reg_errcode_t *err;
+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;
bin_tree_t *tree, *branch = NULL;
@@ -2206,13 +2103,8 @@ parse_reg_exp (regexp, preg, token, syntax, nest, err)
CAT means concatenation. */
static bin_tree_t *
-parse_branch (regexp, preg, token, syntax, nest, err)
- re_string_t *regexp;
- regex_t *preg;
- re_token_t *token;
- reg_syntax_t syntax;
- int nest;
- reg_errcode_t *err;
+parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
+ reg_syntax_t syntax, int nest, reg_errcode_t *err)
{
bin_tree_t *tree, *exp;
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
@@ -2251,13 +2143,8 @@ parse_branch (regexp, preg, token, syntax, nest, err)
*/
static bin_tree_t *
-parse_expression (regexp, preg, token, syntax, nest, err)
- re_string_t *regexp;
- regex_t *preg;
- re_token_t *token;
- reg_syntax_t syntax;
- int nest;
- reg_errcode_t *err;
+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;
bin_tree_t *tree;
@@ -2472,13 +2359,8 @@ parse_expression (regexp, preg, token, syntax, nest, err)
*/
static bin_tree_t *
-parse_sub_exp (regexp, preg, token, syntax, nest, err)
- re_string_t *regexp;
- regex_t *preg;
- re_token_t *token;
- reg_syntax_t syntax;
- int nest;
- reg_errcode_t *err;
+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;
bin_tree_t *tree;
@@ -2513,13 +2395,8 @@ parse_sub_exp (regexp, preg, token, syntax, nest, err)
/* This function parse repetition operators like "*", "+", "{1,3}" etc. */
static bin_tree_t *
-parse_dup_op (elem, regexp, dfa, token, syntax, err)
- bin_tree_t *elem;
- re_string_t *regexp;
- re_dfa_t *dfa;
- re_token_t *token;
- reg_syntax_t syntax;
- reg_errcode_t *err;
+parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
+ re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err)
{
bin_tree_t *tree = NULL, *old_tree = NULL;
int i, start, end, start_idx = re_string_cur_idx (regexp);
@@ -2658,15 +2535,11 @@ parse_dup_op (elem, regexp, dfa, token, syntax, err)
update it. */
static reg_errcode_t
+build_range_exp (re_bitset_ptr_t sbcset,
# ifdef RE_ENABLE_I18N
-build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
- re_charset_t *mbcset;
- int *range_alloc;
-# else /* not RE_ENABLE_I18N */
-build_range_exp (sbcset, start_elem, end_elem)
-# endif /* not RE_ENABLE_I18N */
- re_bitset_ptr_t sbcset;
- bracket_elem_t *start_elem, *end_elem;
+ re_charset_t *mbcset, int *range_alloc,
+# endif
+ bracket_elem_t *start_elem, bracket_elem_t *end_elem)
{
unsigned int start_ch, end_ch;
/* Equivalence Classes and Character Classes can't be a range start/end. */
@@ -2779,15 +2652,11 @@ build_range_exp (sbcset, start_elem, end_elem)
pointer argument since we may update it. */
static reg_errcode_t
+build_collating_symbol (re_bitset_ptr_t sbcset,
# ifdef RE_ENABLE_I18N
-build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
- re_charset_t *mbcset;
- int *coll_sym_alloc;
-# else /* not RE_ENABLE_I18N */
-build_collating_symbol (sbcset, name)
-# endif /* not RE_ENABLE_I18N */
- re_bitset_ptr_t sbcset;
- const unsigned char *name;
+ re_charset_t *mbcset, int *coll_sym_alloc,
+# endif
+ const unsigned char *name)
{
size_t name_len = strlen ((const char *) name);
if (BE (name_len != 1, 0))
@@ -2804,12 +2673,8 @@ build_collating_symbol (sbcset, name)
"[[.a-a.]]" etc. */
static bin_tree_t *
-parse_bracket_exp (regexp, dfa, token, syntax, err)
- re_string_t *regexp;
- re_dfa_t *dfa;
- re_token_t *token;
- reg_syntax_t syntax;
- reg_errcode_t *err;
+parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
+ reg_syntax_t syntax, reg_errcode_t *err)
{
#ifdef _LIBC
const unsigned char *collseqmb;
@@ -3360,15 +3225,9 @@ parse_bracket_exp (regexp, dfa, token, syntax, err)
/* Parse an element in the bracket expression. */
static reg_errcode_t
-parse_bracket_element (elem, regexp, token, token_len, dfa, syntax,
- accept_hyphen)
- bracket_elem_t *elem;
- re_string_t *regexp;
- re_token_t *token;
- int token_len;
- re_dfa_t *dfa;
- reg_syntax_t syntax;
- int accept_hyphen;
+parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
+ re_token_t *token, int token_len, re_dfa_t *dfa,
+ reg_syntax_t syntax, int accept_hyphen)
{
#ifdef RE_ENABLE_I18N
int cur_char_size;
@@ -3406,10 +3265,8 @@ parse_bracket_element (elem, regexp, token, token_len, dfa, syntax,
[=<equivalent_class>=]. */
static reg_errcode_t
-parse_bracket_symbol (elem, regexp, token)
- bracket_elem_t *elem;
- re_string_t *regexp;
- re_token_t *token;
+parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
+ re_token_t *token)
{
unsigned char ch, delim = token->opr.c;
int i = 0;
@@ -3455,15 +3312,11 @@ parse_bracket_symbol (elem, regexp, token)
is a pointer argument sinse we may update it. */
static reg_errcode_t
+build_equiv_class (re_bitset_ptr_t sbcset,
#ifdef RE_ENABLE_I18N
-build_equiv_class (sbcset, mbcset, equiv_class_alloc, name)
- re_charset_t *mbcset;
- int *equiv_class_alloc;
-#else /* not RE_ENABLE_I18N */
-build_equiv_class (sbcset, name)
-#endif /* not RE_ENABLE_I18N */
- re_bitset_ptr_t sbcset;
- const unsigned char *name;
+ re_charset_t *mbcset, int *equiv_class_alloc,
+#endif
+ const unsigned char *name)
{
#if defined _LIBC
uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -3550,17 +3403,11 @@ build_equiv_class (sbcset, name)
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,
#ifdef RE_ENABLE_I18N
-build_charclass (trans, sbcset, mbcset, char_class_alloc, class_name, syntax)
- re_charset_t *mbcset;
- int *char_class_alloc;
-#else /* not RE_ENABLE_I18N */
-build_charclass (trans, sbcset, class_name, syntax)
-#endif /* not RE_ENABLE_I18N */
- unsigned RE_TRANSLATE_TYPE trans;
- re_bitset_ptr_t sbcset;
- const unsigned char *class_name;
- reg_syntax_t syntax;
+ re_charset_t *mbcset, int *char_class_alloc,
+#endif
+ const unsigned char *class_name, reg_syntax_t syntax)
{
int i;
const char *name = (const char *) class_name;
@@ -3630,13 +3477,10 @@ build_charclass (trans, sbcset, class_name, syntax)
}
static bin_tree_t *
-build_charclass_op (dfa, trans, class_name, extra, non_match, err)
- re_dfa_t *dfa;
- unsigned RE_TRANSLATE_TYPE trans;
- const unsigned char *class_name;
- const unsigned char *extra;
- int non_match;
- reg_errcode_t *err;
+build_charclass_op (re_dfa_t *dfa, unsigned RE_TRANSLATE_TYPE trans,
+ const unsigned char *class_name,
+ const unsigned char *extra,
+ int non_match, reg_errcode_t *err)
{
re_bitset_ptr_t sbcset;
#ifdef RE_ENABLE_I18N
@@ -3750,10 +3594,7 @@ build_charclass_op (dfa, trans, class_name, extra, non_match, err)
Return -2, If an error is occured. */
static int
-fetch_number (input, token, syntax)
- re_string_t *input;
- re_token_t *token;
- reg_syntax_t syntax;
+fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
{
int num = -1;
unsigned char c;
@@ -3793,11 +3634,8 @@ free_charset (re_charset_t *cset)
/* Create a tree node. */
static bin_tree_t *
-create_tree (dfa, left, right, type)
- re_dfa_t *dfa;
- bin_tree_t *left;
- bin_tree_t *right;
- re_token_type_t type;
+create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+ re_token_type_t type)
{
re_token_t t;
t.type = type;
@@ -3805,11 +3643,8 @@ create_tree (dfa, left, right, type)
}
static bin_tree_t *
-create_token_tree (dfa, left, right, token)
- re_dfa_t *dfa;
- bin_tree_t *left;
- bin_tree_t *right;
- const re_token_t *token;
+create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+ const re_token_t *token)
{
bin_tree_t *tree;
if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0))
@@ -3845,9 +3680,7 @@ create_token_tree (dfa, left, right, token)
To be called from preorder or postorder. */
static reg_errcode_t
-mark_opt_subexp (extra, node)
- void *extra;
- bin_tree_t *node;
+mark_opt_subexp (void *extra, bin_tree_t *node)
{
int idx = (int) (long) extra;
if (node->token.type == SUBEXP && node->token.opr.idx == idx)
@@ -3887,9 +3720,7 @@ free_tree (void *extra, bin_tree_t *node)
it's easier to duplicate. */
static bin_tree_t *
-duplicate_tree (root, dfa)
- const bin_tree_t *root;
- re_dfa_t *dfa;
+duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa)
{
const bin_tree_t *node;
bin_tree_t *dup_root;
diff --git a/lib/regex.c b/lib/regex.c
index c202a8ca1..99c1a8250 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -82,12 +82,6 @@
#include <regex.h>
#include "regex_internal.h"
-#ifdef lint
-# define IF_LINT(Code) Code
-#else
-# define IF_LINT(Code) /* empty */
-#endif
-
#include "regex_internal.c"
#include "regcomp.c"
#include "regexec.c"
diff --git a/lib/regex.h b/lib/regex.h
index bdce605a3..c31095aa2 100644
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -1,6 +1,6 @@
/* Definitions for data structures and routines for the regular
expression library.
- Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003
+ Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -136,8 +136,7 @@ typedef unsigned long int reg_syntax_t;
/* If this bit is set, then an ending range point collating higher
than the starting range point, as in [z-a], is invalid.
- If not set, then when ending range point collates higher than the
- starting range point, the range is ignored. */
+ If not set, the containing range is empty and does not match any string. */
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
/* If this bit is set, then an unmatched ) is ordinary.
@@ -451,38 +450,21 @@ typedef struct
/* Declarations for routines. */
-/* To avoid duplicating every routine declaration -- once with a
- prototype (if we are ANSI), and once without (if we aren't) -- we
- use the following macro to declare argument types. This
- unfortunately clutters up the declarations a bit, but I think it's
- worth it. */
-
-#if __STDC__
-
-# define _RE_ARGS(args) args
-
-#else /* not __STDC__ */
-
-# define _RE_ARGS(args) ()
-
-#endif /* not __STDC__ */
-
/* Sets the current default syntax to SYNTAX, and return the old syntax.
You can also simply assign to the `re_syntax_options' variable. */
-extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
+extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
/* Compile the regular expression PATTERN, with length LENGTH
and syntax given by the global `re_syntax_options', into the buffer
BUFFER. Return NULL if successful, and an error string if not. */
-extern const char *re_compile_pattern
- _RE_ARGS ((const char *pattern, size_t length,
- struct re_pattern_buffer *buffer));
+extern const char *re_compile_pattern (const char *pattern, size_t length,
+ struct re_pattern_buffer *buffer);
/* Compile a fastmap for the compiled pattern in BUFFER; used to
accelerate searches. Return 0 if successful and -2 if was an
internal error. */
-extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
+extern int re_compile_fastmap (struct re_pattern_buffer *buffer);
/* Search in the string STRING (with length LENGTH) for the pattern
@@ -490,31 +472,29 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
characters. Return the starting position of the match, -1 for no
match, or -2 for an internal error. Also return register
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
-extern int re_search
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
- int length, int start, int range, struct re_registers *regs));
+extern int re_search (struct re_pattern_buffer *buffer, const char *string,
+ int length, int start, int range,
+ struct re_registers *regs);
/* Like `re_search', but search in the concatenation of STRING1 and
STRING2. Also, stop searching at index START + STOP. */
-extern int re_search_2
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, int range, struct re_registers *regs, int stop));
+extern int re_search_2 (struct re_pattern_buffer *buffer, const char *string1,
+ int length1, const char *string2, int length2,
+ int start, int range, struct re_registers *regs,
+ int stop);
/* Like `re_search', but return how many characters in STRING the regexp
in BUFFER matched, starting at position START. */
-extern int re_match
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
- int length, int start, struct re_registers *regs));
+extern int re_match (struct re_pattern_buffer *buffer, const char *string,
+ int length, int start, struct re_registers *regs);
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
-extern int re_match_2
- _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, struct re_registers *regs, int stop));
+extern int re_match_2 (struct re_pattern_buffer *buffer, const char *string1,
+ int length1, const char *string2, int length2,
+ int start, struct re_registers *regs, int stop);
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -529,15 +509,15 @@ extern int re_match_2
Unless this function is called, the first search or match using
PATTERN_BUFFER will allocate its own register data, without
freeing the old data. */
-extern void re_set_registers
- _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
- unsigned num_regs, regoff_t *starts, regoff_t *ends));
+extern void re_set_registers (struct re_pattern_buffer *buffer,
+ struct re_registers *regs, unsigned num_regs,
+ regoff_t *starts, regoff_t *ends);
#if defined _REGEX_RE_COMP || defined _LIBC
# ifndef _CRAY
/* 4.2 bsd compatibility. */
-extern char *re_comp _RE_ARGS ((const char *));
-extern int re_exec _RE_ARGS ((const char *));
+extern char *re_comp (const char *);
+extern int re_exec (const char *);
# endif
#endif
@@ -562,19 +542,19 @@ extern int re_exec _RE_ARGS ((const char *));
#endif
/* POSIX compatibility. */
-extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
- const char *__restrict __pattern,
- int __cflags));
+extern int regcomp (regex_t *__restrict __preg,
+ const char *__restrict __pattern,
+ int __cflags);
-extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
- const char *__restrict __string, size_t __nmatch,
- regmatch_t __pmatch[__restrict_arr],
- int __eflags));
+extern int regexec (const regex_t *__restrict __preg,
+ const char *__restrict __string, size_t __nmatch,
+ regmatch_t __pmatch[__restrict_arr],
+ int __eflags);
-extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
- char *__errbuf, size_t __errbuf_size));
+extern size_t regerror (int __errcode, const regex_t *__preg,
+ char *__errbuf, size_t __errbuf_size);
-extern void regfree _RE_ARGS ((regex_t *__preg));
+extern void regfree (regex_t *__preg);
#ifdef __cplusplus
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index ff04abbcf..385de6ffc 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -21,12 +21,6 @@ static void re_string_construct_common (const char *str, int len,
re_string_t *pstr,
RE_TRANSLATE_TYPE trans, int icase,
const re_dfa_t *dfa) internal_function;
-#ifdef RE_ENABLE_I18N
-static int re_string_skip_chars (re_string_t *pstr, int new_raw_idx,
- wint_t *last_wc) internal_function;
-#endif /* RE_ENABLE_I18N */
-static reg_errcode_t register_state (re_dfa_t *dfa, re_dfastate_t *newstate,
- unsigned int hash) internal_function;
static re_dfastate_t *create_ci_newstate (re_dfa_t *dfa,
const re_node_set *nodes,
unsigned int hash) internal_function;
@@ -34,8 +28,6 @@ static re_dfastate_t *create_cd_newstate (re_dfa_t *dfa,
const re_node_set *nodes,
unsigned int context,
unsigned int hash) internal_function;
-static unsigned int inline calc_state_hash (const re_node_set *nodes,
- unsigned int context) internal_function;
/* Functions for string operation. */
@@ -43,12 +35,9 @@ static unsigned int inline calc_state_hash (const re_node_set *nodes,
re_string_reconstruct before using the object. */
static reg_errcode_t
-re_string_allocate (pstr, str, len, init_len, trans, icase, dfa)
- re_string_t *pstr;
- const char *str;
- int len, init_len, icase;
- RE_TRANSLATE_TYPE trans;
- const re_dfa_t *dfa;
+internal_function
+re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len,
+ RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
{
reg_errcode_t ret;
int init_buf_len;
@@ -74,12 +63,9 @@ re_string_allocate (pstr, str, len, init_len, trans, icase, dfa)
/* This function allocate the buffers, and initialize them. */
static reg_errcode_t
-re_string_construct (pstr, str, len, trans, icase, dfa)
- re_string_t *pstr;
- const char *str;
- int len, icase;
- RE_TRANSLATE_TYPE trans;
- const re_dfa_t *dfa;
+internal_function
+re_string_construct (re_string_t *pstr, const char *str, int len,
+ RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
{
reg_errcode_t ret;
memset (pstr, '\0', sizeof (re_string_t));
@@ -140,33 +126,32 @@ re_string_construct (pstr, str, len, trans, icase, dfa)
/* Helper functions for re_string_allocate, and re_string_construct. */
static reg_errcode_t
-re_string_realloc_buffers (pstr, new_buf_len)
- re_string_t *pstr;
- int new_buf_len;
+internal_function
+re_string_realloc_buffers (re_string_t *pstr, int new_buf_len)
{
#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
{
- wint_t *new_array = re_realloc (pstr->wcs, wint_t, new_buf_len);
- if (BE (new_array == NULL, 0))
+ wint_t *new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
+ if (BE (new_wcs == NULL, 0))
return REG_ESPACE;
- pstr->wcs = new_array;
+ pstr->wcs = new_wcs;
if (pstr->offsets != NULL)
{
- int *offsets = re_realloc (pstr->offsets, int, new_buf_len);
- if (BE (offsets == NULL, 0))
+ int *new_offsets = re_realloc (pstr->offsets, int, new_buf_len);
+ if (BE (new_offsets == NULL, 0))
return REG_ESPACE;
- pstr->offsets = offsets;
+ pstr->offsets = new_offsets;
}
}
#endif /* RE_ENABLE_I18N */
if (pstr->mbs_allocated)
{
- unsigned char *new_array = re_realloc (pstr->mbs, unsigned char,
- new_buf_len);
- if (BE (new_array == NULL, 0))
+ unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
+ new_buf_len);
+ if (BE (new_mbs == NULL, 0))
return REG_ESPACE;
- pstr->mbs = new_array;
+ pstr->mbs = new_mbs;
}
pstr->bufs_len = new_buf_len;
return REG_NOERROR;
@@ -174,13 +159,10 @@ re_string_realloc_buffers (pstr, new_buf_len)
static void
-re_string_construct_common (str, len, pstr, trans, icase, dfa)
- const char *str;
- int len;
- re_string_t *pstr;
- RE_TRANSLATE_TYPE trans;
- int icase;
- const re_dfa_t *dfa;
+internal_function
+re_string_construct_common (const char *str, int len, re_string_t *pstr,
+ RE_TRANSLATE_TYPE trans, int icase,
+ const re_dfa_t *dfa)
{
pstr->raw_mbs = (const unsigned char *) str;
pstr->len = len;
@@ -209,8 +191,8 @@ re_string_construct_common (str, len, pstr, trans, icase, dfa)
built and starts from PSTR->VALID_LEN. */
static void
-build_wcs_buffer (pstr)
- re_string_t *pstr;
+internal_function
+build_wcs_buffer (re_string_t *pstr)
{
#ifdef _LIBC
unsigned char buf[MB_LEN_MAX];
@@ -277,8 +259,8 @@ build_wcs_buffer (pstr)
but for REG_ICASE. */
static int
-build_wcs_upper_buffer (pstr)
- re_string_t *pstr;
+internal_function
+build_wcs_upper_buffer (re_string_t *pstr)
{
mbstate_t prev_st;
int src_idx, byte_idx, end_idx, remain_len;
@@ -493,10 +475,8 @@ build_wcs_upper_buffer (pstr)
Return the index. */
static int
-re_string_skip_chars (pstr, new_raw_idx, last_wc)
- re_string_t *pstr;
- int new_raw_idx;
- wint_t *last_wc;
+internal_function
+re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
{
mbstate_t prev_st;
int rawbuf_idx;
@@ -530,8 +510,8 @@ re_string_skip_chars (pstr, new_raw_idx, last_wc)
This function is used in case of REG_ICASE. */
static void
-build_upper_buffer (pstr)
- re_string_t *pstr;
+internal_function
+build_upper_buffer (re_string_t *pstr)
{
int char_idx, end_idx;
end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
@@ -553,8 +533,8 @@ build_upper_buffer (pstr)
/* Apply TRANS to the buffer in PSTR. */
static void
-re_string_translate_buffer (pstr)
- re_string_t *pstr;
+internal_function
+re_string_translate_buffer (re_string_t *pstr)
{
int buf_idx, end_idx;
end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len;
@@ -574,9 +554,8 @@ re_string_translate_buffer (pstr)
convert to upper case in case of REG_ICASE, apply translation. */
static reg_errcode_t
-re_string_reconstruct (pstr, idx, eflags)
- re_string_t *pstr;
- int idx, eflags;
+internal_function
+re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
{
int offset = idx - pstr->raw_mbs_idx;
if (BE (offset < 0, 0))
@@ -752,9 +731,8 @@ re_string_reconstruct (pstr, idx, eflags)
}
static unsigned char
-re_string_peek_byte_case (pstr, idx)
- const re_string_t *pstr;
- int idx;
+internal_function
+re_string_peek_byte_case (const re_string_t *pstr, int idx)
{
int ch, off;
@@ -789,8 +767,8 @@ re_string_peek_byte_case (pstr, idx)
}
static unsigned char
-re_string_fetch_byte_case (pstr)
- re_string_t *pstr;
+internal_function
+re_string_fetch_byte_case (re_string_t *pstr)
{
if (BE (!pstr->mbs_allocated, 1))
return re_string_fetch_byte (pstr);
@@ -826,8 +804,8 @@ re_string_fetch_byte_case (pstr)
}
static void
-re_string_destruct (pstr)
- re_string_t *pstr;
+internal_function
+re_string_destruct (re_string_t *pstr)
{
#ifdef RE_ENABLE_I18N
re_free (pstr->wcs);
@@ -840,9 +818,8 @@ re_string_destruct (pstr)
/* Return the context at IDX in INPUT. */
static unsigned int
-re_string_context_at (input, idx, eflags)
- const re_string_t *input;
- int idx, eflags;
+internal_function
+re_string_context_at (const re_string_t *input, int idx, int eflags)
{
int c;
if (BE (idx < 0, 0))
@@ -886,9 +863,8 @@ re_string_context_at (input, idx, eflags)
/* Functions for set operation. */
static reg_errcode_t
-re_node_set_alloc (set, size)
- re_node_set *set;
- int size;
+internal_function
+re_node_set_alloc (re_node_set *set, int size)
{
set->alloc = size;
set->nelem = 0;
@@ -899,9 +875,8 @@ re_node_set_alloc (set, size)
}
static reg_errcode_t
-re_node_set_init_1 (set, elem)
- re_node_set *set;
- int elem;
+internal_function
+re_node_set_init_1 (re_node_set *set, int elem)
{
set->alloc = 1;
set->nelem = 1;
@@ -916,9 +891,8 @@ re_node_set_init_1 (set, elem)
}
static reg_errcode_t
-re_node_set_init_2 (set, elem1, elem2)
- re_node_set *set;
- int elem1, elem2;
+internal_function
+re_node_set_init_2 (re_node_set *set, int elem1, int elem2)
{
set->alloc = 2;
set->elems = re_malloc (int, 2);
@@ -947,9 +921,8 @@ re_node_set_init_2 (set, elem1, elem2)
}
static reg_errcode_t
-re_node_set_init_copy (dest, src)
- re_node_set *dest;
- const re_node_set *src;
+internal_function
+re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
{
dest->nelem = src->nelem;
if (src->nelem > 0)
@@ -973,9 +946,9 @@ re_node_set_init_copy (dest, src)
Note: We assume dest->elems is NULL, when dest->alloc is 0. */
static reg_errcode_t
-re_node_set_add_intersect (dest, src1, src2)
- re_node_set *dest;
- const re_node_set *src1, *src2;
+internal_function
+re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
+ const re_node_set *src2)
{
int i1, i2, is, id, delta, sbase;
if (src1->nelem == 0 || src2->nelem == 0)
@@ -1064,9 +1037,9 @@ re_node_set_add_intersect (dest, src1, src2)
DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
static reg_errcode_t
-re_node_set_init_union (dest, src1, src2)
- re_node_set *dest;
- const re_node_set *src1, *src2;
+internal_function
+re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
+ const re_node_set *src2)
{
int i1, i2, id;
if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
@@ -1117,9 +1090,8 @@ re_node_set_init_union (dest, src1, src2)
DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
static reg_errcode_t
-re_node_set_merge (dest, src)
- re_node_set *dest;
- const re_node_set *src;
+internal_function
+re_node_set_merge (re_node_set *dest, const re_node_set *src)
{
int is, id, sbase, delta;
if (src == NULL || src->nelem == 0)
@@ -1201,9 +1173,8 @@ re_node_set_merge (dest, src)
return -1 if an error is occured, return 1 otherwise. */
static int
-re_node_set_insert (set, elem)
- re_node_set *set;
- int elem;
+internal_function
+re_node_set_insert (re_node_set *set, int elem)
{
int idx;
/* In case the set is empty. */
@@ -1226,12 +1197,12 @@ re_node_set_insert (set, elem)
/* Realloc if we need. */
if (set->alloc == set->nelem)
{
- int *new_array;
+ int *new_elems;
set->alloc = set->alloc * 2;
- new_array = re_realloc (set->elems, int, set->alloc);
- if (BE (new_array == NULL, 0))
+ new_elems = re_realloc (set->elems, int, set->alloc);
+ if (BE (new_elems == NULL, 0))
return -1;
- set->elems = new_array;
+ set->elems = new_elems;
}
/* Move the elements which follows the new element. Test the
@@ -1259,19 +1230,18 @@ re_node_set_insert (set, elem)
Return -1 if an error is occured, return 1 otherwise. */
static int
-re_node_set_insert_last (set, elem)
- re_node_set *set;
- int elem;
+internal_function
+re_node_set_insert_last (re_node_set *set, int elem)
{
/* Realloc if we need. */
if (set->alloc == set->nelem)
{
- int *new_array;
+ int *new_elems;
set->alloc = (set->alloc + 1) * 2;
- new_array = re_realloc (set->elems, int, set->alloc);
- if (BE (new_array == NULL, 0))
+ new_elems = re_realloc (set->elems, int, set->alloc);
+ if (BE (new_elems == NULL, 0))
return -1;
- set->elems = new_array;
+ set->elems = new_elems;
}
/* Insert the new element. */
@@ -1283,8 +1253,8 @@ re_node_set_insert_last (set, elem)
return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */
static int
-re_node_set_compare (set1, set2)
- const re_node_set *set1, *set2;
+internal_function
+re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
{
int i;
if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
@@ -1298,9 +1268,8 @@ re_node_set_compare (set1, set2)
/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
static int
-re_node_set_contains (set, elem)
- const re_node_set *set;
- int elem;
+internal_function
+re_node_set_contains (const re_node_set *set, int elem)
{
unsigned int idx, right, mid;
if (set->nelem <= 0)
@@ -1321,9 +1290,8 @@ re_node_set_contains (set, elem)
}
static void
-re_node_set_remove_at (set, idx)
- re_node_set *set;
- int idx;
+internal_function
+re_node_set_remove_at (re_node_set *set, int idx)
{
if (idx < 0 || idx >= set->nelem)
return;
@@ -1337,9 +1305,8 @@ re_node_set_remove_at (set, idx)
Or return -1, if an error will be occured. */
static int
-re_dfa_add_node (dfa, token)
- re_dfa_t *dfa;
- re_token_t token;
+internal_function
+re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
{
int type = token.type;
if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
@@ -1348,11 +1315,11 @@ re_dfa_add_node (dfa, token)
int *new_nexts, *new_indices;
re_node_set *new_edests, *new_eclosures;
- re_token_t *new_array = re_realloc (dfa->nodes, re_token_t,
+ re_token_t *new_nodes = re_realloc (dfa->nodes, re_token_t,
new_nodes_alloc);
- if (BE (new_array == NULL, 0))
+ if (BE (new_nodes == NULL, 0))
return -1;
- dfa->nodes = new_array;
+ dfa->nodes = new_nodes;
new_nexts = re_realloc (dfa->nexts, int, new_nodes_alloc);
new_indices = re_realloc (dfa->org_indices, int, new_nodes_alloc);
new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
@@ -1378,10 +1345,9 @@ re_dfa_add_node (dfa, token)
return dfa->nodes_len++;
}
-static unsigned int inline
-calc_state_hash (nodes, context)
- const re_node_set *nodes;
- unsigned int context;
+static inline unsigned int
+internal_function
+calc_state_hash (const re_node_set *nodes, unsigned int context)
{
unsigned int hash = nodes->nelem + context;
int i;
@@ -1400,15 +1366,17 @@ calc_state_hash (nodes, context)
optimization. */
static re_dfastate_t*
-re_acquire_state (err, dfa, nodes)
- reg_errcode_t *err;
- re_dfa_t *dfa;
- const re_node_set *nodes;
+internal_function
+re_acquire_state (reg_errcode_t *err, re_dfa_t *dfa, const re_node_set *nodes)
{
unsigned int hash;
re_dfastate_t *new_state;
struct re_state_table_entry *spot;
int i;
+#ifdef lint
+ /* Suppress bogus uninitialized-variable warnings. */
+ *err = REG_NOERROR;
+#endif
if (BE (nodes->nelem == 0, 0))
{
*err = REG_NOERROR;
@@ -1423,19 +1391,13 @@ re_acquire_state (err, dfa, nodes)
if (hash != state->hash)
continue;
if (re_node_set_compare (&state->nodes, nodes))
- {
- IF_LINT (*err = REG_NOERROR);
- return state;
- }
+ return state;
}
/* There are no appropriate state in the dfa, create the new one. */
new_state = create_ci_newstate (dfa, nodes, hash);
if (BE (new_state != NULL, 1))
- {
- IF_LINT (*err = REG_NOERROR);
- return new_state;
- }
+ return new_state;
else
{
*err = REG_ESPACE;
@@ -1454,19 +1416,23 @@ re_acquire_state (err, dfa, nodes)
optimization. */
static re_dfastate_t*
-re_acquire_state_context (err, dfa, nodes, context)
- reg_errcode_t *err;
- re_dfa_t *dfa;
- const re_node_set *nodes;
- unsigned int context;
+internal_function
+re_acquire_state_context (reg_errcode_t *err, re_dfa_t *dfa,
+ const re_node_set *nodes, unsigned int context)
{
unsigned int hash;
re_dfastate_t *new_state;
struct re_state_table_entry *spot;
int i;
+#ifdef lint
+ /* Suppress bogus uninitialized-variable warnings. */
*err = REG_NOERROR;
+#endif
if (nodes->nelem == 0)
- return NULL;
+ {
+ *err = REG_NOERROR;
+ return NULL;
+ }
hash = calc_state_hash (nodes, context);
spot = dfa->state_table + (hash & dfa->state_hash_mask);
@@ -1494,10 +1460,8 @@ re_acquire_state_context (err, dfa, nodes, context)
indicates the error code if failed. */
static reg_errcode_t
-register_state (dfa, newstate, hash)
- re_dfa_t *dfa;
- re_dfastate_t *newstate;
- unsigned int hash;
+internal_function
+register_state (re_dfa_t *dfa, re_dfastate_t *newstate, unsigned int hash)
{
struct re_state_table_entry *spot;
reg_errcode_t err;
@@ -1533,10 +1497,8 @@ register_state (dfa, newstate, hash)
Return the new state if succeeded, otherwise return NULL. */
static re_dfastate_t *
-create_ci_newstate (dfa, nodes, hash)
- re_dfa_t *dfa;
- const re_node_set *nodes;
- unsigned int hash;
+internal_function
+create_ci_newstate (re_dfa_t *dfa, const re_node_set *nodes, unsigned int hash)
{
int i;
reg_errcode_t err;
@@ -1584,10 +1546,9 @@ create_ci_newstate (dfa, nodes, hash)
Return the new state if succeeded, otherwise return NULL. */
static re_dfastate_t *
-create_cd_newstate (dfa, nodes, context, hash)
- re_dfa_t *dfa;
- const re_node_set *nodes;
- unsigned int context, hash;
+internal_function
+create_cd_newstate (re_dfa_t *dfa, const re_node_set *nodes,
+ unsigned int context, unsigned int hash)
{
int i, nctx_nodes = 0;
reg_errcode_t err;
@@ -1660,8 +1621,8 @@ create_cd_newstate (dfa, nodes, context, hash)
}
static void
-free_state (state)
- re_dfastate_t *state;
+internal_function
+free_state (re_dfastate_t *state)
{
re_node_set_free (&state->non_eps_nodes);
re_node_set_free (&state->inveclosure);
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 74a52ecee..31e21af67 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -375,7 +375,6 @@ typedef struct re_dfa_t re_dfa_t;
# endif
#endif
-#ifndef RE_NO_INTERNAL_PROTOTYPES
static reg_errcode_t re_string_allocate (re_string_t *pstr, const char *str,
int len, int init_len,
RE_TRANSLATE_TYPE trans, int icase,
@@ -390,21 +389,21 @@ static reg_errcode_t re_string_reconstruct (re_string_t *pstr, int idx,
static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
int new_buf_len)
internal_function;
-# ifdef RE_ENABLE_I18N
+#ifdef RE_ENABLE_I18N
static void build_wcs_buffer (re_string_t *pstr) internal_function;
static int build_wcs_upper_buffer (re_string_t *pstr) internal_function;
-# endif /* RE_ENABLE_I18N */
+#endif /* RE_ENABLE_I18N */
static void build_upper_buffer (re_string_t *pstr) internal_function;
static void re_string_translate_buffer (re_string_t *pstr) internal_function;
static void re_string_destruct (re_string_t *pstr) internal_function;
-# ifdef RE_ENABLE_I18N
+#ifdef RE_ENABLE_I18N
static int re_string_elem_size_at (const re_string_t *pstr, int idx)
internal_function __attribute ((pure));
static inline int re_string_char_size_at (const re_string_t *pstr, int idx)
internal_function __attribute ((pure));
static inline wint_t re_string_wchar_at (const re_string_t *pstr, int idx)
internal_function __attribute ((pure));
-# endif /* RE_ENABLE_I18N */
+#endif /* RE_ENABLE_I18N */
static unsigned int re_string_context_at (const re_string_t *input, int idx,
int eflags)
internal_function __attribute ((pure));
@@ -413,7 +412,7 @@ static unsigned char re_string_peek_byte_case (const re_string_t *pstr,
internal_function __attribute ((pure));
static unsigned char re_string_fetch_byte_case (re_string_t *pstr)
internal_function __attribute ((pure));
-#endif
+
#define re_string_peek_byte(pstr, offset) \
((pstr)->mbs[(pstr)->cur_idx + offset])
#define re_string_fetch_byte(pstr) \
diff --git a/lib/regexec.c b/lib/regexec.c
index 8535d72c8..969d6b1b5 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -51,32 +51,21 @@ static int re_search_stub (struct re_pattern_buffer *bufp,
int ret_len) internal_function;
static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
int nregs, int regs_allocated) internal_function;
-static inline re_dfastate_t *acquire_init_state_context
- (reg_errcode_t *err, const re_match_context_t *mctx, int idx)
- __attribute ((always_inline)) internal_function;
static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
internal_function;
static int check_matching (re_match_context_t *mctx, int fl_longest_match,
int *p_match_first)
internal_function;
-static int check_halt_node_context (const re_dfa_t *dfa, int node,
- unsigned int context) internal_function;
static int check_halt_state_context (const re_match_context_t *mctx,
const re_dfastate_t *state, int idx)
internal_function;
static void update_regs (re_dfa_t *dfa, regmatch_t *pmatch,
regmatch_t *prev_idx_match, int cur_node,
int cur_idx, int nmatch) internal_function;
-static int proceed_next_node (const re_match_context_t *mctx,
- int nregs, regmatch_t *regs,
- int *pidx, int node, re_node_set *eps_via_nodes,
- struct re_fail_stack_t *fs) internal_function;
static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
int str_idx, int dest_node, int nregs,
regmatch_t *regs,
re_node_set *eps_via_nodes) internal_function;
-static int pop_fail_stack (struct re_fail_stack_t *fs, int *pidx, int nregs,
- regmatch_t *regs, re_node_set *eps_via_nodes) internal_function;
static reg_errcode_t set_regs (const regex_t *preg,
const re_match_context_t *mctx,
size_t nmatch, regmatch_t *pmatch,
@@ -100,9 +89,6 @@ static reg_errcode_t update_cur_sifted_state (re_match_context_t *mctx,
static reg_errcode_t add_epsilon_src_nodes (re_dfa_t *dfa,
re_node_set *dest_nodes,
const re_node_set *candidates) internal_function;
-static reg_errcode_t sub_epsilon_src_nodes (re_dfa_t *dfa, int node,
- re_node_set *dest_nodes,
- const re_node_set *and_nodes) internal_function;
static int check_dst_limits (re_match_context_t *mctx, re_node_set *limits,
int dst_node, int dst_idx, int src_node,
int src_idx) internal_function;
@@ -122,8 +108,6 @@ static reg_errcode_t check_subexp_limits (re_dfa_t *dfa,
static reg_errcode_t sift_states_bkref (re_match_context_t *mctx,
re_sift_context_t *sctx,
int str_idx, const re_node_set *candidates) internal_function;
-static reg_errcode_t clean_state_log_if_needed (re_match_context_t *mctx,
- int next_state_log_idx) internal_function;
static reg_errcode_t merge_state_array (re_dfa_t *dfa, re_dfastate_t **dst,
re_dfastate_t **src, int num) internal_function;
static re_dfastate_t *find_recover_state (reg_errcode_t *err,
@@ -209,16 +193,12 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx) internal_function
We return 0 if we find a match and REG_NOMATCH if not. */
int
-regexec (preg, string, nmatch, pmatch, eflags)
- const regex_t *__restrict preg;
- const char *__restrict string;
- size_t nmatch;
- regmatch_t pmatch[];
- int eflags;
+regexec (const regex_t *__restrict preg, const char *__restrict string,
+ size_t nmatch, regmatch_t pmatch[], int eflags)
{
reg_errcode_t err;
int start, length;
-#if defined _LIBC
+#ifdef _LIBC
re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
#endif
@@ -297,11 +277,8 @@ compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
match was found and -2 indicates an internal error. */
int
-re_match (bufp, string, length, start, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start;
- struct re_registers *regs;
+re_match (struct re_pattern_buffer *bufp, const char *string,
+ int length, int start, struct re_registers *regs)
{
return re_search_stub (bufp, string, length, start, 0, length, regs, 1);
}
@@ -310,11 +287,8 @@ weak_alias (__re_match, re_match)
#endif
int
-re_search (bufp, string, length, start, range, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start, range;
- struct re_registers *regs;
+re_search (struct re_pattern_buffer *bufp, const char *string,
+ int length, int start, int range, struct re_registers *regs)
{
return re_search_stub (bufp, string, length, start, range, length, regs, 0);
}
@@ -323,11 +297,10 @@ weak_alias (__re_search, re_search)
#endif
int
-re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, stop;
- struct re_registers *regs;
+re_match_2 (struct re_pattern_buffer *bufp,
+ const char *string1, int length1,
+ const char *string2, int length2,
+ int start, struct re_registers *regs, int stop)
{
return re_search_2_stub (bufp, string1, length1, string2, length2,
start, 0, regs, stop, 1);
@@ -337,11 +310,10 @@ weak_alias (__re_match_2, re_match_2)
#endif
int
-re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, range, stop;
- struct re_registers *regs;
+re_search_2 (struct re_pattern_buffer *bufp,
+ const char *string1, int length1,
+ const char *string2, int length2,
+ int start, int range, struct re_registers *regs, int stop)
{
return re_search_2_stub (bufp, string1, length1, string2, length2,
start, range, regs, stop, 0);
@@ -351,12 +323,12 @@ weak_alias (__re_search_2, re_search_2)
#endif
static int
-re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
- stop, ret_len)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, range, stop, ret_len;
- struct re_registers *regs;
+internal_function
+re_search_2_stub (struct re_pattern_buffer *bufp,
+ const char *string1, int length1,
+ const char *string2, int length2,
+ int start, int range, struct re_registers *regs, int stop,
+ int ret_len)
{
const char *str;
int rval;
@@ -397,17 +369,17 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
otherwise the position of the match is returned. */
static int
-re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start, range, stop, ret_len;
- struct re_registers *regs;
+internal_function
+re_search_stub (struct re_pattern_buffer *bufp,
+ const char *string, int length,
+ int start, int range, int stop, struct re_registers *regs,
+ int ret_len)
{
reg_errcode_t result;
regmatch_t *pmatch;
int nregs, rval;
int eflags = 0;
-#if defined _LIBC
+#ifdef _LIBC
re_dfa_t *dfa = (re_dfa_t *)bufp->buffer;
#endif
@@ -488,10 +460,9 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
}
static unsigned
-re_copy_regs (regs, pmatch, nregs, regs_allocated)
- struct re_registers *regs;
- regmatch_t *pmatch;
- int nregs, regs_allocated;
+internal_function
+re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, int nregs,
+ int regs_allocated)
{
int rval = REGS_REALLOCATE;
int i;
@@ -557,11 +528,8 @@ re_copy_regs (regs, pmatch, nregs, regs_allocated)
freeing the old data. */
void
-re_set_registers (bufp, regs, num_regs, starts, ends)
- struct re_pattern_buffer *bufp;
- struct re_registers *regs;
- unsigned num_regs;
- regoff_t *starts, *ends;
+re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
+ unsigned int num_regs, regoff_t *starts, regoff_t *ends)
{
if (num_regs)
{
@@ -608,13 +576,12 @@ re_exec (s)
(START + RANGE >= 0 && START + RANGE <= LENGTH) */
static reg_errcode_t
-re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch,
- eflags)
- const regex_t *preg;
- const char *string;
- int length, start, range, stop, eflags;
- size_t nmatch;
- regmatch_t pmatch[];
+internal_function
+re_search_internal (const regex_t *preg,
+ const char *string, int length,
+ int start, int range, int stop,
+ size_t nmatch, regmatch_t pmatch[],
+ int eflags)
{
reg_errcode_t err;
re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
@@ -927,8 +894,8 @@ re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch,
}
static reg_errcode_t
-prune_impossible_nodes (mctx)
- re_match_context_t *mctx;
+internal_function
+prune_impossible_nodes (re_match_context_t *mctx)
{
re_dfa_t *const dfa = mctx->dfa;
int halt_node, match_last;
@@ -1013,10 +980,9 @@ prune_impossible_nodes (mctx)
since initial states may have constraints like "\<", "^", etc.. */
static inline re_dfastate_t *
-acquire_init_state_context (err, mctx, idx)
- reg_errcode_t *err;
- const re_match_context_t *mctx;
- int idx;
+__attribute ((always_inline)) internal_function
+acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
+ int idx)
{
re_dfa_t *const dfa = mctx->dfa;
if (dfa->init_state->has_constraint)
@@ -1056,10 +1022,9 @@ acquire_init_state_context (err, mctx, idx)
index of the buffer. */
static int
-check_matching (mctx, fl_longest_match, p_match_first)
- re_match_context_t *mctx;
- int fl_longest_match;
- int *p_match_first;
+internal_function
+check_matching (re_match_context_t *mctx, int fl_longest_match,
+ int *p_match_first)
{
re_dfa_t *const dfa = mctx->dfa;
reg_errcode_t err;
@@ -1188,10 +1153,9 @@ check_matching (mctx, fl_longest_match, p_match_first)
/* Check NODE match the current context. */
-static int check_halt_node_context (dfa, node, context)
- const re_dfa_t *dfa;
- int node;
- unsigned int context;
+static int
+internal_function
+check_halt_node_context (const re_dfa_t *dfa, int node, unsigned int context)
{
re_token_type_t type = dfa->nodes[node].type;
unsigned int constraint = dfa->nodes[node].constraint;
@@ -1209,10 +1173,9 @@ static int check_halt_node_context (dfa, node, context)
match the context, return the node. */
static int
-check_halt_state_context (mctx, state, idx)
- const re_match_context_t *mctx;
- const re_dfastate_t *state;
- int idx;
+internal_function
+check_halt_state_context (const re_match_context_t *mctx,
+ const re_dfastate_t *state, int idx)
{
int i;
unsigned int context;
@@ -1232,12 +1195,10 @@ check_halt_state_context (mctx, state, idx)
of errors. */
static int
-proceed_next_node (mctx, nregs, regs, pidx, node, eps_via_nodes, fs)
- const re_match_context_t *mctx;
- regmatch_t *regs;
- int nregs, *pidx, node;
- re_node_set *eps_via_nodes;
- struct re_fail_stack_t *fs;
+internal_function
+proceed_next_node (const re_match_context_t *mctx,
+ int nregs, regmatch_t *regs, int *pidx, int node,
+ re_node_set *eps_via_nodes, struct re_fail_stack_t *fs)
{
re_dfa_t *const dfa = mctx->dfa;
int i, err;
@@ -1334,11 +1295,9 @@ proceed_next_node (mctx, nregs, regs, pidx, node, eps_via_nodes, fs)
}
static reg_errcode_t
-push_fail_stack (fs, str_idx, dest_node, nregs, regs, eps_via_nodes)
- struct re_fail_stack_t *fs;
- int str_idx, dest_node, nregs;
- regmatch_t *regs;
- re_node_set *eps_via_nodes;
+internal_function
+push_fail_stack (struct re_fail_stack_t *fs, int str_idx, int dest_node,
+ int nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
{
reg_errcode_t err;
int num = fs->num++;
@@ -1363,11 +1322,9 @@ push_fail_stack (fs, str_idx, dest_node, nregs, regs, eps_via_nodes)
}
static int
-pop_fail_stack (fs, pidx, nregs, regs, eps_via_nodes)
- struct re_fail_stack_t *fs;
- int *pidx, nregs;
- regmatch_t *regs;
- re_node_set *eps_via_nodes;
+internal_function
+pop_fail_stack (struct re_fail_stack_t *fs, int *pidx,
+ int nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
{
int num = --fs->num;
assert (num >= 0);
@@ -1385,12 +1342,9 @@ pop_fail_stack (fs, pidx, nregs, regs, eps_via_nodes)
pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */
static reg_errcode_t
-set_regs (preg, mctx, nmatch, pmatch, fl_backtrack)
- const regex_t *preg;
- const re_match_context_t *mctx;
- size_t nmatch;
- regmatch_t *pmatch;
- int fl_backtrack;
+internal_function
+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;
int idx, cur_node;
@@ -1473,8 +1427,8 @@ set_regs (preg, mctx, nmatch, pmatch, fl_backtrack)
}
static reg_errcode_t
-free_fail_stack_return (fs)
- struct re_fail_stack_t *fs;
+internal_function
+free_fail_stack_return (struct re_fail_stack_t *fs)
{
if (fs)
{
@@ -1490,10 +1444,9 @@ free_fail_stack_return (fs)
}
static void
-update_regs (dfa, pmatch, prev_idx_match, cur_node, cur_idx, nmatch)
- re_dfa_t *dfa;
- regmatch_t *pmatch, *prev_idx_match;
- int cur_node, cur_idx, nmatch;
+internal_function
+update_regs (re_dfa_t *dfa, regmatch_t *pmatch, regmatch_t *prev_idx_match,
+ int cur_node, int cur_idx, int nmatch)
{
int type = dfa->nodes[cur_node].type;
if (type == OP_OPEN_SUBEXP)
@@ -1563,9 +1516,8 @@ update_regs (dfa, pmatch, prev_idx_match, cur_node, cur_idx, nmatch)
((state) != NULL && re_node_set_contains (&(state)->nodes, node))
static reg_errcode_t
-sift_states_backward (mctx, sctx)
- re_match_context_t *mctx;
- re_sift_context_t *sctx;
+internal_function
+sift_states_backward (re_match_context_t *mctx, re_sift_context_t *sctx)
{
reg_errcode_t err;
int null_cnt = 0;
@@ -1622,11 +1574,9 @@ sift_states_backward (mctx, sctx)
}
static reg_errcode_t
-build_sifted_states (mctx, sctx, str_idx, cur_dest)
- re_match_context_t *mctx;
- re_sift_context_t *sctx;
- int str_idx;
- re_node_set *cur_dest;
+internal_function
+build_sifted_states (re_match_context_t *mctx, re_sift_context_t *sctx,
+ int str_idx, re_node_set *cur_dest)
{
re_dfa_t *const dfa = mctx->dfa;
re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes;
@@ -1686,9 +1636,8 @@ build_sifted_states (mctx, sctx, str_idx, cur_dest)
/* Helper functions. */
static reg_errcode_t
-clean_state_log_if_needed (mctx, next_state_log_idx)
- re_match_context_t *mctx;
- int next_state_log_idx;
+internal_function
+clean_state_log_if_needed (re_match_context_t *mctx, int next_state_log_idx)
{
int top = mctx->state_log_top;
@@ -1712,11 +1661,9 @@ clean_state_log_if_needed (mctx, next_state_log_idx)
}
static reg_errcode_t
-merge_state_array (dfa, dst, src, num)
- re_dfa_t *dfa;
- re_dfastate_t **dst;
- re_dfastate_t **src;
- int num;
+internal_function
+merge_state_array (re_dfa_t *dfa, re_dfastate_t **dst, re_dfastate_t **src,
+ int num)
{
int st_idx;
reg_errcode_t err;
@@ -1741,11 +1688,9 @@ merge_state_array (dfa, dst, src, num)
}
static reg_errcode_t
-update_cur_sifted_state (mctx, sctx, str_idx, dest_nodes)
- re_match_context_t *mctx;
- re_sift_context_t *sctx;
- int str_idx;
- re_node_set *dest_nodes;
+internal_function
+update_cur_sifted_state (re_match_context_t *mctx, re_sift_context_t *sctx,
+ int str_idx, re_node_set *dest_nodes)
{
re_dfa_t *const dfa = mctx->dfa;
reg_errcode_t err;
@@ -1790,10 +1735,9 @@ update_cur_sifted_state (mctx, sctx, str_idx, dest_nodes)
}
static reg_errcode_t
-add_epsilon_src_nodes (dfa, dest_nodes, candidates)
- re_dfa_t *dfa;
- re_node_set *dest_nodes;
- const re_node_set *candidates;
+internal_function
+add_epsilon_src_nodes (re_dfa_t *dfa, re_node_set *dest_nodes,
+ const re_node_set *candidates)
{
reg_errcode_t err = REG_NOERROR;
int i;
@@ -1816,11 +1760,9 @@ add_epsilon_src_nodes (dfa, dest_nodes, candidates)
}
static reg_errcode_t
-sub_epsilon_src_nodes (dfa, node, dest_nodes, candidates)
- re_dfa_t *dfa;
- int node;
- re_node_set *dest_nodes;
- const re_node_set *candidates;
+internal_function
+sub_epsilon_src_nodes (re_dfa_t *dfa, int node, re_node_set *dest_nodes,
+ const re_node_set *candidates)
{
int ecl_idx;
reg_errcode_t err;
@@ -1867,10 +1809,9 @@ sub_epsilon_src_nodes (dfa, node, dest_nodes, candidates)
}
static int
-check_dst_limits (mctx, limits, dst_node, dst_idx, src_node, src_idx)
- re_match_context_t *mctx;
- re_node_set *limits;
- int dst_node, dst_idx, src_node, src_idx;
+internal_function
+check_dst_limits (re_match_context_t *mctx, re_node_set *limits,
+ int dst_node, int dst_idx, int src_node, int src_idx)
{
re_dfa_t *const dfa = mctx->dfa;
int lim_idx, src_pos, dst_pos;
@@ -1904,9 +1845,9 @@ check_dst_limits (mctx, limits, dst_node, dst_idx, src_node, src_idx)
}
static int
-check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, from_node, bkref_idx)
- re_match_context_t *mctx;
- int boundaries, subexp_idx, from_node, bkref_idx;
+internal_function
+check_dst_limits_calc_pos_1 (re_match_context_t *mctx, int boundaries,
+ int subexp_idx, int from_node, int bkref_idx)
{
re_dfa_t *const dfa = mctx->dfa;
re_node_set *eclosures = dfa->eclosures + from_node;
@@ -1982,9 +1923,9 @@ check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, from_node, bkref_idx)
}
static int
-check_dst_limits_calc_pos (mctx, limit, subexp_idx, from_node, str_idx, bkref_idx)
- re_match_context_t *mctx;
- int limit, subexp_idx, from_node, str_idx, bkref_idx;
+internal_function
+check_dst_limits_calc_pos (re_match_context_t *mctx, int limit, int subexp_idx,
+ int from_node, int str_idx, int bkref_idx)
{
struct re_backref_cache_entry *lim = mctx->bkref_ents + limit;
int boundaries;
@@ -2011,13 +1952,10 @@ check_dst_limits_calc_pos (mctx, limit, subexp_idx, from_node, str_idx, bkref_id
which are against limitations from DEST_NODES. */
static reg_errcode_t
-check_subexp_limits (dfa, dest_nodes, candidates, limits, bkref_ents, str_idx)
- re_dfa_t *dfa;
- re_node_set *dest_nodes;
- const re_node_set *candidates;
- re_node_set *limits;
- struct re_backref_cache_entry *bkref_ents;
- int str_idx;
+internal_function
+check_subexp_limits (re_dfa_t *dfa, re_node_set *dest_nodes,
+ const re_node_set *candidates, re_node_set *limits,
+ struct re_backref_cache_entry *bkref_ents, int str_idx)
{
reg_errcode_t err;
int node_idx, lim_idx;
@@ -2102,11 +2040,9 @@ check_subexp_limits (dfa, dest_nodes, candidates, limits, bkref_ents, str_idx)
}
static reg_errcode_t
-sift_states_bkref (mctx, sctx, str_idx, candidates)
- re_match_context_t *mctx;
- re_sift_context_t *sctx;
- int str_idx;
- const re_node_set *candidates;
+internal_function
+sift_states_bkref (re_match_context_t *mctx, re_sift_context_t *sctx,
+ int str_idx, const re_node_set *candidates)
{
re_dfa_t *const dfa = mctx->dfa;
reg_errcode_t err;
@@ -2136,7 +2072,7 @@ sift_states_bkref (mctx, sctx, str_idx, candidates)
enabled_idx = first_idx;
do
{
- int subexp_len, to_idx, dst_node;
+ int subexp_len, to_idx, dst_node, ret;
re_dfastate_t *cur_state;
if (entry->node != node)
@@ -2162,8 +2098,8 @@ sift_states_bkref (mctx, sctx, str_idx, candidates)
}
local_sctx.last_node = node;
local_sctx.last_str_idx = str_idx;
- err = re_node_set_insert (&local_sctx.limits, enabled_idx);
- if (BE (err < 0, 0))
+ ret = re_node_set_insert (&local_sctx.limits, enabled_idx);
+ if (BE (ret < 0, 0))
{
err = REG_ESPACE;
goto free_return;
@@ -2201,10 +2137,9 @@ sift_states_bkref (mctx, sctx, str_idx, candidates)
#ifdef RE_ENABLE_I18N
static int
-sift_states_iter_mb (mctx, sctx, node_idx, str_idx, max_str_idx)
- const re_match_context_t *mctx;
- re_sift_context_t *sctx;
- int node_idx, str_idx, max_str_idx;
+internal_function
+sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
+ int node_idx, int str_idx, int max_str_idx)
{
re_dfa_t *const dfa = mctx->dfa;
int naccepted;
@@ -2232,10 +2167,9 @@ sift_states_iter_mb (mctx, sctx, node_idx, str_idx, max_str_idx)
update the destination of STATE_LOG. */
static re_dfastate_t *
-transit_state (err, mctx, state)
- reg_errcode_t *err;
- re_match_context_t *mctx;
- re_dfastate_t *state;
+internal_function
+transit_state (reg_errcode_t *err, re_match_context_t *mctx,
+ re_dfastate_t *state)
{
re_dfastate_t **trtable;
unsigned char ch;
@@ -2291,10 +2225,9 @@ transit_state (err, mctx, state)
/* Update the state_log if we need */
re_dfastate_t *
-merge_state_with_log (err, mctx, next_state)
- reg_errcode_t *err;
- re_match_context_t *mctx;
- re_dfastate_t *next_state;
+internal_function
+merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
+ re_dfastate_t *next_state)
{
re_dfa_t *const dfa = mctx->dfa;
int cur_idx = re_string_cur_idx (&mctx->input);
@@ -2370,10 +2303,9 @@ merge_state_with_log (err, mctx, next_state)
/* Skip bytes in the input that correspond to part of a
multi-byte match, then look in the log for a state
from which to restart matching. */
-re_dfastate_t *
-find_recover_state (err, mctx)
- reg_errcode_t *err;
- re_match_context_t *mctx;
+static re_dfastate_t *
+internal_function
+find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
{
re_dfastate_t *cur_state = NULL;
do
@@ -2403,10 +2335,9 @@ find_recover_state (err, mctx)
correspoding back references. */
static reg_errcode_t
-check_subexp_matching_top (mctx, cur_nodes, str_idx)
- re_match_context_t *mctx;
- re_node_set *cur_nodes;
- int str_idx;
+internal_function
+check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
+ int str_idx)
{
re_dfa_t *const dfa = mctx->dfa;
int node_idx;
@@ -2478,9 +2409,8 @@ transit_state_sb (err, mctx, state)
#ifdef RE_ENABLE_I18N
static reg_errcode_t
-transit_state_mb (mctx, pstate)
- re_match_context_t *mctx;
- re_dfastate_t *pstate;
+internal_function
+transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
{
re_dfa_t *const dfa = mctx->dfa;
reg_errcode_t err;
@@ -2548,9 +2478,8 @@ transit_state_mb (mctx, pstate)
#endif /* RE_ENABLE_I18N */
static reg_errcode_t
-transit_state_bkref (mctx, nodes)
- re_match_context_t *mctx;
- const re_node_set *nodes;
+internal_function
+transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
{
re_dfa_t *const dfa = mctx->dfa;
reg_errcode_t err;
@@ -2663,9 +2592,8 @@ transit_state_bkref (mctx, nodes)
delay these checking for prune_impossible_nodes(). */
static reg_errcode_t
-get_subexp (mctx, bkref_node, bkref_str_idx)
- re_match_context_t *mctx;
- int bkref_node, bkref_str_idx;
+internal_function
+get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx)
{
re_dfa_t *const dfa = mctx->dfa;
int subexp_num, sub_top_idx;
@@ -2809,11 +2737,9 @@ get_subexp (mctx, bkref_node, bkref_str_idx)
and SUB_LAST. */
static reg_errcode_t
-get_subexp_sub (mctx, sub_top, sub_last, bkref_node, bkref_str)
- re_match_context_t *mctx;
- const re_sub_match_top_t *sub_top;
- re_sub_match_last_t *sub_last;
- int bkref_node, bkref_str;
+internal_function
+get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
+ re_sub_match_last_t *sub_last, int bkref_node, int bkref_str)
{
reg_errcode_t err;
int to_idx;
@@ -2839,10 +2765,9 @@ get_subexp_sub (mctx, sub_top, sub_last, bkref_node, bkref_str)
E.g. RE: (a){2} */
static int
-find_subexp_node (dfa, nodes, subexp_idx, type)
- const re_dfa_t *dfa;
- const re_node_set *nodes;
- int subexp_idx, type;
+internal_function
+find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
+ int subexp_idx, int type)
{
int cls_idx;
for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx)
@@ -2862,11 +2787,10 @@ find_subexp_node (dfa, nodes, subexp_idx, type)
Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */
static reg_errcode_t
-check_arrival (mctx, path, top_node, top_str, last_node, last_str,
- type)
- re_match_context_t *mctx;
- state_array_t *path;
- int top_node, top_str, last_node, last_str, type;
+internal_function
+check_arrival (re_match_context_t *mctx, state_array_t *path,
+ int top_node, int top_str, int last_node, int last_str,
+ int type)
{
re_dfa_t *const dfa = mctx->dfa;
reg_errcode_t err;
@@ -3024,10 +2948,10 @@ check_arrival (mctx, path, top_node, top_str, last_node, last_str,
Can't we unify them? */
static reg_errcode_t
-check_arrival_add_next_nodes (mctx, str_idx, cur_nodes, next_nodes)
- re_match_context_t *mctx;
- int str_idx;
- re_node_set *cur_nodes, *next_nodes;
+internal_function
+check_arrival_add_next_nodes (re_match_context_t *mctx, int str_idx,
+ re_node_set *cur_nodes,
+ re_node_set *next_nodes)
{
re_dfa_t *const dfa = mctx->dfa;
int result;
@@ -3104,10 +3028,9 @@ check_arrival_add_next_nodes (mctx, str_idx, cur_nodes, next_nodes)
*/
static reg_errcode_t
-check_arrival_expand_ecl (dfa, cur_nodes, ex_subexp, type)
- re_dfa_t *dfa;
- re_node_set *cur_nodes;
- int ex_subexp, type;
+internal_function
+check_arrival_expand_ecl (re_dfa_t *dfa, re_node_set *cur_nodes,
+ int ex_subexp, int type)
{
reg_errcode_t err;
int idx, outside_node;
@@ -3158,10 +3081,9 @@ check_arrival_expand_ecl (dfa, cur_nodes, ex_subexp, type)
problematic append it to DST_NODES. */
static reg_errcode_t
-check_arrival_expand_ecl_sub (dfa, dst_nodes, target, ex_subexp, type)
- re_dfa_t *dfa;
- int target, ex_subexp, type;
- re_node_set *dst_nodes;
+internal_function
+check_arrival_expand_ecl_sub (re_dfa_t *dfa, re_node_set *dst_nodes,
+ int target, int ex_subexp, int type)
{
int cur_node;
for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);)
@@ -3203,11 +3125,9 @@ check_arrival_expand_ecl_sub (dfa, dst_nodes, target, ex_subexp, type)
in MCTX->BKREF_ENTS. */
static reg_errcode_t
-expand_bkref_cache (mctx, cur_nodes, cur_str, subexp_num,
- type)
- re_match_context_t *mctx;
- int cur_str, subexp_num, type;
- re_node_set *cur_nodes;
+internal_function
+expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
+ int cur_str, int subexp_num, int type)
{
re_dfa_t *const dfa = mctx->dfa;
reg_errcode_t err;
@@ -3294,9 +3214,8 @@ expand_bkref_cache (mctx, cur_nodes, cur_str, subexp_num,
Return 1 if succeeded, otherwise return NULL. */
static int
-build_trtable (dfa, state)
- re_dfa_t *dfa;
- re_dfastate_t *state;
+internal_function
+build_trtable (re_dfa_t *dfa, re_dfastate_t *state)
{
reg_errcode_t err;
int i, j, ch, need_word_trtable = 0;
@@ -3520,11 +3439,9 @@ out_free:
to DEST_CH[i]. This function return the number of destinations. */
static int
-group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch)
- re_dfa_t *dfa;
- const re_dfastate_t *state;
- re_node_set *dests_node;
- bitset *dests_ch;
+internal_function
+group_nodes_into_DFAstates (re_dfa_t *dfa, const re_dfastate_t *state,
+ re_node_set *dests_node, bitset *dests_ch)
{
reg_errcode_t err;
int result;
@@ -3712,10 +3629,9 @@ group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch)
can only accept one byte. */
static int
-check_node_accept_bytes (dfa, node_idx, input, str_idx)
- re_dfa_t *dfa;
- int node_idx, str_idx;
- const re_string_t *input;
+internal_function
+check_node_accept_bytes (re_dfa_t *dfa, int node_idx,
+ const re_string_t *input, int str_idx)
{
const re_token_t *node = dfa->nodes + node_idx;
int char_len, elem_len;
@@ -4013,10 +3929,9 @@ find_collation_sequence_value (mbs, mbs_len)
byte of the INPUT. */
static int
-check_node_accept (mctx, node, idx)
- const re_match_context_t *mctx;
- const re_token_t *node;
- int idx;
+internal_function
+check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
+ int idx)
{
unsigned char ch;
ch = re_string_byte_at (&mctx->input, idx);
@@ -4064,8 +3979,8 @@ check_node_accept (mctx, node, idx)
/* Extend the buffers, if the buffers have run out. */
static reg_errcode_t
-extend_buffers (mctx)
- re_match_context_t *mctx;
+internal_function
+extend_buffers (re_match_context_t *mctx)
{
reg_errcode_t ret;
re_string_t *pstr = &mctx->input;
@@ -4123,9 +4038,8 @@ extend_buffers (mctx)
/* Initialize MCTX. */
static reg_errcode_t
-match_ctx_init (mctx, eflags, n)
- re_match_context_t *mctx;
- int eflags, n;
+internal_function
+match_ctx_init (re_match_context_t *mctx, int eflags, int n)
{
mctx->eflags = eflags;
mctx->match_last = -1;
@@ -4152,8 +4066,8 @@ match_ctx_init (mctx, eflags, n)
of the input, or changes the input string. */
static void
-match_ctx_clean (mctx)
- re_match_context_t *mctx;
+internal_function
+match_ctx_clean (re_match_context_t *mctx)
{
int st_idx;
for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
@@ -4182,8 +4096,8 @@ match_ctx_clean (mctx)
/* Free all the memory associated with MCTX. */
static void
-match_ctx_free (mctx)
- re_match_context_t *mctx;
+internal_function
+match_ctx_free (re_match_context_t *mctx)
{
/* First, free all the memory associated with MCTX->SUB_TOPS. */
match_ctx_clean (mctx);
@@ -4197,9 +4111,9 @@ match_ctx_free (mctx)
*/
static reg_errcode_t
-match_ctx_add_entry (mctx, node, str_idx, from, to)
- re_match_context_t *mctx;
- int node, str_idx, from, to;
+internal_function
+match_ctx_add_entry (re_match_context_t *mctx, int node, int str_idx,
+ int from, int to)
{
if (mctx->nbkref_ents >= mctx->abkref_ents)
{
@@ -4246,9 +4160,8 @@ match_ctx_add_entry (mctx, node, str_idx, from, to)
found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
static int
-search_cur_bkref_entry (mctx, str_idx)
- re_match_context_t *mctx;
- int str_idx;
+internal_function
+search_cur_bkref_entry (re_match_context_t *mctx, int str_idx)
{
int left, right, mid, last;
last = right = mctx->nbkref_ents;
@@ -4270,9 +4183,8 @@ search_cur_bkref_entry (mctx, str_idx)
at STR_IDX. */
static reg_errcode_t
-match_ctx_add_subtop (mctx, node, str_idx)
- re_match_context_t *mctx;
- int node, str_idx;
+internal_function
+match_ctx_add_subtop (re_match_context_t *mctx, int node, int str_idx)
{
#ifdef DEBUG
assert (mctx->sub_tops != NULL);
@@ -4301,9 +4213,8 @@ match_ctx_add_subtop (mctx, node, str_idx)
at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */
static re_sub_match_last_t *
-match_ctx_add_sublast (subtop, node, str_idx)
- re_sub_match_top_t *subtop;
- int node, str_idx;
+internal_function
+match_ctx_add_sublast (re_sub_match_top_t *subtop, int node, int str_idx)
{
re_sub_match_last_t *new_entry;
if (BE (subtop->nlasts == subtop->alasts, 0))
@@ -4329,10 +4240,11 @@ match_ctx_add_sublast (subtop, node, str_idx)
}
static void
-sift_ctx_init (sctx, sifted_sts, limited_sts, last_node, last_str_idx)
- re_sift_context_t *sctx;
- re_dfastate_t **sifted_sts, **limited_sts;
- int last_node, last_str_idx;
+internal_function
+sift_ctx_init (re_sift_context_t *sctx,
+ re_dfastate_t **sifted_sts,
+ re_dfastate_t **limited_sts,
+ int last_node, int last_str_idx)
{
sctx->sifted_states = sifted_sts;
sctx->limited_states = limited_sts;