X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fff-printf.c;h=769f830e1cd5423e7db5e80831bc090ba67e98b0;hb=b4d79987a979bcbf749294c706fdc8c4ae8f9304;hp=d22d421d1d09a7f9be2632ff6573bb3fb43c1f65;hpb=9c21b55e57a42cabe0ee81489ce232834885f7b1;p=libucw.git diff --git a/lib/ff-printf.c b/lib/ff-printf.c index d22d421d..769f830e 100644 --- a/lib/ff-printf.c +++ b/lib/ff-printf.c @@ -1,7 +1,7 @@ /* - * Sherlock Library -- Printf on Fastbuf Streams + * UCW Library -- Printf on Fastbuf Streams * - * (c) 2002 Martin Mares + * (c) 2002--2005 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -13,15 +13,18 @@ #include int -vbprintf(struct fastbuf *b, byte *msg, va_list args) +vbprintf(struct fastbuf *b, char *msg, va_list args) { byte *buf; int len, r; + va_list args2; len = bdirect_write_prepare(b, &buf); if (len >= 16) { - r = vsnprintf(buf, len, msg, args); + va_copy(args2, args); + r = vsnprintf(buf, len, msg, args2); + va_end(args2); if (r < 0) len = 256; else if (r < len) @@ -38,7 +41,9 @@ vbprintf(struct fastbuf *b, byte *msg, va_list args) while (1) { buf = alloca(len); - r = vsnprintf(buf, len, msg, args); + va_copy(args2, args); + r = vsnprintf(buf, len, msg, args2); + va_end(args2); if (r < 0) len += len; else if (r < len) @@ -52,7 +57,7 @@ vbprintf(struct fastbuf *b, byte *msg, va_list args) } int -bprintf(struct fastbuf *b, byte *msg, ...) +bprintf(struct fastbuf *b, char *msg, ...) { va_list args; int res;