]> diplodocus.org Git - nmh/commitdiff
fmttest.c: Clear output buffer after each write.
authorRalph Corderoy <ralph@inputplus.co.uk>
Wed, 22 Nov 2017 15:12:11 +0000 (15:12 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Wed, 22 Nov 2017 15:14:29 +0000 (15:14 +0000)
Otherwise each write outputs the whole buffer again, including what's
already appeared.  Instead of the three lines 1, 2, 3, one sees 1, 1, 2,
1, 2, 3.

uip/fmttest.c

index db16ae7..e330838 100644 (file)
@@ -473,6 +473,7 @@ process_addresses(struct format *fmt, struct msgs_array *addrs,
 
            fmt_scan(fmt, buffer, outwidth, dat, cb);
            fputs(charstring_buffer(buffer), stdout);
+            charstring_clear(buffer);
            mlistfree();
 
             free(p->pq_text);
@@ -699,6 +700,7 @@ finished:
     }
     fmt_scan(fmt, buffer, outwidth, dat, cb);
     fputs(charstring_buffer (buffer), stdout);
+    charstring_clear(buffer);
     mlistfree();
 }
 
@@ -732,6 +734,7 @@ process_raw(struct format *fmt, struct msgs_array *text, charstring_t buffer,
 
        fmt_scan(fmt, buffer, outwidth, dat, cb);
        fputs(charstring_buffer (buffer), stdout);
+        charstring_clear(buffer);
        mlistfree();
     }
 }