From 22c821f31290ab5957a8d9eb99d48aa064f50df4 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 8 Feb 2001 14:51:33 +0000 Subject: [PATCH] * src/conflicts.c (conflict_report): Be sure not to append to res between two calls, which could happen if both first sprintf were skipped, but not the first cp += strlen. --- ChangeLog | 6 ++++++ src/conflicts.c | 30 +++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52e9b43a..4af5f372 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-02-08 Akim Demaille + + * src/conflicts.c (conflict_report): Be sure not to append to res + between two calls, which could happen if both first sprintf were + skipped, but not the first cp += strlen. + 2001-02-08 Akim Demaille * lib/memchr.c, lib/stpcpy.c, lib/strndup.c, lib/strnlen.c: diff --git a/src/conflicts.c b/src/conflicts.c index 50e82c9f..208f7910 100644 --- a/src/conflicts.c +++ b/src/conflicts.c @@ -1,5 +1,5 @@ /* Find and resolve or report look-ahead conflicts for bison, - Copyright 1984, 1989, 1992, 2000 Free Software Foundation, Inc. + Copyright 1984, 1989, 1992, 2000, 2001 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -418,20 +418,32 @@ conflict_report (int src_num, int rrc_num) char *cp = res; if (src_num == 1) - sprintf (cp, _(" 1 shift/reduce conflict")); + { + sprintf (cp, _(" 1 shift/reduce conflict")); + cp += strlen (cp); + } else if (src_num > 1) - sprintf (cp, _(" %d shift/reduce conflicts"), src_num); - cp += strlen (cp); + { + sprintf (cp, _(" %d shift/reduce conflicts"), src_num); + cp += strlen (cp); + } if (src_num > 0 && rrc_num > 0) - sprintf (cp, _(" and")); - cp += strlen (cp); + { + sprintf (cp, _(" and")); + cp += strlen (cp); + } if (rrc_num == 1) - sprintf (cp, _(" 1 reduce/reduce conflict")); + { + sprintf (cp, _(" 1 reduce/reduce conflict")); + cp += strlen (cp); + } else if (rrc_num > 1) - sprintf (cp, _(" %d reduce/reduce conflicts"), rrc_num); - cp += strlen (cp); + { + sprintf (cp, _(" %d reduce/reduce conflicts"), rrc_num); + cp += strlen (cp); + } *cp++ = '.'; *cp++ = '\n'; -- 2.47.2