3 * vfgets.c -- virtual fgets
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
17 vfgets (FILE *in, char **bp)
20 char *cp, *dp, *ep, *fp;
22 static char *pp = NULL;
25 pp = mh_xmalloc ((size_t) (len = BUFSIZ));
27 for (ep = (cp = pp) + len - 1;;) {
28 if (fgets (cp, ep - cp + 1, in) == NULL) {
33 return (ferror (in) && !feof (in) ? -1 : 1);
36 if ((dp = cp + strlen (cp) - 2) < cp || *dp != QUOTE) {
39 adios (NULL, "vfgets() botch -- you lose big");
47 for (fp = dp - 1, toggle = 0; fp >= cp; fp--) {
67 dp = mh_xrealloc (pp, (size_t) (len += BUFSIZ));
69 ep = (pp = dp) + len - 1;