diff options
author | ache <ache@FreeBSD.org> | 1994-12-18 23:58:25 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-12-18 23:58:25 +0000 |
commit | 81a63dc6d52646c455526dfdbb36b02edc05fae1 (patch) | |
tree | f301128eb27e760abc9a085e9698d493868e52ed | |
parent | a1049f75bf8f7a542055d26c91470c9537bfae35 (diff) | |
download | FreeBSD-src-81a63dc6d52646c455526dfdbb36b02edc05fae1.zip FreeBSD-src-81a63dc6d52646c455526dfdbb36b02edc05fae1.tar.gz |
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
-rw-r--r-- | usr.bin/m4/eval.c | 6 | ||||
-rw-r--r-- | usr.bin/m4/extern.h | 12 | ||||
-rw-r--r-- | usr.bin/m4/main.c | 20 | ||||
-rw-r--r-- | usr.bin/m4/mdef.h | 2 | ||||
-rw-r--r-- | usr.bin/m4/misc.c | 10 |
5 files changed, 26 insertions, 24 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c index 0e77c6b..59fde31 100644 --- a/usr.bin/m4/eval.c +++ b/usr.bin/m4/eval.c @@ -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) diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h index b54a9b9..a8df3eb 100644 --- a/usr.bin/m4/extern.h +++ b/usr.bin/m4/extern.h @@ -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 */ diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index 221b865..d16bbf1 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -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) diff --git a/usr.bin/m4/mdef.h b/usr.bin/m4/mdef.h index cc256b0..239993a 100644 --- a/usr.bin/m4/mdef.h +++ b/usr.bin/m4/mdef.h @@ -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) diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c index 2ed115b..916edba 100644 --- a/usr.bin/m4/misc.c +++ b/usr.bin/m4/misc.c @@ -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; |