From 6af0c8bb08f8c36e7106ba87f00164b1df3d2774 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Wed, 18 Jan 2006 16:43:27 +0000 Subject: [PATCH] fix bug with insertion of newline being wrong if the num function was used at the end of the format buffer --- ChangeLog | 5 +++++ sbr/fmt_scan.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7f3e1c..f634ba2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-18 Oliver Kiddle + + * sbr/fmt_scan.c: fix bug with insertion of newline being wrong if + the num function was used at the end of the format buffer + 2006-01-17 David Levine * uip/post.c, uip/spost.c: in make_bcc_file (), use same diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index c049ad4..b27f7c6 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -342,8 +342,12 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) adios (NULL, "internal error (FT_STRFW)"); case FT_NUM: - n = snprintf(cp, ep - cp, "%d", value); - if (n >= 0) cp += n; + n = snprintf(cp, ep - cp + 1, "%d", value); + if (n >= 0) + if (n >= ep - cp) { + cp = ep; + } else + cp += n; break; case FT_NUMF: cpnumber (&cp, value, fmt->f_width, fmt->f_fill, ep - cp); -- 1.7.10.4