[PATCH 3/6] compat/regex/regexec.c: reduce scope of variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Elia Pinto <gitter.spiros@xxxxxxxxx>
---
 compat/regex/regexec.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/compat/regex/regexec.c b/compat/regex/regexec.c
index eb5e1d4..f86dbeb 100644
--- a/compat/regex/regexec.c
+++ b/compat/regex/regexec.c
@@ -1254,12 +1254,12 @@ proceed_next_node (const re_match_context_t *mctx, int nregs, regmatch_t *regs,
 		   struct re_fail_stack_t *fs)
 {
   const re_dfa_t *const dfa = mctx->dfa;
-  int i, err;
+  int err;
   if (IS_EPSILON_NODE (dfa->nodes[node].type))
     {
       re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
       re_node_set *edests = &dfa->edests[node];
-      int dest_node;
+      int dest_node, i;
       err = re_node_set_insert (eps_via_nodes, node);
       if (BE (err < 0, 0))
 	return -2;
@@ -1446,9 +1446,9 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
 
       if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
 	{
-	  int reg_idx;
 	  if (fs)
 	    {
+	      int reg_idx;
 	      for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
 		if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
 		  break;
@@ -1818,7 +1818,6 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
 		       const re_node_set *candidates)
 {
   reg_errcode_t err = REG_NOERROR;
-  int i;
 
   re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
   if (BE (err != REG_NOERROR, 0))
@@ -1826,6 +1825,7 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
 
   if (!state->inveclosure.alloc)
     {
+      int i;
       err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
       if (BE (err != REG_NOERROR, 0))
 	return REG_ESPACE;
@@ -3824,7 +3824,6 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
 # ifdef _LIBC
       const unsigned char *pin
 	= ((const unsigned char *) re_string_get_buffer (input) + str_idx);
-      int j;
       uint32_t nrules;
 # endif /* _LIBC */
       int match_len = 0;
@@ -3867,6 +3866,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
 	  for (i = 0; i < cset->ncoll_syms; ++i)
 	    {
 	      const unsigned char *coll_sym = extra + cset->coll_syms[i];
+              int j;
 	      /* Compare the length of input collating element and
 		 the length of current collating element.  */
 	      if (*coll_sym != elem_len)
@@ -4004,13 +4004,14 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
 
       for (idx = 0; idx < extrasize;)
 	{
-	  int mbs_cnt, found = 0;
+	  int found = 0;
 	  int32_t elem_mbs_len;
 	  /* Skip the name of collating element name.  */
 	  idx = idx + extra[idx] + 1;
 	  elem_mbs_len = extra[idx++];
 	  if (mbs_len == elem_mbs_len)
-	    {
+	    { 
+              init mbs_cnt;
 	      for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt)
 		if (extra[idx + mbs_cnt] != mbs[mbs_cnt])
 		  break;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]