From: Martin Mares Date: Sat, 15 Dec 2001 22:51:05 +0000 (+0000) Subject: bgetw() returns int instead of word, so it's possible X-Git-Tag: holmes-import~1459 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=5037a189be2563359e2943f39ed4ccbee07ffe9b;p=libucw.git bgetw() returns int instead of word, so it's possible to detect EOF. --- diff --git a/lib/fastbuf.c b/lib/fastbuf.c index 00fa51bc..8df90548 100644 --- a/lib/fastbuf.c +++ b/lib/fastbuf.c @@ -87,13 +87,19 @@ void bputc_slow(struct fastbuf *f, byte c) *f->bptr++ = c; } -word bgetw_slow(struct fastbuf *f) +int bgetw_slow(struct fastbuf *f) { - word w = bgetc_slow(f); + int w1, w2; + w1 = bgetc_slow(f); + if (w1 < 0) + return w1; + w2 = bgetc_slow(f); + if (w2 < 0) + return w2; #ifdef CPU_BIG_ENDIAN - return (w << 8) | bgetc_slow(f); + return (w1 << 8) | w2; #else - return w | (bgetc_slow(f) << 8); + return w1 | (w2 << 8); #endif } diff --git a/lib/fastbuf.h b/lib/fastbuf.h index 1488f740..a796a3c7 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -103,10 +103,10 @@ static inline void bputc(struct fastbuf *f, byte c) bputc_slow(f, c); } -word bgetw_slow(struct fastbuf *f); -static inline word bgetw(struct fastbuf *f) +int bgetw_slow(struct fastbuf *f); +static inline int bgetw(struct fastbuf *f) { - word w; + int w; if (f->bptr + 2 <= f->bstop) { w = GET_U16(f->bptr);