]> mj.ucw.cz Git - libucw.git/commitdiff
Added bgets0().
authorMartin Mares <mj@ucw.cz>
Tue, 20 Feb 2001 22:32:06 +0000 (22:32 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 20 Feb 2001 22:32:06 +0000 (22:32 +0000)
lib/fastbuf.c
lib/fastbuf.h

index 2d00bf05687f7252c1fa26a4847559644b6530df..00fa51bcccd902538514cbbb069598008094b06f 100644 (file)
@@ -256,6 +256,28 @@ bgets(struct fastbuf *f, byte *b, uns l)
   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)
 {
index 15bfed5a89cf1b42541c3dcdc5a7a12717feeab4..d831ed36153a877f27d0cf5f9cb85d90ac615604 100644 (file)
@@ -306,6 +306,7 @@ static inline void bwrite(struct fastbuf *f, void *b, uns l)
 }
 
 byte *bgets(struct fastbuf *f, byte *b, uns l);        /* Non-std */
+byte *bgets0(struct fastbuf *f, byte *b, uns l);
 
 static inline void
 bputs(struct fastbuf *f, byte *b)