add a typedef which describes elements in the push-back buffer. Make

that typedef 'short'.  'char' (which was previously used) because char
may be unsigned and ((char)EOF) != EOF if that is the case.  That was
causing the (char)EOF (0xff) pushed back in main to be interepreted as
a character, and, in some cases, to be written to the output.  'short'
was used rather than 'signed char' because if the latter is used,
0xff characters in the input would confuse m4.  (No point in introducing
(more?) 8-bit lossage.)
This commit is contained in:
cgd 1997-12-02 22:34:00 +00:00
parent 11751c2757
commit e4d749962a
4 changed files with 20 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.4 1997/10/19 04:39:55 lukem Exp $ */
/* $NetBSD: extern.h,v 1.5 1997/12/02 22:34:00 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -80,13 +80,13 @@ extern int fp; /* m4 call frame pointer */
extern int ilevel; /* input file stack pointer */
extern int oindex; /* diversion index. */
extern int sp; /* current m4 stack pointer */
extern char *bp; /* first available character */
extern char buf[]; /* push-back buffer */
extern char *bufbase; /* buffer base for this ilevel */
extern char *bbase[]; /* buffer base per ilevel */
extern pbent *bp; /* first available character */
extern pbent buf[]; /* push-back buffer */
extern pbent *bufbase; /* buffer base for this ilevel */
extern pbent *bbase[]; /* buffer base per ilevel */
extern char ecommt[]; /* end character for comment */
extern char *endest; /* end of string space */
extern char *endpbb; /* end of push-back buffer */
extern pbent *endpbb; /* end of push-back buffer */
extern char *ep; /* first free char in strspace */
extern char lquote[]; /* left quote character (`) */
extern char *m4temp; /* filename for diversions */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.13 1997/10/19 04:40:00 lukem Exp $ */
/* $NetBSD: main.c,v 1.14 1997/12/02 22:34:02 cgd Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: main.c,v 1.13 1997/10/19 04:40:00 lukem Exp $");
__RCSID("$NetBSD: main.c,v 1.14 1997/12/02 22:34:02 cgd Exp $");
#endif
#endif /* not lint */
@ -70,11 +70,11 @@ __RCSID("$NetBSD: main.c,v 1.13 1997/10/19 04:40:00 lukem Exp $");
#include "pathnames.h"
ndptr hashtab[HASHSIZE]; /* hash table for macros etc. */
char buf[BUFSIZE]; /* push-back buffer */
char *bufbase = buf; /* the base for current ilevel */
char *bbase[MAXINP]; /* the base for each ilevel */
char *bp = buf; /* first available character */
char *endpbb = buf+BUFSIZE; /* end of push-back buffer */
pbent buf[BUFSIZE]; /* push-back buffer */
pbent *bufbase = buf; /* the base for current ilevel */
pbent *bbase[MAXINP]; /* the base for each ilevel */
pbent *bp = buf; /* first available character */
pbent *endpbb = buf+BUFSIZE; /* end of push-back buffer */
stae mstack[STACKMAX+1]; /* stack of m4 machine */
char strspace[STRSPMAX+1]; /* string space for evaluation */
char *ep = strspace; /* first free char in strspace */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mdef.h,v 1.7 1996/01/13 23:25:27 pk Exp $ */
/* $NetBSD: mdef.h,v 1.8 1997/12/02 22:34:04 cgd Exp $ */
/*
* Copyright (c) 1989, 1993
@ -138,6 +138,8 @@ typedef union { /* stack structure */
char *sstr; /* string entry */
} stae;
typedef short pbent; /* pushback entry; needs to hold chars + EOF */
/*
* macros for readibility and/or speed
*

View File

@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.7 1997/10/19 04:40:03 lukem Exp $ */
/* $NetBSD: misc.c,v 1.8 1997/12/02 22:34:05 cgd Exp $ */
/*
* Copyright (c) 1989, 1993
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: misc.c,v 1.7 1997/10/19 04:40:03 lukem Exp $");
__RCSID("$NetBSD: misc.c,v 1.8 1997/12/02 22:34:05 cgd Exp $");
#endif
#endif /* not lint */
@ -78,7 +78,7 @@ indx(s1, s2)
*/
void
putback(c)
char c;
pbent c;
{
if (bp < endpbb)
*bp++ = c;
@ -96,7 +96,7 @@ pbstr(s)
char *s;
{
char *es;
char *zp;
pbent *zp;
es = s;
zp = bp;