diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/bio.h | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/include/bio.h b/include/bio.h index b4e552d8..67ec18ed 100644 --- a/include/bio.h +++ b/include/bio.h @@ -5,7 +5,7 @@ typedef struct Biobuf Biobuf; enum { Bsize = 8*1024, - Bungetsize = 4, /* space for ungetc */ + Bungetsize = UTFmax+1, /* space for ungetc */ Bmagic = 0x314159, Beof = -1, Bbad = -2, @@ -27,7 +27,7 @@ struct Biobuf int state; /* r/w/inactive */ int fid; /* open file */ int flag; /* magic if malloc'ed */ - long offset; /* offset of buffer in file */ + vlong offset; /* offset of buffer in file */ int bsize; /* size of buffer */ uchar* bbuf; /* pointer to beginning of buffer */ uchar* ebuf; /* pointer to end of buffer */ @@ -35,20 +35,12 @@ struct Biobuf uchar b[Bungetsize+Bsize]; }; -#define BGETC(bp)\ - ((bp)->icount?(bp)->bbuf[(bp)->bsize+(bp)->icount++]:Bgetc((bp))) -#define BPUTC(bp,c)\ - ((bp)->ocount?(bp)->bbuf[(bp)->bsize+(bp)->ocount++]=(c),0:Bputc((bp),(c))) -#define BOFFSET(bp)\ - (((bp)->state==Bractive)?\ - (bp)->offset + (bp)->icount:\ - (((bp)->state==Bwactive)?\ - (bp)->offset + ((bp)->bsize + (bp)->ocount):\ - -1)) -#define BLINELEN(bp)\ - (bp)->rdline -#define BFILDES(bp)\ - (bp)->fid +/* Dregs, redefined as functions for backwards compatibility */ +#define BGETC(bp) Bgetc(bp) +#define BPUTC(bp,c) Bputc(bp,c) +#define BOFFSET(bp) Boffset(bp) +#define BLINELEN(bp) Blinelen(bp) +#define BFILDES(bp) Bfildes(bp) int Bbuffered(Biobuf*); int Bfildes(Biobuf*); @@ -59,14 +51,16 @@ long Bgetrune(Biobuf*); int Binit(Biobuf*, int, int); int Binits(Biobuf*, int, int, uchar*, int); int Blinelen(Biobuf*); -long Boffset(Biobuf*); +vlong Boffset(Biobuf*); Biobuf* Bopen(char*, int); int Bprint(Biobuf*, char*, ...); +int Bvprint(Biobuf*, char*, va_list); int Bputc(Biobuf*, int); int Bputrune(Biobuf*, long); void* Brdline(Biobuf*, int); +char* Brdstr(Biobuf*, int, int); long Bread(Biobuf*, void*, long); -long Bseek(Biobuf*, long, int); +vlong Bseek(Biobuf*, vlong, int); int Bterm(Biobuf*); int Bungetc(Biobuf*); int Bungetrune(Biobuf*); |
