From 1d5fa9d950aab078562e5ec6ac4999759ae30cc3 Mon Sep 17 00:00:00 2001 From: tjr Date: Mon, 16 Aug 2004 14:18:22 +0000 Subject: Store a pointer to "null" in struct ndblock's defn member instead of a duplicate allocated on the heap; the address defn points to is significant, and is checked against the address of "null" in certain conditionals. PR: 59883 MFC after: 1 week --- usr.bin/m4/eval.c | 6 +++--- usr.bin/m4/extern.h | 2 +- usr.bin/m4/main.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c index 6d2d0fde..060ce03 100644 --- a/usr.bin/m4/eval.c +++ b/usr.bin/m4/eval.c @@ -593,12 +593,12 @@ dodefine(const char *name, const char *defn) p->type = n & TYPEMASK; if ((n & NOARGS) == 0) p->type |= NEEDARGS; - p->defn = xstrdup(null); + p->defn = null; return; } } if (!*defn) - p->defn = xstrdup(null); + p->defn = null; else p->defn = xstrdup(defn); p->type = MACRTYPE; @@ -645,7 +645,7 @@ dopushdef(const char *name, const char *defn) CURRENT_LINE); p = addent(name); if (!*defn) - p->defn = xstrdup(null); + p->defn = null; else p->defn = xstrdup(defn); p->type = MACRTYPE; diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h index 88cba41..e96870b 100644 --- a/usr.bin/m4/extern.h +++ b/usr.bin/m4/extern.h @@ -149,7 +149,7 @@ extern char ecommt[MAXCCHARS+1];/* end character for comment */ extern char *ep; /* first free char in strspace */ extern char lquote[MAXCCHARS+1];/* left quote character (`) */ extern const char *m4wraps; /* m4wrap string default. */ -extern const char *null; /* as it says.. just a null. */ +extern char null[]; /* as it says.. just a null. */ extern char rquote[MAXCCHARS+1];/* right quote character (') */ extern char scommt[MAXCCHARS+1];/* start character for comment */ extern int synccpp; /* Line synchronisation for C preprocessor */ diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index 1c1ac45..847a372 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -93,7 +93,7 @@ int maxout; FILE *active; /* active output file pointer */ int ilevel = 0; /* input file stack pointer */ int oindex = 0; /* diversion index.. */ -const char *null = ""; /* as it says.. just a null.. */ +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 (') */ @@ -583,7 +583,7 @@ initkwds(void) p->nxtptr = hashtab[h % HASHSIZE]; hashtab[h % HASHSIZE] = p; p->name = xstrdup(keywrds[i].knam); - p->defn = xstrdup(null); + p->defn = null; p->hv = h; p->type = keywrds[i].ktyp & TYPEMASK; if ((keywrds[i].ktyp & NOARGS) == 0) -- cgit v1.1