aboutsummaryrefslogtreecommitdiff
path: root/src/libbio
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-12-28 19:25:16 +0000
committerrsc <devnull@localhost>2004-12-28 19:25:16 +0000
commit4dd07e012c124921328df5d91c272c63e015bdd5 (patch)
treefa8300981dfb26e1f90c4152deae106cfd65aa03 /src/libbio
parent727facb60539f522635f0d8978435ce4680fecd6 (diff)
downloadplan9port-4dd07e012c124921328df5d91c272c63e015bdd5.tar.gz
plan9port-4dd07e012c124921328df5d91c272c63e015bdd5.tar.bz2
plan9port-4dd07e012c124921328df5d91c272c63e015bdd5.zip
check against plan 9
Diffstat (limited to 'src/libbio')
-rw-r--r--src/libbio/bgetc.c1
-rw-r--r--src/libbio/binit.c6
-rw-r--r--src/libbio/bputc.c29
-rw-r--r--src/libbio/lib9.std.h5
4 files changed, 19 insertions, 22 deletions
diff --git a/src/libbio/bgetc.c b/src/libbio/bgetc.c
index 4c8ae90c..741b692f 100644
--- a/src/libbio/bgetc.c
+++ b/src/libbio/bgetc.c
@@ -26,6 +26,7 @@ loop:
i = read(bp->fid, bp->bbuf, bp->bsize);
bp->gbuf = bp->bbuf;
if(i <= 0) {
+ bp->state = Bracteof;
if(i < 0)
bp->state = Binactive;
return Beof;
diff --git a/src/libbio/binit.c b/src/libbio/binit.c
index 33bf5812..1a8c252c 100644
--- a/src/libbio/binit.c
+++ b/src/libbio/binit.c
@@ -61,7 +61,7 @@ Binits(Biobuf *bp, int f, int mode, unsigned char *p, int size)
p += Bungetsize; /* make room for Bungets */
size -= Bungetsize;
- switch(mode) {
+ switch(mode&~(OCEXEC|ORCLOSE|OTRUNC)) {
default:
fprint(2, "Bopen: unknown mode %d\n", mode);
return Beof;
@@ -86,7 +86,7 @@ Binits(Biobuf *bp, int f, int mode, unsigned char *p, int size)
bp->flag = 0;
bp->rdline = 0;
bp->offset = 0;
-/* bp->runesize = 0; */
+ bp->runesize = 0;
return 0;
}
@@ -116,7 +116,7 @@ Bopen(char *name, int mode)
Biobuf *bp;
int f;
- switch(mode) {
+ switch(mode&~(OCEXEC|ORCLOSE|OTRUNC)) {
default:
fprint(2, "Bopen: unknown mode %d\n", mode);
return 0;
diff --git a/src/libbio/bputc.c b/src/libbio/bputc.c
index 5f0fba59..d05badaa 100644
--- a/src/libbio/bputc.c
+++ b/src/libbio/bputc.c
@@ -4,26 +4,17 @@
int
Bputc(Biobuf *bp, int c)
{
- int i, j;
+ int i;
-loop:
- i = bp->ocount;
- j = i+1;
- if(i != 0) {
- bp->ocount = j;
- bp->ebuf[i] = c;
- return 0;
+ for(;;) {
+ i = bp->ocount;
+ if(i) {
+ bp->ebuf[i++] = c;
+ bp->ocount = i;
+ return 0;
+ }
+ if(Bflush(bp) == Beof)
+ break;
}
- if(bp->state != Bwactive)
- return Beof;
- j = write(bp->fid, bp->bbuf, bp->bsize);
- if(j == bp->bsize) {
- bp->ocount = -bp->bsize;
- bp->offset += j;
- goto loop;
- }
- fprint(2, "Bputc: write error\n");
- bp->state = Binactive;
- bp->ocount = 0;
return Beof;
}
diff --git a/src/libbio/lib9.std.h b/src/libbio/lib9.std.h
index a3ae0e99..44218fd6 100644
--- a/src/libbio/lib9.std.h
+++ b/src/libbio/lib9.std.h
@@ -9,6 +9,11 @@
#define OREAD O_RDONLY
#define OWRITE O_WRONLY
+#define OCEXEC 0
+#define ORCLOSE 0
+#define OTRUNC 0
+
+
#define nil ((void*)0)
typedef long long vlong;