1 /* vfgets.c - virtual fgets */
3 static char ident[] = "@(#)$Id: vfgets.c,v 1.3 1992/12/15 00:20:22 jromine Exp $";
23 static char *pp = NULL;
26 if ((pp = malloc ((unsigned) (len = BUFSIZ))) == NULL)
27 adios (NULLCP, "unable to allocate string storage");
29 for (ep = (cp = pp) + len - 1;;) {
30 if (fgets (cp, ep - cp + 1, in) == NULL) {
35 return (ferror (in) && !feof (in) ? NOTOK : DONE);
38 if ((dp = cp + strlen (cp) - 2) < cp || *dp != QUOTE) {
41 adios (NULLCP, "vfgets() botch -- you lose big");
50 for (fp = dp - 1, toggle = 0; fp >= cp; fp--)
64 register int curlen = cp - pp;
66 if ((dp = realloc (pp, (unsigned) (len += BUFSIZ))) == NULL)
67 adios (NULLCP, "unable to allocate string storage");
69 cp = dp + curlen, ep = (pp = dp) + len - 1;