changeset 18633:42cabb9832cd

dfa: narrow more local var scopes * lib/dfa.c: Move more local decls to be more local.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 02 Jan 2017 10:49:17 -0800
parents 2fe73d269172
children a2fc5a686baf
files ChangeLog lib/dfa.c
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jan 02 08:27:12 2017 -0800
+++ b/ChangeLog	Mon Jan 02 10:49:17 2017 -0800
@@ -1,5 +1,8 @@
 2017-01-02  Paul Eggert  <eggert@cs.ucla.edu>
 
+	dfa: narrow more local var scopes
+	* lib/dfa.c: Move more local decls to be more local.
+
 	dfa: remove duplicate assignment
 	Problem reported by Bruno Haible in:
 	http://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00007.html
--- a/lib/dfa.c	Mon Jan 02 08:27:12 2017 -0800
+++ b/lib/dfa.c	Mon Jan 02 10:49:17 2017 -0800
@@ -995,7 +995,6 @@
 parse_bracket_exp (struct dfa *dfa)
 {
   int c;
-  charclass ccl;
 
   /* This is a bracket expression that dfaexec is known to
      process correctly.  */
@@ -1013,6 +1012,7 @@
   wint_t wc1 = 0;
 
   dfa->lex.brack.nchars = 0;
+  charclass ccl;
   zeroset (&ccl);
   FETCH_WC (dfa, c, wc, _("unbalanced ["));
   bool invert = c == '^';
@@ -1255,7 +1255,6 @@
   for (int i = 0; i < 2; ++i)
     {
       int c;
-      charclass ccl;
       FETCH_WC (dfa, c, dfa->lex.wctok, NULL);
 
       switch (c)
@@ -1472,6 +1471,7 @@
             goto normal_char;
           if (dfa->canychar == (size_t) -1)
             {
+              charclass ccl;
               fillset (&ccl);
               if (!(dfa->syntax.syntax_bits & RE_DOT_NEWLINE))
                 clrbit ('\n', &ccl);
@@ -1494,6 +1494,7 @@
             goto normal_char;
           if (!dfa->localeinfo.multibyte)
             {
+              charclass ccl;
               zeroset (&ccl);
               for (int c2 = 0; c2 < NOTCHAR; ++c2)
                 if (isspace (c2))
@@ -1527,6 +1528,7 @@
 
           if (!dfa->localeinfo.multibyte)
             {
+              charclass ccl;
               zeroset (&ccl);
               for (int c2 = 0; c2 < NOTCHAR; ++c2)
                 if (dfa->syntax.sbit[c2] == CTX_LETTER)
@@ -1569,6 +1571,7 @@
 
           if (dfa->syntax.case_fold && isalpha (c))
             {
+              charclass ccl;
               zeroset (&ccl);
               setbit_case_fold_c (c, &ccl);
               return dfa->lex.lasttok = CSET + charclass_index (dfa, &ccl);
@@ -2596,8 +2599,6 @@
 static state_num
 dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
 {
-  leaf_set group;               /* Positions that match the input char.  */
-  charclass label;              /* The group's label.  */
   position_set follows;         /* Union of the follows of the group.  */
   position_set tmp;             /* Temporary space for merging sets.  */
   state_num state;              /* New state.  */
@@ -2608,9 +2609,13 @@
   fprintf (stderr, "build state %td\n", s);
 #endif
 
+  /* Positions that match the input char.  */
+  leaf_set group;
   group.elems = xnmalloc (d->nleaves, sizeof *group.elems);
   group.nelem = 0;
 
+  /* The group's label.  */
+  charclass label;
   fillset (&label);
 
   for (size_t i = 0; i < d->states[s].elems.nelem; ++i)