Include @<ctype.h>@.
[mLib] / lbuf.c
diff --git a/lbuf.c b/lbuf.c
index 9c0ec22..8b93076 100644 (file)
--- a/lbuf.c
+++ b/lbuf.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: lbuf.c,v 1.4 2000/06/17 10:38:14 mdw Exp $
+ * $Id: lbuf.c,v 1.5 2001/02/03 16:23:33 mdw Exp $
  *
  * Block-to-line buffering
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: lbuf.c,v $
+ * Revision 1.5  2001/02/03 16:23:33  mdw
+ * Bug fix: handle a disable during a close-induced flush without dumping
+ * core.
+ *
  * Revision 1.4  2000/06/17 10:38:14  mdw
  * Add support for variable buffer sizes.
  *
@@ -87,6 +91,11 @@ void lbuf_flush(lbuf *b, char *p, size_t len)
   char *base;                          /* Base address of current line */
   int cr;                              /* Carriage return state */
 
+  if (b->f & LBUF_CLOSE) {
+    b->func(0, b->p);
+    return;
+  }
+
   /* --- Initialize variables as necessary --- */
 
   if (!p) {
@@ -192,6 +201,7 @@ void lbuf_close(lbuf *b)
     x_free(b->a, b->buf);
     b->buf = 0;
   }
+  b->f |= LBUF_CLOSE;
   if (b->f & LBUF_ENABLE)
     b->func(0, b->p);
 }