2 * vfgets.c -- virtual fgets
4 * This code is Copyright (c) 2002, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
16 vfgets (FILE *in, char **bp)
19 char *cp, *dp, *ep, *fp;
21 static char *pp = NULL;
24 pp = mh_xmalloc ((size_t) (len = BUFSIZ));
26 for (ep = (cp = pp) + len - 1;;) {
27 if (fgets (cp, ep - cp + 1, in) == NULL) {
32 return (ferror (in) && !feof (in) ? -1 : 1);
35 if ((dp = cp + strlen (cp) - 2) < cp || *dp != QUOTE) {
38 adios (NULL, "vfgets() botch -- you lose big");
46 for (fp = dp - 1, toggle = 0; fp >= cp; fp--) {
66 dp = mh_xrealloc (pp, (size_t) (len += BUFSIZ));
68 ep = (pp = dp) + len - 1;