summaryrefslogtreecommitdiff
path: root/lib/regexec.c
diff options
context:
space:
mode:
authorClint Adams <clint@debian.org>2018-07-04 13:05:31 -0400
committerClint Adams <clint@debian.org>2018-07-04 13:05:31 -0400
commit117dcd10d7e04d0dda7668518b8d085027f4d705 (patch)
treef9612d6268ab16555fb21be04bc7594f9eb6ce4f /lib/regexec.c
parent1c0d840cad3dc7c951a86c9c128a721e9ebcd2cf (diff)
New upstream version 4.5
Diffstat (limited to 'lib/regexec.c')
-rw-r--r--lib/regexec.c234
1 files changed, 84 insertions, 150 deletions
diff --git a/lib/regexec.c b/lib/regexec.c
index 45bc796..fc18850 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -15,192 +15,162 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
- Idx n) internal_function;
-static void match_ctx_clean (re_match_context_t *mctx) internal_function;
-static void match_ctx_free (re_match_context_t *cache) internal_function;
+ Idx n);
+static void match_ctx_clean (re_match_context_t *mctx);
+static void match_ctx_free (re_match_context_t *cache);
static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node,
- Idx str_idx, Idx from, Idx to)
- internal_function;
-static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
- internal_function;
+ Idx str_idx, Idx from, Idx to);
+static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx);
static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node,
- Idx str_idx) internal_function;
+ Idx str_idx);
static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop,
- Idx node, Idx str_idx)
- internal_function;
+ Idx node, Idx str_idx);
static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
re_dfastate_t **limited_sts, Idx last_node,
- Idx last_str_idx)
- internal_function;
+ Idx last_str_idx);
static reg_errcode_t re_search_internal (const regex_t *preg,
const char *string, Idx length,
Idx start, Idx last_start, Idx stop,
size_t nmatch, regmatch_t pmatch[],
- int eflags) internal_function;
+ int eflags);
static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp,
const char *string1, Idx length1,
const char *string2, Idx length2,
Idx start, regoff_t range,
struct re_registers *regs,
- Idx stop, bool ret_len) internal_function;
+ Idx stop, bool ret_len);
static regoff_t re_search_stub (struct re_pattern_buffer *bufp,
const char *string, Idx length, Idx start,
regoff_t range, Idx stop,
struct re_registers *regs,
- bool ret_len) internal_function;
+ bool ret_len);
static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
- Idx nregs, int regs_allocated) internal_function;
-static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
- internal_function;
+ Idx nregs, int regs_allocated);
+static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx);
static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match,
- Idx *p_match_first) internal_function;
+ Idx *p_match_first);
static Idx check_halt_state_context (const re_match_context_t *mctx,
- const re_dfastate_t *state, Idx idx)
- internal_function;
+ const re_dfastate_t *state, Idx idx);
static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
regmatch_t *prev_idx_match, Idx cur_node,
- Idx cur_idx, Idx nmatch) internal_function;
+ Idx cur_idx, Idx nmatch);
static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
Idx str_idx, Idx dest_node, Idx nregs,
regmatch_t *regs,
- re_node_set *eps_via_nodes)
- internal_function;
+ re_node_set *eps_via_nodes);
static reg_errcode_t set_regs (const regex_t *preg,
const re_match_context_t *mctx,
size_t nmatch, regmatch_t *pmatch,
- bool fl_backtrack) internal_function;
-static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs)
- internal_function;
+ bool fl_backtrack);
+static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs);
#ifdef RE_ENABLE_I18N
static int sift_states_iter_mb (const re_match_context_t *mctx,
re_sift_context_t *sctx,
- Idx node_idx, Idx str_idx, Idx max_str_idx)
- internal_function;
+ Idx node_idx, Idx str_idx, Idx max_str_idx);
#endif /* RE_ENABLE_I18N */
static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
- re_sift_context_t *sctx)
- internal_function;
+ re_sift_context_t *sctx);
static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
re_sift_context_t *sctx, Idx str_idx,
- re_node_set *cur_dest)
- internal_function;
+ re_node_set *cur_dest);
static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx,
re_sift_context_t *sctx,
Idx str_idx,
- re_node_set *dest_nodes)
- internal_function;
+ re_node_set *dest_nodes);
static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa,
re_node_set *dest_nodes,
- const re_node_set *candidates)
- internal_function;
+ const re_node_set *candidates);
static bool check_dst_limits (const re_match_context_t *mctx,
const re_node_set *limits,
Idx dst_node, Idx dst_idx, Idx src_node,
- Idx src_idx) internal_function;
+ Idx src_idx);
static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
int boundaries, Idx subexp_idx,
- Idx from_node, Idx bkref_idx)
- internal_function;
+ Idx from_node, Idx bkref_idx);
static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
Idx limit, Idx subexp_idx,
Idx node, Idx str_idx,
- Idx bkref_idx) internal_function;
+ Idx bkref_idx);
static reg_errcode_t check_subexp_limits (const 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,
- Idx str_idx) internal_function;
+ Idx str_idx);
static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
re_sift_context_t *sctx,
- Idx str_idx, const re_node_set *candidates)
- internal_function;
+ Idx str_idx, const re_node_set *candidates);
static reg_errcode_t merge_state_array (const re_dfa_t *dfa,
re_dfastate_t **dst,
- re_dfastate_t **src, Idx num)
- internal_function;
+ re_dfastate_t **src, Idx num);
static re_dfastate_t *find_recover_state (reg_errcode_t *err,
- re_match_context_t *mctx) internal_function;
+ re_match_context_t *mctx);
static re_dfastate_t *transit_state (reg_errcode_t *err,
re_match_context_t *mctx,
- re_dfastate_t *state) internal_function;
+ re_dfastate_t *state);
static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
re_match_context_t *mctx,
- re_dfastate_t *next_state)
- internal_function;
+ re_dfastate_t *next_state);
static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
re_node_set *cur_nodes,
- Idx str_idx) internal_function;
+ Idx str_idx);
#if 0
static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
re_match_context_t *mctx,
- re_dfastate_t *pstate)
- internal_function;
+ re_dfastate_t *pstate);
#endif
#ifdef RE_ENABLE_I18N
static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
- re_dfastate_t *pstate)
- internal_function;
+ re_dfastate_t *pstate);
#endif /* RE_ENABLE_I18N */
static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
- const re_node_set *nodes)
- internal_function;
+ const re_node_set *nodes);
static reg_errcode_t get_subexp (re_match_context_t *mctx,
- Idx bkref_node, Idx bkref_str_idx)
- internal_function;
+ Idx bkref_node, Idx bkref_str_idx);
static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
const re_sub_match_top_t *sub_top,
re_sub_match_last_t *sub_last,
- Idx bkref_node, Idx bkref_str)
- internal_function;
+ Idx bkref_node, Idx bkref_str);
static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
- Idx subexp_idx, int type) internal_function;
+ Idx subexp_idx, int type);
static reg_errcode_t check_arrival (re_match_context_t *mctx,
state_array_t *path, Idx top_node,
Idx top_str, Idx last_node, Idx last_str,
- int type) internal_function;
+ int type);
static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
Idx str_idx,
re_node_set *cur_nodes,
- re_node_set *next_nodes)
- internal_function;
+ re_node_set *next_nodes);
static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa,
re_node_set *cur_nodes,
- Idx ex_subexp, int type)
- internal_function;
+ Idx ex_subexp, int type);
static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa,
re_node_set *dst_nodes,
Idx target, Idx ex_subexp,
- int type) internal_function;
+ int type);
static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
re_node_set *cur_nodes, Idx cur_str,
- Idx subexp_num, int type)
- internal_function;
-static bool build_trtable (const re_dfa_t *dfa,
- re_dfastate_t *state) internal_function;
+ Idx subexp_num, int type);
+static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state);
#ifdef RE_ENABLE_I18N
static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
- const re_string_t *input, Idx idx)
- internal_function;
+ const re_string_t *input, Idx idx);
# ifdef _LIBC
static unsigned int find_collation_sequence_value (const unsigned char *mbs,
- size_t name_len)
- internal_function;
+ size_t name_len);
# endif /* _LIBC */
#endif /* RE_ENABLE_I18N */
static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
const re_dfastate_t *state,
re_node_set *states_node,
- bitset_t *states_ch) internal_function;
+ bitset_t *states_ch);
static bool check_node_accept (const re_match_context_t *mctx,
- const re_token_t *node, Idx idx)
- internal_function;
-static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
- internal_function;
+ const re_token_t *node, Idx idx);
+static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
/* Entry point for POSIX code. */
@@ -252,6 +222,8 @@ regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string,
}
#ifdef _LIBC
+libc_hidden_def (__regexec)
+
# include <shlib-compat.h>
versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
@@ -346,7 +318,6 @@ weak_alias (__re_search_2, re_search_2)
#endif
static regoff_t
-internal_function
re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
Idx length1, const char *string2, Idx length2, Idx start,
regoff_t range, struct re_registers *regs,
@@ -395,7 +366,6 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
otherwise the position of the match is returned. */
static regoff_t
-internal_function
re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
Idx start, regoff_t range, Idx stop, struct re_registers *regs,
bool ret_len)
@@ -485,7 +455,6 @@ re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
}
static unsigned
-internal_function
re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
int regs_allocated)
{
@@ -611,7 +580,7 @@ re_exec (const char *s)
(0 <= LAST_START && LAST_START <= LENGTH) */
static reg_errcode_t
-__attribute_warn_unused_result__ internal_function
+__attribute_warn_unused_result__
re_search_internal (const regex_t *preg, const char *string, Idx length,
Idx start, Idx last_start, Idx stop, size_t nmatch,
regmatch_t pmatch[], int eflags)
@@ -945,7 +914,7 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
}
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
prune_impossible_nodes (re_match_context_t *mctx)
{
const re_dfa_t *const dfa = mctx->dfa;
@@ -1041,7 +1010,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
since initial states may have constraints like "\<", "^", etc.. */
static inline re_dfastate_t *
-__attribute__ ((always_inline)) internal_function
+__attribute__ ((always_inline))
acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
Idx idx)
{
@@ -1083,7 +1052,7 @@ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
index of the buffer. */
static Idx
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
check_matching (re_match_context_t *mctx, bool fl_longest_match,
Idx *p_match_first)
{
@@ -1216,7 +1185,6 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
/* Check NODE match the current context. */
static bool
-internal_function
check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
{
re_token_type_t type = dfa->nodes[node].type;
@@ -1235,7 +1203,6 @@ check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
match the context, return the node. */
static Idx
-internal_function
check_halt_state_context (const re_match_context_t *mctx,
const re_dfastate_t *state, Idx idx)
{
@@ -1257,7 +1224,6 @@ check_halt_state_context (const re_match_context_t *mctx,
return -1 in case of errors. */
static Idx
-internal_function
proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
Idx *pidx, Idx node, re_node_set *eps_via_nodes,
struct re_fail_stack_t *fs)
@@ -1359,7 +1325,7 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
}
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
{
@@ -1368,8 +1334,8 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
if (fs->num == fs->alloc)
{
struct re_fail_stack_ent_t *new_array;
- new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t)
- * fs->alloc * 2));
+ new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t,
+ fs->alloc * 2);
if (new_array == NULL)
return REG_ESPACE;
fs->alloc *= 2;
@@ -1386,7 +1352,6 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
}
static Idx
-internal_function
pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
regmatch_t *regs, re_node_set *eps_via_nodes)
{
@@ -1406,7 +1371,7 @@ pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
regmatch_t *pmatch, bool fl_backtrack)
{
@@ -1513,7 +1478,6 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
}
static reg_errcode_t
-internal_function
free_fail_stack_return (struct re_fail_stack_t *fs)
{
if (fs)
@@ -1530,7 +1494,6 @@ free_fail_stack_return (struct re_fail_stack_t *fs)
}
static void
-internal_function
update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch)
{
@@ -1602,7 +1565,6 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
((state) != NULL && re_node_set_contains (&(state)->nodes, node))
static reg_errcode_t
-internal_function
sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
{
reg_errcode_t err;
@@ -1660,7 +1622,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
}
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
Idx str_idx, re_node_set *cur_dest)
{
@@ -1722,7 +1684,6 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
/* Helper functions. */
static reg_errcode_t
-internal_function
clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
{
Idx top = mctx->state_log_top;
@@ -1748,7 +1709,6 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
}
static reg_errcode_t
-internal_function
merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
re_dfastate_t **src, Idx num)
{
@@ -1775,7 +1735,6 @@ merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
}
static reg_errcode_t
-internal_function
update_cur_sifted_state (const re_match_context_t *mctx,
re_sift_context_t *sctx, Idx str_idx,
re_node_set *dest_nodes)
@@ -1823,7 +1782,7 @@ update_cur_sifted_state (const re_match_context_t *mctx,
}
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
const re_node_set *candidates)
{
@@ -1852,7 +1811,6 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
}
static reg_errcode_t
-internal_function
sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
const re_node_set *candidates)
{
@@ -1901,7 +1859,6 @@ sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
}
static bool
-internal_function
check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx)
{
@@ -1937,7 +1894,6 @@ check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
}
static int
-internal_function
check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
Idx subexp_idx, Idx from_node, Idx bkref_idx)
{
@@ -2019,7 +1975,6 @@ check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
}
static int
-internal_function
check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
Idx subexp_idx, Idx from_node, Idx str_idx,
Idx bkref_idx)
@@ -2049,7 +2004,6 @@ check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
which are against limitations from DEST_NODES. */
static reg_errcode_t
-internal_function
check_subexp_limits (const 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, Idx str_idx)
@@ -2137,7 +2091,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
}
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
Idx str_idx, const re_node_set *candidates)
{
@@ -2237,7 +2191,6 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
#ifdef RE_ENABLE_I18N
static int
-internal_function
sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
Idx node_idx, Idx str_idx, Idx max_str_idx)
{
@@ -2267,7 +2220,7 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
update the destination of STATE_LOG. */
static re_dfastate_t *
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
transit_state (reg_errcode_t *err, re_match_context_t *mctx,
re_dfastate_t *state)
{
@@ -2325,7 +2278,6 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
/* Update the state_log if we need */
static re_dfastate_t *
-internal_function
merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
re_dfastate_t *next_state)
{
@@ -2404,7 +2356,6 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
multi-byte match, then look in the log for a state
from which to restart matching. */
static re_dfastate_t *
-internal_function
find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
{
re_dfastate_t *cur_state;
@@ -2435,7 +2386,6 @@ find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
corresponding back references. */
static reg_errcode_t
-internal_function
check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
Idx str_idx)
{
@@ -2508,7 +2458,6 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
#ifdef RE_ENABLE_I18N
static reg_errcode_t
-internal_function
transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
{
const re_dfa_t *const dfa = mctx->dfa;
@@ -2579,7 +2528,6 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
#endif /* RE_ENABLE_I18N */
static reg_errcode_t
-internal_function
transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
{
const re_dfa_t *const dfa = mctx->dfa;
@@ -2693,7 +2641,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
delay these checking for prune_impossible_nodes(). */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
{
const re_dfa_t *const dfa = mctx->dfa;
@@ -2843,7 +2791,6 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
and SUB_LAST. */
static reg_errcode_t
-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, Idx bkref_node, Idx bkref_str)
{
@@ -2872,7 +2819,6 @@ get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
E.g. RE: (a){2} */
static Idx
-internal_function
find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
Idx subexp_idx, int type)
{
@@ -2894,7 +2840,7 @@ find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
Idx top_str, Idx last_node, Idx last_str, int type)
{
@@ -3059,7 +3005,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
Can't we unify them? */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
re_node_set *cur_nodes, re_node_set *next_nodes)
{
@@ -3140,7 +3086,6 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
*/
static reg_errcode_t
-internal_function
check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
Idx ex_subexp, int type)
{
@@ -3193,7 +3138,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
problematic append it to DST_NODES. */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
Idx target, Idx ex_subexp, int type)
{
@@ -3238,7 +3183,7 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
in MCTX->BKREF_ENTS. */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
Idx cur_str, Idx subexp_num, int type)
{
@@ -3327,7 +3272,6 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
Return true if successful. */
static bool
-internal_function
build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
{
reg_errcode_t err;
@@ -3375,7 +3319,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
if (BE (ndests <= 0, 0))
{
if (dests_node_malloced)
- free (dests_alloc);
+ re_free (dests_alloc);
/* Return false in case of an error, true otherwise. */
if (ndests == 0)
{
@@ -3405,18 +3349,17 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
alloca (ndests * 3 * sizeof (re_dfastate_t *));
else
{
- dest_states = (re_dfastate_t **)
- malloc (ndests * 3 * sizeof (re_dfastate_t *));
+ dest_states = re_malloc (re_dfastate_t *, ndests * 3);
if (BE (dest_states == NULL, 0))
{
out_free:
if (dest_states_malloced)
- free (dest_states);
+ re_free (dest_states);
re_node_set_free (&follows);
for (i = 0; i < ndests; ++i)
re_node_set_free (dests_node + i);
if (dests_node_malloced)
- free (dests_alloc);
+ re_free (dests_alloc);
return false;
}
dest_states_malloced = true;
@@ -3547,14 +3490,14 @@ out_free:
}
if (dest_states_malloced)
- free (dest_states);
+ re_free (dest_states);
re_node_set_free (&follows);
for (i = 0; i < ndests; ++i)
re_node_set_free (dests_node + i);
if (dests_node_malloced)
- free (dests_alloc);
+ re_free (dests_alloc);
return true;
}
@@ -3565,7 +3508,6 @@ out_free:
to DEST_CH[i]. This function return the number of destinations. */
static Idx
-internal_function
group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
re_node_set *dests_node, bitset_t *dests_ch)
{
@@ -3762,7 +3704,6 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
# endif
static int
-internal_function
check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
const re_string_t *input, Idx str_idx)
{
@@ -3992,7 +3933,6 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
# ifdef _LIBC
static unsigned int
-internal_function
find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
{
uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -4056,7 +3996,6 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
byte of the INPUT. */
static bool
-internal_function
check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
Idx idx)
{
@@ -4078,7 +4017,7 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
case OP_UTF8_PERIOD:
if (ch >= ASCII_CHARS)
return false;
- /* FALLTHROUGH */
+ FALLTHROUGH;
#endif
case OP_PERIOD:
if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
@@ -4106,7 +4045,7 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
/* Extend the buffers, if the buffers have run out. */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
extend_buffers (re_match_context_t *mctx, int min_len)
{
reg_errcode_t ret;
@@ -4172,7 +4111,7 @@ extend_buffers (re_match_context_t *mctx, int min_len)
/* Initialize MCTX. */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
{
mctx->eflags = eflags;
@@ -4207,7 +4146,6 @@ match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
of the input, or changes the input string. */
static void
-internal_function
match_ctx_clean (re_match_context_t *mctx)
{
Idx st_idx;
@@ -4227,7 +4165,7 @@ match_ctx_clean (re_match_context_t *mctx)
re_free (top->path->array);
re_free (top->path);
}
- free (top);
+ re_free (top);
}
mctx->nsub_tops = 0;
@@ -4237,7 +4175,6 @@ match_ctx_clean (re_match_context_t *mctx)
/* Free all the memory associated with MCTX. */
static void
-internal_function
match_ctx_free (re_match_context_t *mctx)
{
/* First, free all the memory associated with MCTX->SUB_TOPS. */
@@ -4252,7 +4189,7 @@ match_ctx_free (re_match_context_t *mctx)
*/
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
Idx to)
{
@@ -4301,7 +4238,6 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
static Idx
-internal_function
search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
{
Idx left, right, mid, last;
@@ -4324,7 +4260,7 @@ search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
at STR_IDX. */
static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
{
#ifdef DEBUG
@@ -4354,7 +4290,6 @@ match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */
static re_sub_match_last_t *
-internal_function
match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
{
re_sub_match_last_t *new_entry;
@@ -4381,7 +4316,6 @@ match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
}
static void
-internal_function
sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx)
{