bvprint.c (654B)
1 #include "lib9.h" 2 3 #include <bio.h> 4 5 static int 6 fmtBflush(Fmt* f) { 7 Biobuf* bp; 8 9 bp = f->farg; 10 bp->ocount = (char*) f->to - (char*) f->stop; 11 if (Bflush(bp) < 0) 12 return 0; 13 f->stop = bp->ebuf; 14 f->to = (char*) f->stop + bp->ocount; 15 f->start = f->to; 16 return 1; 17 } 18 19 int Bvprint(Biobuf* bp, char* fmt, va_list arg) { 20 int n; 21 Fmt f; 22 23 f.runes = 0; 24 f.stop = bp->ebuf; 25 f.start = (char*) f.stop + bp->ocount; 26 f.to = f.start; 27 f.flush = fmtBflush; 28 f.farg = bp; 29 f.nfmt = 0; 30 fmtlocaleinit(&f, nil, nil, nil); 31 n = fmtvprint(&f, fmt, arg); 32 bp->ocount = (char*) f.to - (char*) f.stop; 33 if (n == 0) 34 n = f.nfmt; 35 return n; 36 }