git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elia Pinto <gitter.spiros@gmail.com>
To: git@vger.kernel.org
Cc: Elia Pinto <gitter.spiros@gmail.com>
Subject: [PATCH 3/6] compat/regex/regexec.c: reduce scope of variables
Date: Wed, 16 Apr 2014 02:33:28 -0700	[thread overview]
Message-ID: <1397640811-17719-3-git-send-email-gitter.spiros@gmail.com> (raw)
In-Reply-To: <1397640811-17719-1-git-send-email-gitter.spiros@gmail.com>

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 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

  parent reply	other threads:[~2014-04-16  9:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-16  9:33 [PATCH 1/6] compat/regex/regcomp.c: reduce scope of variables Elia Pinto
2014-04-16  9:33 ` [PATCH 2/6] compat/regex/regex_internal.c: " Elia Pinto
2014-04-16  9:33 ` Elia Pinto [this message]
2014-04-16  9:33 ` [PATCH 4/6] contrib/credential/osxkeychain/git-credential-osxkeychain.c: " Elia Pinto
2014-04-16  9:55   ` Erik Faye-Lund
2014-04-16  9:33 ` [PATCH 5/6] contrib/credential/wincred/git-credential-wincred.c: " Elia Pinto
2014-04-16  9:54   ` Erik Faye-Lund
2014-04-16  9:33 ` [PATCH 6/6] xdiff/xprepare.c: " Elia Pinto
2014-04-16  9:55   ` Erik Faye-Lund
2014-04-16 16:49 ` [PATCH 1/6] compat/regex/regcomp.c: " Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397640811-17719-3-git-send-email-gitter.spiros@gmail.com \
    --to=gitter.spiros@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).