* src/lalr.c (set_goto_map): Remove a wrong but benign loop
authorAkim Demaille <akim@epita.fr>
Thu, 27 Dec 2001 18:07:05 +0000 (18:07 +0000)
committerAkim Demaille <akim@epita.fr>
Thu, 27 Dec 2001 18:07:05 +0000 (18:07 +0000)
duplication.

ChangeLog
src/lalr.c
src/output.c

index 1d4e28e..1e3b31c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2001-12-27  Akim Demaille  <akim@epita.fr>
 
+       * src/lalr.c (set_goto_map): Remove a wrong but benign loop
+       duplication.
+
+       
+2001-12-27  Akim Demaille  <akim@epita.fr>
+
        * src/reader.c (packgram): Catch nitems overflows.
 
        
index 8617ae8..1dfb293 100644 (file)
@@ -159,12 +159,8 @@ initialize_LA (void)
 static void
 set_goto_map (void)
 {
-  int state;
-  int i;
-  int symbol;
-  int k;
+  int state, i;
   short *temp_map;
-  int state2;
 
   goto_map = XCALLOC (short, nvars + 1) - ntokens;
   temp_map = XCALLOC (short, nvars + 1) - ntokens;
@@ -175,7 +171,7 @@ set_goto_map (void)
       shifts *sp = state_table[state]->shifts;
       for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
        {
-         symbol = state_table[sp->shifts[i]]->accessing_symbol;
+         int symbol = state_table[sp->shifts[i]]->accessing_symbol;
 
          if (ngotos == MAXSHORT)
            fatal (_("too many gotos (max %d)"), MAXSHORT);
@@ -185,18 +181,20 @@ set_goto_map (void)
        }
     }
 
-  k = 0;
-  for (i = ntokens; i < nsyms; i++)
-    {
-      temp_map[i] = k;
-      k += goto_map[i];
-    }
+  {
+    int k = 0;
+    for (i = ntokens; i < nsyms; i++)
+      {
+       temp_map[i] = k;
+       k += goto_map[i];
+      }
 
-  for (i = ntokens; i < nsyms; i++)
-    goto_map[i] = temp_map[i];
+    for (i = ntokens; i < nsyms; i++)
+      goto_map[i] = temp_map[i];
 
-  goto_map[nsyms] = ngotos;
-  temp_map[nsyms] = ngotos;
+    goto_map[nsyms] = ngotos;
+    temp_map[nsyms] = ngotos;
+  }
 
   from_state = XCALLOC (short, ngotos);
   to_state = XCALLOC (short, ngotos);
@@ -206,15 +204,12 @@ set_goto_map (void)
       shifts *sp = state_table[state]->shifts;
       for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
        {
-         for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
-           {
-             state2 = sp->shifts[i];
-             symbol = state_table[state2]->accessing_symbol;
+         int state2 = sp->shifts[i];
+         int symbol = state_table[state2]->accessing_symbol;
 
-             k = temp_map[symbol]++;
-             from_state[k] = state;
-             to_state[k] = state2;
-           }
+         int k = temp_map[symbol]++;
+         from_state[k] = state;
+         to_state[k] = state2;
        }
     }
 
index 43935f5..dfbfbb5 100644 (file)
@@ -133,10 +133,8 @@ get_lines_number (const char *s)
 
   size_t i;
   for (i = 0; s[i]; ++i)
-    {
-      if (s[i] == '\n')
-       ++lines;
-    }
+    if (s[i] == '\n')
+      ++lines;
 
   return lines;
 }