X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fff-printf.c;h=0493092e6a0f4f57c482dee64f2f2abc0f43eb4d;hb=90afcc18dbf7cb6c682e1efb994007f03e304422;hp=cac06b55d907de387df3e6090451a136e9c98d72;hpb=cad27e97e6370f96903d42aaf345c099af0a03bd;p=libucw.git diff --git a/lib/ff-printf.c b/lib/ff-printf.c index cac06b55..0493092e 100644 --- a/lib/ff-printf.c +++ b/lib/ff-printf.c @@ -1,7 +1,7 @@ /* * 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. @@ -10,18 +10,22 @@ #include "lib/lib.h" #include "lib/fastbuf.h" +#include #include int -vbprintf(struct fastbuf *b, byte *msg, va_list args) +vbprintf(struct fastbuf *b, const 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 +42,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 +58,7 @@ vbprintf(struct fastbuf *b, byte *msg, va_list args) } int -bprintf(struct fastbuf *b, byte *msg, ...) +bprintf(struct fastbuf *b, const char *msg, ...) { va_list args; int res;