[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
const-correctness fixes for regex
From: |
Jim Meyering |
Subject: |
const-correctness fixes for regex |
Date: |
Wed, 31 Aug 2005 22:49:37 +0200 |
A week or so ago, I stumbled across one interface that was missing a
`const' attribute on a parameter, then dug up a few more. Paul, let me
know when you reach a point at which my checking this in won't interfere.
Index: regcomp.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regcomp.c,v
retrieving revision 1.9
diff -u -p -r1.9 regcomp.c
--- regcomp.c 25 Aug 2005 20:39:57 -0000 1.9
+++ regcomp.c 31 Aug 2005 20:43:01 -0000
@@ -45,8 +45,9 @@ static bin_tree_t *lower_subexp (reg_err
static reg_errcode_t calc_first (void *extra, bin_tree_t *node);
static reg_errcode_t calc_next (void *extra, bin_tree_t *node);
static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node);
-static int duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int
constraint);
-static int search_duplicated_node (re_dfa_t *dfa, int org_node,
+static int duplicate_node (re_dfa_t *dfa, int org_idx,
+ unsigned int constraint);
+static int search_duplicated_node (const re_dfa_t *dfa, int org_node,
unsigned int constraint);
static reg_errcode_t calc_eclosure (re_dfa_t *dfa);
static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa,
@@ -1506,7 +1507,8 @@ duplicate_node_closure (re_dfa_t *dfa, i
satisfies the constraint CONSTRAINT. */
static int
-search_duplicated_node (re_dfa_t *dfa, int org_node, unsigned int constraint)
+search_duplicated_node (const 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)
Index: regex_internal.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regex_internal.c,v
retrieving revision 1.9
diff -u -p -r1.9 regex_internal.c
--- regex_internal.c 26 Aug 2005 21:47:52 -0000 1.9
+++ regex_internal.c 31 Aug 2005 20:43:01 -0000
@@ -21,10 +21,10 @@ static void re_string_construct_common (
re_string_t *pstr,
REG_TRANSLATE_TYPE trans, int icase,
const re_dfa_t *dfa) internal_function;
-static re_dfastate_t *create_ci_newstate (re_dfa_t *dfa,
+static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
const re_node_set *nodes,
unsigned int hash) internal_function;
-static re_dfastate_t *create_cd_newstate (re_dfa_t *dfa,
+static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
const re_node_set *nodes,
unsigned int context,
unsigned int hash) internal_function;
@@ -1461,7 +1461,7 @@ re_acquire_state_context (reg_errcode_t
static reg_errcode_t
internal_function
-register_state (re_dfa_t *dfa, re_dfastate_t *newstate, unsigned int hash)
+register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, unsigned int
hash)
{
struct re_state_table_entry *spot;
reg_errcode_t err;
@@ -1498,7 +1498,7 @@ register_state (re_dfa_t *dfa, re_dfasta
static re_dfastate_t *
internal_function
-create_ci_newstate (re_dfa_t *dfa, const re_node_set *nodes, unsigned int hash)
+create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, unsigned
int hash)
{
int i;
reg_errcode_t err;
@@ -1547,7 +1547,7 @@ create_ci_newstate (re_dfa_t *dfa, const
static re_dfastate_t *
internal_function
-create_cd_newstate (re_dfa_t *dfa, const re_node_set *nodes,
+create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
unsigned int context, unsigned int hash)
{
int i, nctx_nodes = 0;
Index: regexec.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regexec.c,v
retrieving revision 1.9
diff -u -p -r1.9 regexec.c
--- regexec.c 26 Aug 2005 05:58:55 -0000 1.9
+++ regexec.c 31 Aug 2005 20:43:02 -0000
@@ -24,7 +24,7 @@ static void match_ctx_free (re_match_con
static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, int node,
int str_idx, int from, int to)
internal_function;
-static int search_cur_bkref_entry (re_match_context_t *mctx, int str_idx)
+static int search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx)
internal_function;
static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, int node,
int str_idx) internal_function;
@@ -89,13 +89,14 @@ static reg_errcode_t update_cur_sifted_s
static reg_errcode_t add_epsilon_src_nodes (re_dfa_t *dfa,
re_node_set *dest_nodes,
const re_node_set *candidates)
internal_function;
-static int check_dst_limits (re_match_context_t *mctx, re_node_set *limits,
+static int check_dst_limits (const re_match_context_t *mctx,
+ const re_node_set *limits,
int dst_node, int dst_idx, int src_node,
int src_idx) internal_function;
-static int check_dst_limits_calc_pos_1 (re_match_context_t *mctx,
+static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
int boundaries, int subexp_idx,
int from_node, int bkref_idx)
internal_function;
-static int check_dst_limits_calc_pos (re_match_context_t *mctx,
+static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
int limit, int subexp_idx,
int node, int str_idx,
int bkref_idx) internal_function;
@@ -168,7 +169,7 @@ static unsigned int find_collation_seque
size_t name_len)
internal_function;
# endif /* _LIBC */
#endif /* RE_ENABLE_I18N */
-static int group_nodes_into_DFAstates (re_dfa_t *dfa,
+static int group_nodes_into_DFAstates (const re_dfa_t *dfa,
const re_dfastate_t *state,
re_node_set *states_node,
bitset *states_ch) internal_function;
@@ -1834,7 +1835,7 @@ sub_epsilon_src_nodes (re_dfa_t *dfa, in
static int
internal_function
-check_dst_limits (re_match_context_t *mctx, re_node_set *limits,
+check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
int dst_node, int dst_idx, int src_node, int src_idx)
{
re_dfa_t *const dfa = mctx->dfa;
@@ -1870,7 +1871,7 @@ check_dst_limits (re_match_context_t *mc
static int
internal_function
-check_dst_limits_calc_pos_1 (re_match_context_t *mctx, int boundaries,
+check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
int subexp_idx, int from_node, int bkref_idx)
{
re_dfa_t *const dfa = mctx->dfa;
@@ -1948,7 +1949,8 @@ check_dst_limits_calc_pos_1 (re_match_co
static int
internal_function
-check_dst_limits_calc_pos (re_match_context_t *mctx, int limit, int subexp_idx,
+check_dst_limits_calc_pos (const 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;
@@ -3458,7 +3460,7 @@ out_free:
static int
internal_function
-group_nodes_into_DFAstates (re_dfa_t *dfa, const re_dfastate_t *state,
+group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
re_node_set *dests_node, bitset *dests_ch)
{
reg_errcode_t err;
@@ -4179,7 +4181,7 @@ match_ctx_add_entry (re_match_context_t
static int
internal_function
-search_cur_bkref_entry (re_match_context_t *mctx, int str_idx)
+search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx)
{
int left, right, mid, last;
last = right = mctx->nbkref_ents;
- const-correctness fixes for regex,
Jim Meyering <=