Discussion:
[PATCH] regex: merge from glibc
Add Reply
Paul Eggert
2017-11-21 00:00:24 UTC
Reply
Permalink
Raw Message
* lib/regcomp.c (__regcomp, __regfree) [_LIBC]: Now hidden.
* lib/regex_internal.h (internal_function): Remove.
All uses removed.
---
ChangeLog | 7 ++
lib/regcomp.c | 11 +--
lib/regex_internal.c | 59 ++++++---------
lib/regex_internal.h | 22 +++---
lib/regexec.c | 209 ++++++++++++++++++---------------------------------
5 files changed, 115 insertions(+), 193 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1d77e436e..45823beab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-20 Paul Eggert <***@cs.ucla.edu>
+
+ regex: merge from glibc
+ * lib/regcomp.c (__regcomp, __regfree) [_LIBC]: Now hidden.
+ * lib/regex_internal.h (internal_function): Remove.
+ All uses removed.
+
2017-11-20 Bruno Haible <***@clisp.org>

crypto/gc-sm3: Fix buffer overrun.
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 3d2d5c624..6dc8d72b3 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -59,7 +59,7 @@ static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
static Idx fetch_number (re_string_t *input, re_token_t *token,
reg_syntax_t syntax);
static int peek_token (re_token_t *token, re_string_t *input,
- reg_syntax_t syntax) internal_function;
+ 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,
@@ -516,6 +516,7 @@ regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags)
return (int) ret;
}
#ifdef _LIBC
+libc_hidden_def (__regcomp)
weak_alias (__regcomp, regcomp)
#endif

@@ -658,6 +659,7 @@ regfree (regex_t *preg)
preg->translate = NULL;
}
#ifdef _LIBC
+libc_hidden_def (__regfree)
weak_alias (__regfree, regfree)
#endif

@@ -935,7 +937,6 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
character used by some operators like "\<", "\>", etc. */

static void
-internal_function
init_word_char (re_dfa_t *dfa)
{
int i = 0;
@@ -1490,7 +1491,6 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
to their own constraint. */

static reg_errcode_t
-internal_function
duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
Idx root_node, unsigned int init_constraint)
{
@@ -1782,7 +1782,6 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
We must not use this function inside bracket expressions. */

static void
-internal_function
fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
{
re_string_skip_bytes (input, peek_token (result, input, syntax));
@@ -1792,7 +1791,6 @@ fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
We must not use this function inside bracket expressions. */

static int
-internal_function
peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
{
unsigned char c;
@@ -2031,7 +2029,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
We must not use this function out of bracket expressions. */

static int
-internal_function
peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
{
unsigned char c;
@@ -2706,7 +2703,6 @@ parse_byte (unsigned char b, re_charset_t *mbcset)
update it. */

static reg_errcode_t
-internal_function
# ifdef RE_ENABLE_I18N
build_range_exp (const reg_syntax_t syntax,
bitset_t sbcset,
@@ -2832,7 +2828,6 @@ build_range_exp (const reg_syntax_t syntax,
pointer argument since we may update it. */

static reg_errcode_t
-internal_function
# ifdef RE_ENABLE_I18N
build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
Idx *coll_sym_alloc, const unsigned char *name)
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index a05630eb2..efd38883c 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -20,14 +20,14 @@
static void re_string_construct_common (const char *str, Idx len,
re_string_t *pstr,
RE_TRANSLATE_TYPE trans, bool icase,
- const re_dfa_t *dfa) internal_function;
+ const re_dfa_t *dfa);
static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
const re_node_set *nodes,
- re_hashval_t hash) internal_function;
+ re_hashval_t hash);
static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
const re_node_set *nodes,
unsigned int context,
- re_hashval_t hash) internal_function;
+ re_hashval_t hash);

/* Functions for string operation. */

@@ -35,7 +35,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
re_string_reconstruct before using the object. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
{
@@ -63,7 +63,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
/* This function allocate the buffers, and initialize them. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_string_construct (re_string_t *pstr, const char *str, Idx len,
RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
{
@@ -126,7 +126,7 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
/* Helper functions for re_string_allocate, and re_string_construct. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
{
#ifdef RE_ENABLE_I18N
@@ -166,7 +166,6 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)


static void
-internal_function
re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
RE_TRANSLATE_TYPE trans, bool icase,
const re_dfa_t *dfa)
@@ -198,7 +197,6 @@ re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
built and starts from PSTR->VALID_LEN. */

static void
-internal_function
build_wcs_buffer (re_string_t *pstr)
{
#ifdef _LIBC
@@ -267,7 +265,7 @@ build_wcs_buffer (re_string_t *pstr)
but for REG_ICASE. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
build_wcs_upper_buffer (re_string_t *pstr)
{
mbstate_t prev_st;
@@ -484,7 +482,6 @@ build_wcs_upper_buffer (re_string_t *pstr)
Return the index. */

static Idx
-internal_function
re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
{
mbstate_t prev_st;
@@ -525,7 +522,6 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
This function is used in case of REG_ICASE. */

static void
-internal_function
build_upper_buffer (re_string_t *pstr)
{
Idx char_idx, end_idx;
@@ -545,7 +541,6 @@ build_upper_buffer (re_string_t *pstr)
/* Apply TRANS to the buffer in PSTR. */

static void
-internal_function
re_string_translate_buffer (re_string_t *pstr)
{
Idx buf_idx, end_idx;
@@ -566,7 +561,7 @@ re_string_translate_buffer (re_string_t *pstr)
convert to upper case in case of REG_ICASE, apply translation. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
{
Idx offset;
@@ -829,7 +824,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
}

static unsigned char
-internal_function __attribute__ ((pure))
+__attribute__ ((pure))
re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
{
int ch;
@@ -866,7 +861,6 @@ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
}

static unsigned char
-internal_function
re_string_fetch_byte_case (re_string_t *pstr)
{
if (BE (!pstr->mbs_allocated, 1))
@@ -904,7 +898,6 @@ re_string_fetch_byte_case (re_string_t *pstr)
}

static void
-internal_function
re_string_destruct (re_string_t *pstr)
{
#ifdef RE_ENABLE_I18N
@@ -918,7 +911,6 @@ re_string_destruct (re_string_t *pstr)
/* Return the context at IDX in INPUT. */

static unsigned int
-internal_function
re_string_context_at (const re_string_t *input, Idx idx, int eflags)
{
int c;
@@ -963,7 +955,7 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
/* Functions for set operation. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_alloc (re_node_set *set, Idx size)
{
set->alloc = size;
@@ -975,7 +967,7 @@ re_node_set_alloc (re_node_set *set, Idx size)
}

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_init_1 (re_node_set *set, Idx elem)
{
set->alloc = 1;
@@ -991,7 +983,7 @@ re_node_set_init_1 (re_node_set *set, Idx elem)
}

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
{
set->alloc = 2;
@@ -1021,7 +1013,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
}

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
{
dest->nelem = src->nelem;
@@ -1046,7 +1038,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
Note: We assume dest->elems is NULL, when dest->alloc is 0. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
const re_node_set *src2)
{
@@ -1137,7 +1129,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
DEST. Return value indicate the error code or REG_NOERROR if succeeded. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
const re_node_set *src2)
{
@@ -1190,7 +1182,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
DEST. Return value indicate the error code or REG_NOERROR if succeeded. */

static reg_errcode_t
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_merge (re_node_set *dest, const re_node_set *src)
{
Idx is, id, sbase, delta;
@@ -1273,7 +1265,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
Return true if successful. */

static bool
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_insert (re_node_set *set, Idx elem)
{
Idx idx;
@@ -1325,7 +1317,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
Return true if successful. */

static bool
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_node_set_insert_last (re_node_set *set, Idx elem)
{
/* Realloc if we need. */
@@ -1348,7 +1340,7 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
Return true if SET1 and SET2 are equivalent. */

static bool
-internal_function __attribute__ ((pure))
+__attribute__ ((pure))
re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
{
Idx i;
@@ -1363,7 +1355,7 @@ re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */

static Idx
-internal_function __attribute__ ((pure))
+__attribute__ ((pure))
re_node_set_contains (const re_node_set *set, Idx elem)
{
__re_size_t idx, right, mid;
@@ -1385,7 +1377,6 @@ re_node_set_contains (const re_node_set *set, Idx elem)
}

static void
-internal_function
re_node_set_remove_at (re_node_set *set, Idx idx)
{
if (idx < 0 || idx >= set->nelem)
@@ -1400,7 +1391,6 @@ re_node_set_remove_at (re_node_set *set, Idx idx)
Or return -1 if an error occurred. */

static Idx
-internal_function
re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
{
if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
@@ -1454,7 +1444,6 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
}

static re_hashval_t
-internal_function
calc_state_hash (const re_node_set *nodes, unsigned int context)
{
re_hashval_t hash = nodes->nelem + context;
@@ -1474,7 +1463,7 @@ calc_state_hash (const re_node_set *nodes, unsigned int context)
optimization. */

static re_dfastate_t *
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
const re_node_set *nodes)
{
@@ -1522,7 +1511,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
optimization. */

static re_dfastate_t *
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
const re_node_set *nodes, unsigned int context)
{
@@ -1618,7 +1607,7 @@ free_state (re_dfastate_t *state)
Return the new state if succeeded, otherwise return NULL. */

static re_dfastate_t *
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
re_hashval_t hash)
{
@@ -1668,7 +1657,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
Return the new state if succeeded, otherwise return NULL. */

static re_dfastate_t *
-internal_function __attribute_warn_unused_result__
+__attribute_warn_unused_result__
create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
unsigned int context, re_hashval_t hash)
{
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index d030969b0..09cae0c97 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -438,23 +438,19 @@ struct re_dfa_t;
typedef struct re_dfa_t re_dfa_t;

#ifndef _LIBC
-# define internal_function
# define IS_IN(libc) false
#endif

static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
- Idx new_buf_len)
- internal_function;
+ Idx new_buf_len);
#ifdef RE_ENABLE_I18N
-static void build_wcs_buffer (re_string_t *pstr) internal_function;
-static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr)
- internal_function;
+static void build_wcs_buffer (re_string_t *pstr);
+static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr);
#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 build_upper_buffer (re_string_t *pstr);
+static void re_string_translate_buffer (re_string_t *pstr);
static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
- int eflags)
- internal_function __attribute__ ((pure));
+ int eflags) __attribute__ ((pure));

#define re_string_peek_byte(pstr, offset) \
((pstr)->mbs[(pstr)->cur_idx + offset])
@@ -831,7 +827,7 @@ bitset_mask (bitset_t dest, const bitset_t src)
#ifdef RE_ENABLE_I18N
/* Functions for re_string. */
static int
-internal_function __attribute__ ((pure, unused))
+__attribute__ ((pure, unused))
re_string_char_size_at (const re_string_t *pstr, Idx idx)
{
int byte_idx;
@@ -844,7 +840,7 @@ re_string_char_size_at (const re_string_t *pstr, Idx idx)
}

static wint_t
-internal_function __attribute__ ((pure, unused))
+__attribute__ ((pure, unused))
re_string_wchar_at (const re_string_t *pstr, Idx idx)
{
if (pstr->mb_cur_max == 1)
@@ -857,7 +853,7 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
# endif

static int
-internal_function __attribute__ ((pure, unused))
+__attribute__ ((pure, unused))
re_string_elem_size_at (const re_string_t *pstr, Idx idx)
{
# ifdef _LIBC
diff --git a/lib/regexec.c b/lib/regexec.c
index 445710755..262384cfc 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -18,189 +18,159 @@
<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)
{
@@ -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;
@@ -3565,7 +3509,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 +3705,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 +3934,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 +3997,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)
{
@@ -4106,7 +4046,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 +4112,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 +4147,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;
@@ -4237,7 +4176,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 +4190,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 +4239,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 +4261,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 +4291,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 +4317,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)
{
--
2.14.3
Loading...