fix bug with insertion of newline being wrong if the num function was used at
authorOliver Kiddle <okiddle@yahoo.co.uk>
Wed, 18 Jan 2006 16:43:27 +0000 (16:43 +0000)
committerOliver Kiddle <okiddle@yahoo.co.uk>
Wed, 18 Jan 2006 16:43:27 +0000 (16:43 +0000)
the end of the format buffer

ChangeLog
sbr/fmt_scan.c

index e7f3e1c..f634ba2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-18  Oliver Kiddle  <okiddle@yahoo.co.uk>
+
+       * 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 <levinedl@acm.org>
 
        * uip/post.c, uip/spost.c: in make_bcc_file (), use same
 2006-01-17  David Levine <levinedl@acm.org>
 
        * uip/post.c, uip/spost.c: in make_bcc_file (), use same
index c049ad4..b27f7c6 100644 (file)
@@ -342,8 +342,12 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat)
            adios (NULL, "internal error (FT_STRFW)");
 
        case FT_NUM:
            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);
            break;
        case FT_NUMF:
            cpnumber (&cp, value, fmt->f_width, fmt->f_fill, ep - cp);