Re: const-correctness fixes for regex

2005-09-01 Thread Jim Meyering
Paul Eggert <[EMAIL PROTECTED]> wrote:
> Jim Meyering <[EMAIL PROTECTED]> writes:
>> 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.
>
> It's easier for me if I just get it off the plate and install it now.
> I installed this into gnulib and filed glibc bug 1282.  Thanks.

Thanks for doing that!

> I wish missing-const-detection could be done automatically.

Same here.


___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: const-correctness fixes for regex

2005-08-31 Thread Paul Eggert
Jim Meyering <[EMAIL PROTECTED]> writes:

> 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.

It's easier for me if I just get it off the plate and install it now.
I installed this into gnulib and filed glibc bug 1282.  Thanks.

I wish missing-const-detection could be done automatically.  I suppose
we could add const to all the pointers, and then remove each const
that causes a diagnostic, but that sounds pretty painful

2005-08-31  Jim Meyering  <[EMAIL PROTECTED]>

* lib/regcomp.c (search_duplicated_node): Make first pointer arg
a pointer-to-const.
* lib/regex_internal.c (create_ci_newstate, create_cd_newstate):
(register_state): Likewise.
* lib/regexec.c (search_cur_bkref_entry, check_dst_limits):
(check_dst_limits_calc_pos_1, check_dst_limits_calc_pos):
(group_nodes_into_DFAstates): Likewise.
* config/srclist.txt: Add glibc bug 1282.

--- lib/regcomp.c   31 Aug 2005 22:51:10 -  1.13
+++ lib/regcomp.c   31 Aug 2005 23:25:36 -
@@ -46,7 +46,7 @@ static reg_errcode_t calc_first (void *e
 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 Idx duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int 
constraint);
-static Idx search_duplicated_node (re_dfa_t *dfa, Idx org_node,
+static Idx search_duplicated_node (const re_dfa_t *dfa, Idx 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 +1506,7 @@ duplicate_node_closure (re_dfa_t *dfa, I
satisfies the constraint CONSTRAINT.  */
 
 static Idx
-search_duplicated_node (re_dfa_t *dfa, Idx org_node,
+search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
unsigned int constraint)
 {
   Idx idx;
--- lib/regex_internal.c31 Aug 2005 22:51:10 -  1.10
+++ lib/regex_internal.c31 Aug 2005 23:25:36 -
@@ -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,
  re_hashval_t 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,
  re_hashval_t hash) internal_function;
@@ -1465,7 +1465,7 @@ re_acquire_state_context (reg_errcode_t 
 
 static reg_errcode_t
 internal_function
-register_state (re_dfa_t *dfa, re_dfastate_t *newstate, re_hashval_t hash)
+register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, re_hashval_t 
hash)
 {
   struct re_state_table_entry *spot;
   reg_errcode_t err;
@@ -1502,7 +1502,8 @@ 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, re_hashval_t hash)
+create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
+   re_hashval_t hash)
 {
   Idx i;
   reg_errcode_t err;
@@ -1551,7 +1552,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, re_hashval_t hash)
 {
   Idx i, nctx_nodes = 0;
--- lib/regexec.c   31 Aug 2005 22:51:10 -  1.13
+++ lib/regexec.c   31 Aug 2005 23:25:36 -
@@ -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, Idx node,
  Idx str_idx, Idx from, Idx to)
  internal_function;
-static Idx search_cur_bkref_entry (re_match_context_t *mctx, Idx str_idx)
+static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
  internal_function;
 static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node,
   Idx str_idx) internal_function;
@@ -91,13 +91,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,