Make m4 more 8bit clean.
Don't use is*(EOF) This fix core dump when LANG setted to 8bit wide charset and ENABLE_STARTUP_LOCALE
This commit is contained in:
parent
db2e1efab0
commit
44a01bec5c
@ -378,8 +378,8 @@ expand(argv, argc)
|
||||
register char *argv[];
|
||||
register int argc;
|
||||
{
|
||||
register char *t;
|
||||
register char *p;
|
||||
register unsigned char *t;
|
||||
register unsigned char *p;
|
||||
register int n;
|
||||
register int argno;
|
||||
|
||||
@ -688,7 +688,7 @@ dosub(argv, argc)
|
||||
register char *argv[];
|
||||
register int argc;
|
||||
{
|
||||
register char *ap, *fc, *k;
|
||||
register unsigned char *ap, *fc, *k;
|
||||
register int nc;
|
||||
|
||||
if (argc < 5)
|
||||
|
@ -65,7 +65,7 @@ void map __P((char *, char *, char *, char *));
|
||||
void onintr __P((int));
|
||||
void oops __P((const char *, ...));
|
||||
void pbnum __P((int));
|
||||
void pbstr __P((char *));
|
||||
void pbstr __P((unsigned char *));
|
||||
void putback __P((int));
|
||||
void remhash __P((char *, int));
|
||||
void usage __P((void));
|
||||
@ -79,13 +79,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 unsigned char *bp; /* first available character */
|
||||
extern unsigned char buf[]; /* push-back buffer */
|
||||
extern unsigned char *bufbase; /* buffer base for this ilevel */
|
||||
extern unsigned char *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 unsigned char *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 */
|
||||
|
@ -63,11 +63,11 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
|
||||
#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 */
|
||||
unsigned char buf[BUFSIZE]; /* push-back buffer */
|
||||
unsigned char *bufbase = buf; /* the base for current ilevel */
|
||||
unsigned char *bbase[MAXINP]; /* the base for each ilevel */
|
||||
unsigned char *bp = buf; /* first available character */
|
||||
unsigned char *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 */
|
||||
@ -248,7 +248,7 @@ macro() {
|
||||
register int nlpar;
|
||||
|
||||
cycle {
|
||||
if ((t = gpbc()) == '_' || isalpha(t)) {
|
||||
if ((t = gpbc()) == '_' || (t != EOF && isalpha(t))) {
|
||||
putback(t);
|
||||
if ((p = inspect(s = token)) == nil) {
|
||||
if (sp < 0)
|
||||
@ -327,7 +327,7 @@ macro() {
|
||||
case LPAREN:
|
||||
if (PARLEV > 0)
|
||||
chrsave(t);
|
||||
while (isspace(l = gpbc()))
|
||||
while ((l = gpbc()) != EOF && isspace(l))
|
||||
; /* skip blank, tab, nl.. */
|
||||
putback(l);
|
||||
PARLEV++;
|
||||
@ -356,7 +356,7 @@ macro() {
|
||||
case COMMA:
|
||||
if (PARLEV == 1) {
|
||||
chrsave(EOS); /* new argument */
|
||||
while (isspace(l = gpbc()))
|
||||
while ((l = gpbc()) != EOF && isspace(l))
|
||||
;
|
||||
putback(l);
|
||||
pushs(ep);
|
||||
@ -380,13 +380,13 @@ ndptr
|
||||
inspect(tp)
|
||||
register char *tp;
|
||||
{
|
||||
register char c;
|
||||
register int c;
|
||||
register char *name = tp;
|
||||
register char *etp = tp+MAXTOK;
|
||||
register ndptr p;
|
||||
register unsigned long h = 0;
|
||||
|
||||
while ((isalnum(c = gpbc()) || c == '_') && tp < etp)
|
||||
while ((c = gpbc()) != EOF && (isalnum(c) || c == '_') && tp < etp)
|
||||
h = (h << 5) + h + (*tp++ = c);
|
||||
putback(c);
|
||||
if (tp == etp)
|
||||
|
@ -142,7 +142,7 @@ typedef union { /* stack structure */
|
||||
* pushf() - push a call frame entry onto stack
|
||||
* pushs() - push a string pointer onto stack
|
||||
*/
|
||||
#define gpbc() (bp > bufbase) ? *--bp : getc(infile[ilevel])
|
||||
#define gpbc() (bp > bufbase) ? (*--bp ? *bp : EOF) : getc(infile[ilevel])
|
||||
#define pushf(x) if (sp < STACKMAX) mstack[++sp].sfra = (x)
|
||||
#define pushs(x) if (sp < STACKMAX) mstack[++sp].sstr = (x)
|
||||
|
||||
|
@ -73,8 +73,10 @@ char *s2;
|
||||
*/
|
||||
void
|
||||
putback(c)
|
||||
char c;
|
||||
int c;
|
||||
{
|
||||
if (c == EOF)
|
||||
c = 0;
|
||||
if (bp < endpbb)
|
||||
*bp++ = c;
|
||||
else
|
||||
@ -88,10 +90,10 @@ char c;
|
||||
*/
|
||||
void
|
||||
pbstr(s)
|
||||
register char *s;
|
||||
register unsigned char *s;
|
||||
{
|
||||
register char *es;
|
||||
register char *zp;
|
||||
register unsigned char *es;
|
||||
register unsigned char *zp;
|
||||
|
||||
es = s;
|
||||
zp = bp;
|
||||
|
Loading…
Reference in New Issue
Block a user