=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/m4/misc.c,v retrieving revision 1.16 retrieving revision 1.17 diff -c -r1.16 -r1.17 *** src/usr.bin/m4/misc.c 2000/01/13 17:35:10 1.16 --- src/usr.bin/m4/misc.c 2000/01/15 14:26:00 1.17 *************** *** 1,4 **** ! /* $OpenBSD: misc.c,v 1.16 2000/01/13 17:35:10 espie Exp $ */ /* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: misc.c,v 1.17 2000/01/15 14:26:00 espie Exp $ */ /* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */ /* *************** *** 41,47 **** #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93"; #else ! static char rcsid[] = "$OpenBSD: misc.c,v 1.16 2000/01/13 17:35:10 espie Exp $"; #endif #endif /* not lint */ --- 41,47 ---- #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93"; #else ! static char rcsid[] = "$OpenBSD: misc.c,v 1.17 2000/01/15 14:26:00 espie Exp $"; #endif #endif /* not lint */ *************** *** 66,76 **** static size_t bufsize = BUFSIZE; static int low_sp = 0; ! pbent *buf; /* push-back buffer */ ! pbent *bufbase; /* the base for current ilevel */ ! pbent *bbase[MAXINP]; /* the base for each ilevel */ ! pbent *bp; /* first available character */ ! static pbent *endpbb; /* end of push-back buffer */ static void enlarge_bufspace __P((void)); --- 66,76 ---- static size_t bufsize = BUFSIZE; static int low_sp = 0; ! char *buf; /* push-back buffer */ ! char *bufbase; /* the base for current ilevel */ ! char *bbase[MAXINP]; /* the base for each ilevel */ ! char *bp; /* first available character */ ! static char *endpbb; /* end of push-back buffer */ static void enlarge_bufspace __P((void)); *************** *** 96,103 **** */ void putback(c) ! pbent c; { if (bp >= endpbb) enlarge_bufspace(); *bp++ = c; --- 96,105 ---- */ void putback(c) ! int c; { + if (c == EOF) + return; if (bp >= endpbb) enlarge_bufspace(); *bp++ = c; *************** *** 149,155 **** strspace = xalloc(strsize+1); ep = strspace; endest = strspace+strsize; ! buf = (pbent *)xalloc(bufsize * sizeof(pbent)); bufbase = buf; bp = buf; endpbb = buf + bufsize; --- 151,157 ---- strspace = xalloc(strsize+1); ep = strspace; endest = strspace+strsize; ! buf = (char *)xalloc(bufsize); bufbase = buf; bp = buf; endpbb = buf + bufsize; *************** *** 162,169 **** * duplicate it transparently, and to reclaim the correct * space when the stack is unwound. */ ! static ! void enlarge_strspace() { char *newstrspace; --- 164,171 ---- * duplicate it transparently, and to reclaim the correct * space when the stack is unwound. */ ! static void ! enlarge_strspace() { char *newstrspace; *************** *** 182,195 **** endest = strspace + strsize; } ! static ! void enlarge_bufspace() { ! pbent *newbuf; int i; bufsize *= 2; ! newbuf = realloc(buf, bufsize*sizeof(pbent)); if (!newbuf) errx(1, "too many characters pushed back"); for (i = 0; i < MAXINP; i++) --- 184,197 ---- endest = strspace + strsize; } ! static void ! enlarge_bufspace() { ! char *newbuf; int i; bufsize *= 2; ! newbuf = realloc(buf, bufsize); if (!newbuf) errx(1, "too many characters pushed back"); for (i = 0; i < MAXINP; i++) *************** *** 299,305 **** obtain_char(f) struct input_file *f; { ! if (f->c == '\n') f->lineno++; f->c = fgetc(f->file); --- 301,309 ---- obtain_char(f) struct input_file *f; { ! if (f->c == EOF) ! return EOF; ! else if (f->c == '\n') f->lineno++; f->c = fgetc(f->file); *************** *** 324,329 **** --- 328,334 ---- { if (f->file != stdin) fclose(f->file); + f->c = EOF; /* * XXX can't free filename, as there might still be * error information pointing to it.