+
+ return rrc_count;
+}
+
+/*--------------------------------------------------------------.
+| Return a human readable string which reports shift/reduce and |
+| reduce/reduce conflict numbers (SRC_NUM, RRC_NUM). |
+`--------------------------------------------------------------*/
+
+static const char *
+conflict_report (int src_num, int rrc_num)
+{
+ static char res[4096];
+ char *cp = res;
+
+ if (src_num >= 1)
+ {
+ sprintf (cp, ngettext ("%d shift/reduce conflict",
+ "%d shift/reduce conflicts", src_num), src_num);
+ cp += strlen (cp);
+ }
+
+ if (src_num > 0 && rrc_num > 0)
+ {
+ sprintf (cp, " %s ", _("and"));
+ cp += strlen (cp);
+ }
+
+ if (rrc_num >= 1)
+ {
+ sprintf (cp, ngettext ("%d reduce/reduce conflict",
+ "%d reduce/reduce conflicts", rrc_num), rrc_num);
+ cp += strlen (cp);
+ }
+
+ *cp++ = '.';
+ *cp++ = '\n';
+ *cp++ = '\0';
+
+ return res;
+}
+
+
+/*-----------------------------------------------------------.
+| Output the detailed description of states with conflicts. |
+`-----------------------------------------------------------*/
+
+void
+conflicts_output (FILE *out)
+{
+ int i;
+ for (i = 0; i < nstates; i++)
+ if (conflicts[i])
+ {
+ fprintf (out, _("State %d contains "), i);
+ fputs (conflict_report (count_sr_conflicts (i),
+ count_rr_conflicts (i)), out);
+ }
+}
+
+
+/*------------------------------------------.
+| Reporting the total number of conflicts. |
+`------------------------------------------*/
+
+void
+conflicts_print (void)
+{
+ int i;
+
+ int src_total = 0;
+ int rrc_total = 0;
+
+ /* Conflicts by state. */
+ for (i = 0; i < nstates; i++)
+ if (conflicts[i])
+ {
+ src_total += count_sr_conflicts (i);
+ rrc_total += count_rr_conflicts (i);
+ }
+
+ /* Report the total number of conflicts on STDERR. */
+ if (src_total || rrc_total)
+ {
+ if (yacc_flag)
+ {
+ /* If invoked with `--yacc', use the output format specified by
+ POSIX. */
+ fprintf (stderr, _("conflicts: "));
+ if (src_total > 0)
+ fprintf (stderr, _(" %d shift/reduce"), src_total);
+ if (src_total > 0 && rrc_total > 0)
+ fprintf (stderr, ",");
+ if (rrc_total > 0)
+ fprintf (stderr, _(" %d reduce/reduce"), rrc_total);
+ putc ('\n', stderr);
+ }
+ else
+ {
+ fprintf (stderr, _("%s contains "), infile);
+ fputs (conflict_report (src_total, rrc_total), stderr);
+ }
+ }
+
+ if (expected_conflicts != -1
+ && src_total != expected_conflicts)
+ {
+ complain_message_count++;
+ fprintf (stderr, ngettext ("expected %d shift/reduce conflict",
+ "expected %d shift/reduce conflicts",
+ expected_conflicts),
+ expected_conflicts);
+ }