check against plan 9
This commit is contained in:
parent
727facb605
commit
4dd07e012c
4 changed files with 19 additions and 22 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue