diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-04-20 01:49:10 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-04-20 01:49:10 +0000 |
commit | ecccdb870361f2e0e62aea65bc8fa21a5171ea06 (patch) | |
tree | 9d6147d43f9f794cfc750ecb3f50fb216c889a70 /usr.bin/m4/main.c | |
parent | 2e75617aafa86c07bed18ac6c9afca1d637e0523 (diff) | |
download | FreeBSD-src-ecccdb870361f2e0e62aea65bc8fa21a5171ea06.zip FreeBSD-src-ecccdb870361f2e0e62aea65bc8fa21a5171ea06.tar.gz |
Crank WARNS.
Cast sizeof() to (int), as it's being compared against an int, not a size_t.
If i is changed to a size_t, it means the logic must be slightly changed later
in the flow, where --i is checked to be >= 0. I am not sure I want to make a
logic change to account for clearing up a warning, when an aesthetic one will
keep from modifying the logic.
Other harmless casts, that I think I've made in the right directions.
Make gpbc() an inline function, rather than an obfuscated macro, make its
scratch space local, rather than global. The previous macro used a dirty
hack (logical AND in place of a conditional) which would lead GCC to throw
a fit (rightly so) as the logical check, as well as the incrementation of
a variable, were not used for anything.
const'ify a few places where gcc3 yells. xstrdup() some global consts in
places where we xstrdup() when not using consts, but tried to assign them
to non-consts before.
Don't use execv(2) if we don't have the kind of arguments it wants.
Reviewed by: asmodai obrien tjr
Submitted by: tjr (a gcc3 build log)
Diffstat (limited to 'usr.bin/m4/main.c')
-rw-r--r-- | usr.bin/m4/main.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index 34020e9..87fc0d3 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -80,14 +80,13 @@ int maxout; FILE *active; /* active output file pointer */ int ilevel = 0; /* input file stack pointer */ int oindex = 0; /* diversion index.. */ -char *null = ""; /* as it says.. just a null.. */ -char *m4wraps = ""; /* m4wrap string default.. */ +const char *null = ""; /* as it says.. just a null.. */ +const char *m4wraps = ""; /* m4wrap string default.. */ char lquote[MAXCCHARS+1] = {LQUOTE}; /* left quote character (`) */ char rquote[MAXCCHARS+1] = {RQUOTE}; /* right quote character (') */ char scommt[MAXCCHARS+1] = {SCOMMT}; /* start character for comment */ char ecommt[MAXCCHARS+1] = {ECOMMT}; /* end character for comment */ int synccpp; /* Line synchronisation for C preprocessor */ -int chscratch; /* Scratch space for gpbc() macro */ struct keyblk keywrds[] = { /* m4 keywords to be installed */ { "include", INCLTYPE }, @@ -476,14 +475,14 @@ macro() default: if (LOOK_AHEAD(t, scommt)) { - char *p; - for (p = scommt; *p; p++) - chrsave(*p); + char *pc; + for (pc = scommt; *pc; pc++) + chrsave(*pc); for(;;) { t = gpbc(); if (LOOK_AHEAD(t, ecommt)) { - for (p = ecommt; *p; p++) - chrsave(*p); + for (pc = ecommt; *pc; pc++) + chrsave(*pc); break; } if (t == EOF) @@ -574,7 +573,7 @@ initkwds() p->nxtptr = hashtab[h % HASHSIZE]; hashtab[h % HASHSIZE] = p; p->name = xstrdup(keywrds[i].knam); - p->defn = null; + p->defn = xstrdup(null); p->hv = h; p->type = keywrds[i].ktyp & TYPEMASK; if ((keywrds[i].ktyp & NOARGS) == 0) @@ -595,7 +594,7 @@ builtin_type(key) return -1; } -char * +const char * builtin_realname(n) int n; { |