Blob


1 #include "lib9.h"
2 #include <bio.h>
4 static int
5 fmtBflush(Fmt *f)
6 {
7 Biobuf *bp;
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 }
19 int
20 Bvprint(Biobuf *bp, char *fmt, va_list arg)
21 {
22 int n;
23 Fmt f;
25 f.runes = 0;
26 f.stop = bp->ebuf;
27 f.start = (char*)f.stop + bp->ocount;
28 f.to = f.start;
29 f.flush = fmtBflush;
30 f.farg = bp;
31 f.nfmt = 0;
32 fmtlocaleinit(&f, nil, nil, nil);
33 n = fmtvprint(&f, fmt, arg);
34 bp->ocount = (char*)f.to - (char*)f.stop;
35 if(n == 0)
36 n = f.nfmt;
37 return n;
38 }