From 669250d159e93a6933afa4cd25f410af801515ec Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 3 Dec 2003 22:50:48 +0000 Subject: Various fixes. B - fixed usage, DISPLAY :0 vs :0.0 9term - fixed various terminal things rc - notice traps in Read _p9dir - only run disk code for disks dirread - getdirentries on FreeBSD and Linux are different w.r.t. meaning of off. notify - set up so signals interrupt system calls bprint - use bfmt. --- src/libbio/bcat.c | 4 ++++ src/libbio/bprint.c | 28 ++++++++++------------------ src/libbio/mkfile | 5 +++-- 3 files changed, 17 insertions(+), 20 deletions(-) (limited to 'src/libbio') diff --git a/src/libbio/bcat.c b/src/libbio/bcat.c index dea346a5..7c9b39e9 100644 --- a/src/libbio/bcat.c +++ b/src/libbio/bcat.c @@ -22,8 +22,12 @@ main(int argc, char **argv) { int i; Biobuf b, *bp; + Fmt fmt; Binit(&bout, 1, O_WRONLY); + Bfmtinit(&fmt, &bout); + fmtprint(&fmt, "hello, world\n"); + Bfmtflush(&fmt); if(argc == 1){ Binit(&b, 0, O_RDONLY); diff --git a/src/libbio/bprint.c b/src/libbio/bprint.c index 81e71e5e..2b66605c 100644 --- a/src/libbio/bprint.c +++ b/src/libbio/bprint.c @@ -4,25 +4,17 @@ int Bprint(Biobuf *bp, char *fmt, ...) { - va_list ap; - char *ip, *ep, *out; + va_list args; + Fmt f; int n; - ep = (char*)bp->ebuf; - ip = ep + bp->ocount; - va_start(ap, fmt); - out = vseprint(ip, ep, fmt, ap); - va_end(ap); - if(out == 0 || out >= ep-5) { - Bflush(bp); - ip = ep + bp->ocount; - va_start(ap, fmt); - out = vseprint(ip, ep, fmt, ap); - va_end(ap); - if(out >= ep-5) - return Beof; - } - n = out-ip; - bp->ocount += n; + if(Bfmtinit(&f, bp) < 0) + return -1; + va_start(args, fmt); + f.args = args; + n = dofmt(&f, fmt); + va_end(args); + if(n > 0 && Bfmtflush(&f) < 0) + return -1; return n; } diff --git a/src/libbio/mkfile b/src/libbio/mkfile index 2c64b257..e808b178 100644 --- a/src/libbio/mkfile +++ b/src/libbio/mkfile @@ -7,6 +7,7 @@ OFILES=\ bbuffered.$O\ bfildes.$O\ bflush.$O\ + bfmt.$O\ bgetc.$O\ bgetd.$O\ binit.$O\ @@ -26,6 +27,6 @@ HFILES=\ <$PLAN9/src/mksyslib -bcat: bcat.$O $LIB - $CC -o bcat bcat.$O -L$PLAN9/lib -lbio -lfmt -lutf +bcat: bcat.$O $PLAN9/lib/$LIB + $LD -o bcat bcat.$O -lbio -lfmt -lutf -- cgit v1.2.3