+2001-12-27  Akim Demaille  <akim@epita.fr>
+
+       * src/state.h, src/state.c (errs_new, errs_dup): New.
+       * src/LR0.c (set_state_table): Let all the states have an errs,
+       even if reduced to 0.
+       * src/print.c (print_errs, print_reductions): Adjust.
+       * src/output.c (output_actions, action_row): Adjust.
+       * src/conflicts.c (resolve_sr_conflict): Adjust.
+
+       
 2001-12-27  Akim Demaille  <akim@epita.fr>
 
        * src/lalr.c (set_goto_map, initialize_F): Use SHIFT_SYMBOL.
 
 static void
 set_state_table (void)
 {
+  state_t *sp;
   state_table = XCALLOC (state_t *, nstates);
 
-  {
-    state_t *sp;
-    for (sp = first_state; sp; sp = sp->next)
+  for (sp = first_state; sp; sp = sp->next)
+    {
+      /* Pessimization, but simplification of the code: make sure all
+        the states have a shifts and errs, even if reduced to 0.  */
+      if (!sp->shifts)
+       sp->shifts = shifts_new (0);
+      if (!sp->errs)
+       sp->errs = errs_new (0);
+
       state_table[sp->number] = sp;
-  }
-
-  /* Pessimization, but simplification of the code: make sure all the
-     states have a shifts, even if reduced to 0 shifts.  */
-  {
-    int i;
-    for (i = 0; i < nstates; i++)
-      if (!state_table[i]->shifts)
-       state_table[i]->shifts = shifts_new (0);
-  }
+    }
 }
 
 /*-------------------------------------------------------------------.
 
   int i;
   /* find the rule to reduce by to get precedence of reduction  */
   int redprec = rule_table[LAruleno[lookahead]].prec;
-  errs *errp = ERRS_ALLOC (ntokens + 1);
-  short *errtokens = errp->errs;
+  errs *errp = errs_new (ntokens + 1);
+  errp->nerrs = 0;
 
   for (i = 0; i < ntokens; i++)
     if (BITISSET (LA (lookahead), i)
              flush_shift (state, i);
              flush_reduce (lookahead, i);
              /* Record an explicit error for this token.  */
-             *errtokens++ = i;
+             errp->errs[errp->nerrs++] = i;
              break;
            }
       }
 
-  errp->nerrs = errtokens - errp->errs;
   /* Some tokens have been explicitly made errors.  Allocate a
      permanent errs structure for this state, to record them.  */
-  i = (char *) errtokens - (char *) errp;
-  state->errs = ERRS_ALLOC (i + 1);
-  memcpy (state->errs, errp, i);
+  state->errs = errs_dup (errp);
   free (errp);
 }
 
 
 
   /* See which tokens are an explicit error in this state (due to
      %nonassoc).  For them, record MINSHORT as the action.  */
-  if (errp)
-    for (i = 0; i < errp->nerrs; i++)
-      {
-       int symbol = errp->errs[i];
-       actrow[symbol] = MINSHORT;
-      }
+  for (i = 0; i < errp->nerrs; i++)
+    {
+      int symbol = errp->errs[i];
+      actrow[symbol] = MINSHORT;
+    }
 
   /* Now find the most common reduction and make it the default action
      for this state.  */
 
   for (i = 0; i < nstates; ++i)
     {
-      XFREE (state_table[i]->shifts);
+      free (state_table[i]->shifts);
       XFREE (state_table[i]->reductions);
-      XFREE (state_table[i]->errs);
+      free (state_table[i]->errs);
       free (state_table[i]);
     }
   XFREE (state_table);
 
   errs *errp = state->errs;
   int i;
 
-  if (!errp)
-    return;
-
   for (i = 0; i < errp->nerrs; ++i)
     if (errp->errs[i])
       fprintf (out, _("    %-4s\terror (nonassociative)\n"),
               tags[errp->errs[i]]);
 
   if (i > 0)
-       fputc ('\n', out);
+    fputc ('\n', out);
 }
 
 
        SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
       }
 
-  if (errp)
-    for (i = 0; i < errp->nerrs; i++)
-      if (errp->errs[i])
-       SETBIT (shiftset, errp->errs[i]);
+  for (i = 0; i < errp->nerrs; i++)
+    if (errp->errs[i])
+      SETBIT (shiftset, errp->errs[i]);
 
   if (state->nlookaheads == 1 && !nodefault)
     {
 
 | Create a new array of N shitfs.  |
 `---------------------------------*/
 
+#define SHIFTS_ALLOC(Nshifts)                                          \
+  (shifts *) xcalloc ((unsigned) (sizeof (shifts)                      \
+                                  + (Nshifts - 1) * sizeof (short)), 1)
+
 shifts *
 shifts_new (int n)
 {
   res->nshifts = n;
   return res;
 }
+
+
+/*-------------------------------.
+| Create a new array of N errs.  |
+`-------------------------------*/
+
+#define ERRS_ALLOC(Nerrs)                                              \
+  (errs *) xcalloc ((unsigned) (sizeof (errs)                          \
+                                  + (Nerrs - 1) * sizeof (short)), 1)
+
+
+errs *
+errs_new (int n)
+{
+  errs *res = ERRS_ALLOC (n);
+  res->nerrs = n;
+  return res;
+}
+
+
+errs *
+errs_dup (errs *src)
+{
+  errs *res = errs_new (src->nerrs);
+  memcpy (res->errs, src->errs, src->nerrs);
+  return res;
+}
 
   short shifts[1];
 } shifts;
 
-
-#define SHIFTS_ALLOC(Nshifts)                                          \
-  (shifts *) xcalloc ((unsigned) (sizeof (shifts)                      \
-                                  + (Nshifts - 1) * sizeof (short)), 1)
-
-shifts * shifts_new PARAMS ((int n));
+shifts *shifts_new PARAMS ((int n));
 
 
 /* What is the symbol which is shifted by SHIFTS->shifts[Shift]?  Can
   short errs[1];
 } errs;
 
-#define ERRS_ALLOC(Nerrs)                                              \
-  (errs *) xcalloc ((unsigned) (sizeof (errs)                          \
-                                  + (Nerrs - 1) * sizeof (short)), 1)
+errs *errs_new PARAMS ((int n));
+errs *errs_dup PARAMS ((errs *src));
 
 
 /*-------------.