bison-patches
[Top][All Lists]
Advanced

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

10-fyi-double-loop-backward-salto.patch


From: Akim Demaille
Subject: 10-fyi-double-loop-backward-salto.patch
Date: Thu, 27 Dec 2001 18:58:32 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/lalr.c (set_goto_map): Remove a wrong but benign loop
        duplication.
        
        
Index: src/lalr.c
--- src/lalr.c Wed, 26 Dec 2001 18:13:52 +0100 akim
+++ src/lalr.c Wed, 26 Dec 2001 20:29:21 +0100 akim
@@ -159,12 +159,8 @@
 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 @@
       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 @@
        }
     }
 
-  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];
-
-  goto_map[nsyms] = ngotos;
-  temp_map[nsyms] = ngotos;
+  {
+    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];
+
+    goto_map[nsyms] = ngotos;
+    temp_map[nsyms] = ngotos;
+  }
 
   from_state = XCALLOC (short, ngotos);
   to_state = XCALLOC (short, ngotos);
@@ -206,15 +204,12 @@
       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;
-
-             k = temp_map[symbol]++;
-             from_state[k] = state;
-             to_state[k] = state2;
-           }
+         int state2 = sp->shifts[i];
+         int symbol = state_table[state2]->accessing_symbol;
+
+         int k = temp_map[symbol]++;
+         from_state[k] = state;
+         to_state[k] = state2;
        }
     }
 
Index: src/output.c
--- src/output.c Wed, 26 Dec 2001 19:41:07 +0100 akim
+++ src/output.c Wed, 26 Dec 2001 20:19:17 +0100 akim
@@ -133,10 +133,8 @@
 
   size_t i;
   for (i = 0; s[i]; ++i)
-    {
-      if (s[i] == '\n')
-       ++lines;
-    }
+    if (s[i] == '\n')
+      ++lines;
 
   return lines;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]