+2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ * srclist.txt: Add glibc bugs 1220, 1221, 1222.
+
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* srclist.txt: Comment out $LIBCSRC/posix/regex_internal.c,
-# $Id: srclist.txt,v 1.72 2005-08-20 01:03:17 eggert Exp $
+# $Id: srclist.txt,v 1.73 2005-08-20 07:42:15 eggert Exp $
# Files for which we are not the source. See ./srclistvars.sh for the
# variable definitions.
#
# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1057
# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1217
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1220
#$LIBCSRC/posix/regcomp.c lib gpl
#
$LIBCSRC/posix/regex.c lib gpl
#
# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1201
# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1207
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1222
#$LIBCSRC/posix/regex.h lib gpl
#
# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1215
# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1218
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1220
#$LIBCSRC/posix/regex_internal.c lib gpl
#
# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1054
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1221
#$LIBCSRC/posix/regex_internal.h lib gpl
#
# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1216
+# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1220
#$LIBCSRC/posix/regexec.c lib gpl
#
# c89 changes $LIBCSRC/string/strdup.c lib gpl
+2005-08-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ * regcomp.c:
+ (re_compile_pattern, re_set_syntax, re_compile_fastmap):
+ (re_compile_fastmap_iter, regcomp, regerror, regfree):
+ (re_compile_internal, init_dfa, init_word_char, free_workarea_compile):
+ (create_initial_state, optimize_utf8, analyze, postorder, preorder):
+ (optimize_subexps, lower_subexps, lower_subexp, calc_first, calc_next):
+ (link_nfa_nodes, duplicate_node_closure, search_duplicated_node):
+ (duplicate_node, calc_inveclosure, calc_eclosure, calc_eclosure_iter):
+ (fetch_token, peek_token, peek_token_bracket, parse, parse_reg_exp):
+ (parse_branch, parse_expression, parse_sub_exp, parse_dup_op):
+ (build_range_exp, build_collating_symbol, parse_bracket_exp):
+ (parse_bracket_element, parse_bracket_symbol, build_equiv_class):
+ (build_charclass, build_charclass_op, fetch_number, create_tree):
+ (create_token_tree, mark_opt_subexp, duplicate_tree):
+ Use prototypes rather than old-style definitions.
+ * regex_internal.c:
+ (re_string_allocate, re_string_construct, re_string_realloc_buffers):
+ (re_string_construct_common, build_wcs_buffer, build_wcs_upper_buffer):
+ (re_string_skip_chars, build_upper_buffer, re_string_translate_buffer):
+ (re_string_reconstruct, re_string_peek_byte_case):
+ (re_string_fetch_byte_case, re_string_destruct, re_string_context_at):
+ (re_node_set_alloc, re_node_set_init_1, re_node_set_init_2):
+ (re_node_set_init_copy, re_node_set_add_intersect):
+ (re_node_set_init_union, re_node_set_merge, re_node_set_insert):
+ (re_node_set_insert_last, re_node_set_compare, re_node_set_contains):
+ (re_node_set_remove_at, re_dfa_add_node, calc_state_hash):
+ (re_acquire_state, re_acquire_state_context, register_state):
+ (create_ci_newstate, create_cd_newstate, free_state):
+ Likewise.
+ * regexec.c (regexec, re_match, re_search, re_match_2, re_search_2):
+ (re_search_2_stub, re_search_stub, re_copy_regs, re_set_registers):
+ (re_search_internal, prune_impossible_nodes):
+ (acquire_init_state_context, check_matching, static):
+ (check_halt_node_context, check_halt_state_context, proceed_next_node):
+ (push_fail_stack, pop_fail_stack, set_regs, free_fail_stack_return):
+ (update_regs, sift_states_backward, build_sifted_states):
+ (clean_state_log_if_needed, merge_state_array):
+ (update_cur_sifted_state, add_epsilon_src_nodes):
+ (sub_epsilon_src_nodes, check_dst_limits, check_dst_limits_calc_pos_1):
+ (check_dst_limits_calc_pos, check_subexp_limits, sift_states_bkref):
+ (sift_states_iter_mb, transit_state, merge_state_with_log, static):
+ (find_recover_state, check_subexp_matching_top, transit_state_mb):
+ (transit_state_bkref, get_subexp, get_subexp_sub, find_subexp_node):
+ (check_arrival, check_arrival_add_next_nodes):
+ (check_arrival_expand_ecl, check_arrival_expand_ecl_sub):
+ (expand_bkref_cache, build_trtable, group_nodes_into_DFAstates):
+ (check_node_accept_bytes, check_node_accept, extend_buffers):
+ (match_ctx_init, match_ctx_clean, match_ctx_free, match_ctx_add_entry):
+ (search_cur_bkref_entry, match_ctx_add_subtop, match_ctx_add_sublast):
+ (sift_ctx_init):
+ Likewise.
+
+ * regex_internal.h:
+ (re_string_allocate, re_string_construct, re_string_reconstruct):
+ (re_string_realloc_buffers, build_wcs_buffer, build_wcs_upper_buffer):
+ (build_upper_buffer, re_string_translate_buffer, re_string_destruct):
+ (re_string_elem_size_at, re_string_char_size_at, re_string_wchar_at):
+ (re_string_context_at, re_string_peek_byte_case):
+ (re_string_fetch_byte_case): Declare even if RE_NO_INTERNAL_PROTOTYPES
+ is defined, since we now use prototypes always.
+
+ * regex.h (_RE_ARGS): Remove. No longer needed, since we assume
+ C89 or better. All uses removed.
+
2005-08-19 Paul Eggert <eggert@cs.ucla.edu>
* regex_internal.c (re_acquire_state, re_acquire_state_context)
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;
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;
#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;
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;
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
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;
/* 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))
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;
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
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;
/* 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;
/* 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;
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;
"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;
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;
}
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;
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;
/* 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;
}
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;
/* 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)
/* 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)
{
/* 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;
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)
{
int org_node, clone_node, ret;
unsigned int constraint = init_constraint;
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)
available. */
static int
-duplicate_node (dfa, org_idx, constraint)
- re_dfa_t *dfa;
- int org_idx;
- unsigned int constraint;
+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, 1))
}
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)
/* 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
/* 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;
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));
}
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;
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))
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;
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;
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;
*/
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;
*/
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;
/* 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);
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. */
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))
"[[.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;
/* 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;
[=<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;
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);
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;
}
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
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;
/* 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;
}
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))
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)
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;
/* 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.
\f
/* 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
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
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
#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
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;
/* 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));
/* 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)
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;
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];
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;
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;
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;
/* 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;
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))
}
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;
}
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);
}
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);
/* 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))
/* 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;
}
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;
}
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);
}
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)
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)
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)
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)
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. */
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)
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)
/* 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)
}
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;
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))
}
static unsigned int inline
-calc_state_hash (nodes, context)
- const re_node_set *nodes;
- unsigned int context;
+internal_function
+calc_state_hash (const re_node_set *nodes, unsigned int context)
{
unsigned int hash = nodes->nelem + context;
int i;
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;
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;
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;
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;
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;
}
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);
# 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,
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));
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) \
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;
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);
}
#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);
}
#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);
#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);
#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;
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;
}
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;
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)
{
(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;
}
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;
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;
+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)
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;
/* 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;
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;
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;
}
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++;
}
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);
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;
}
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)
{
}
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)
((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;
}
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;
/* 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
}
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;
#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;
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;
/* 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);
/* 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
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;
#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;
#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;
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;
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;
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)
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;
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;
*/
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;
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);)
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;
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;
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;
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;
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);
/* 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;
/* 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;
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)
/* 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);
*/
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)
{
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;
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);
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))
}
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;