*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
}
#endif
}
-uns bread_slow(struct fastbuf *f, void *b, uns l)
+uns bread_slow(struct fastbuf *f, void *b, uns l, uns check)
{
uns total = 0;
while (l)
l -= k;
total += k;
}
+ if (check && total && l)
+ die("breadb: short read");
return total;
}
die("%s: Line too long", f->name);
}
+byte *
+bgets0(struct fastbuf *f, byte *b, uns l)
+{
+ byte *e = b + l - 1;
+ int k;
+
+ k = bgetc(f);
+ if (k == EOF)
+ return NULL;
+ while (b < e)
+ {
+ if (!k || k == EOF)
+ {
+ *b = 0;
+ return b;
+ }
+ *b++ = k;
+ k = bgetc(f);
+ }
+ die("%s: Line too long", f->name);
+}
+
int
bdirect_read(struct fastbuf *f, byte **buf)
{