From 50841d34c66233aebf8b6eb5a78a622955bfc100 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Tue, 26 Feb 1991 22:05:45 -0800 Subject: [PATCH] ANSI fixes, use strdup(3) instead of rolling your own SCCS-vsn: usr.bin/m4/eval.c 5.4 SCCS-vsn: usr.bin/m4/expr.c 5.3 SCCS-vsn: usr.bin/m4/look.c 5.3 SCCS-vsn: usr.bin/m4/main.c 5.5 SCCS-vsn: usr.bin/m4/mdef.h 5.6 SCCS-vsn: usr.bin/m4/misc.c 5.6 SCCS-vsn: usr.bin/m4/serv.c 5.3 --- usr/src/usr.bin/m4/eval.c | 10 ++++++---- usr/src/usr.bin/m4/expr.c | 6 ++++-- usr/src/usr.bin/m4/look.c | 9 +++++---- usr/src/usr.bin/m4/main.c | 16 ++++++++++------ usr/src/usr.bin/m4/mdef.h | 7 +------ usr/src/usr.bin/m4/misc.c | 27 ++++++++------------------- usr/src/usr.bin/m4/serv.c | 11 +++++++---- 7 files changed, 41 insertions(+), 45 deletions(-) diff --git a/usr/src/usr.bin/m4/eval.c b/usr/src/usr.bin/m4/eval.c index 65429d84a5..3327bef4ef 100644 --- a/usr/src/usr.bin/m4/eval.c +++ b/usr/src/usr.bin/m4/eval.c @@ -9,7 +9,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)eval.c 5.3 (Berkeley) %G%"; +static char sccsid[] = "@(#)eval.c 5.4 (Berkeley) %G%"; #endif /* not lint */ /* @@ -18,12 +18,14 @@ static char sccsid[] = "@(#)eval.c 5.3 (Berkeley) %G%"; * by: oz */ +#include +#include +#include +#include #include "mdef.h" #include "extr.h" extern ndptr lookup(); -extern char *strsave(); -extern char *mktemp(); /* * eval - evaluate built-in macros. @@ -322,7 +324,7 @@ register int td; * dom4wrap - set up for wrap-up/wind-down activity * */ - m4wraps = (argc > 2) ? strsave(argv[2]) : null; + m4wraps = (argc > 2) ? strdup(argv[2]) : null; break; case EXITTYPE: diff --git a/usr/src/usr.bin/m4/expr.c b/usr/src/usr.bin/m4/expr.c index b5363d9daa..5634412062 100644 --- a/usr/src/usr.bin/m4/expr.c +++ b/usr/src/usr.bin/m4/expr.c @@ -9,9 +9,12 @@ */ #ifndef lint -static char sccsid[] = "@(#)expr.c 5.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)expr.c 5.3 (Berkeley) %G%"; #endif /* not lint */ +#include +#include + /* * expression evaluator: performs a standard recursive * descent parse to evaluate any expression permissible @@ -74,7 +77,6 @@ static char *nxtch; /* Parser scan pointer */ /* * For longjmp */ -#include static jmp_buf expjump; /* diff --git a/usr/src/usr.bin/m4/look.c b/usr/src/usr.bin/m4/look.c index d9bd868f15..7e9c6eca5f 100644 --- a/usr/src/usr.bin/m4/look.c +++ b/usr/src/usr.bin/m4/look.c @@ -9,7 +9,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)look.c 5.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)look.c 5.3 (Berkeley) %G%"; #endif /* not lint */ /* @@ -18,11 +18,12 @@ static char sccsid[] = "@(#)look.c 5.2 (Berkeley) %G%"; * by: oz */ +#include +#include +#include #include "mdef.h" #include "extr.h" -extern char *strsave(); - /* * hash - compute hash value using the proverbial * hashing function. Taken from K&R. @@ -66,7 +67,7 @@ char *name; if ((p = (ndptr) malloc(sizeof(struct ndblock))) != NULL) { p->nxtptr = hashtab[h]; hashtab[h] = p; - p->name = strsave(name); + p->name = strdup(name); } else error("m4: no more memory."); diff --git a/usr/src/usr.bin/m4/main.c b/usr/src/usr.bin/m4/main.c index 2f9511ad13..28d9d536b6 100644 --- a/usr/src/usr.bin/m4/main.c +++ b/usr/src/usr.bin/m4/main.c @@ -9,7 +9,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)main.c 5.4 (Berkeley) %G%"; +static char sccsid[] = "@(#)main.c 5.5 (Berkeley) %G%"; #endif /* not lint */ /* @@ -18,7 +18,13 @@ static char sccsid[] = "@(#)main.c 5.4 (Berkeley) %G%"; * by: oz */ +#include +#include +#include +#include +#include #include "mdef.h" +#include "pathnames.h" /* * m4 - macro processor @@ -174,16 +180,14 @@ struct keyblk keywrds[] = { /* m4 keywords to be installed */ extern ndptr lookup(); extern ndptr addent(); -extern int onintr(); - -extern char *malloc(); -extern char *mktemp(); +extern void onintr(); extern int optind; extern char *optarg; main(argc,argv) -char *argv[]; + int argc; + char **argv; { register int c; register int n; diff --git a/usr/src/usr.bin/m4/mdef.h b/usr/src/usr.bin/m4/mdef.h index 60756798e7..5de520f4eb 100644 --- a/usr/src/usr.bin/m4/mdef.h +++ b/usr/src/usr.bin/m4/mdef.h @@ -7,7 +7,7 @@ * * %sccs.include.redist.c% * - * @(#)mdef.h 5.5 (Berkeley) %G% + * @(#)mdef.h 5.6 (Berkeley) %G% */ /* @@ -16,11 +16,6 @@ * by: oz */ -#include -#include -#include -#include "pathnames.h" - /* * * m4 constants.. diff --git a/usr/src/usr.bin/m4/misc.c b/usr/src/usr.bin/m4/misc.c index 4005b84179..be3cb8cc75 100644 --- a/usr/src/usr.bin/m4/misc.c +++ b/usr/src/usr.bin/m4/misc.c @@ -9,7 +9,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)misc.c 5.5 (Berkeley) %G%"; +static char sccsid[] = "@(#)misc.c 5.6 (Berkeley) %G%"; #endif /* not lint */ /* @@ -18,10 +18,13 @@ static char sccsid[] = "@(#)misc.c 5.5 (Berkeley) %G%"; * by: oz */ +#include +#include +#include +#include #include "mdef.h" #include "extr.h" - -extern char *malloc(); +#include "pathnames.h" /* * indx - find the index of second str in the @@ -156,6 +159,7 @@ char *s; */ static char *msg = "\ninterrupted."; +void onintr() { error(msg); } @@ -175,22 +179,7 @@ killdiv() { } } -/* - * save a string somewhere.. - * - */ -char *strsave(s) -char *s; -{ - register int n; - char *p; - - if ((p = malloc (n = strlen(s)+1)) != NULL) - (void) memcpy(p, s, n); - return (p); -} - usage() { - fprintf(stderr, "Usage: m4 [-Dname[=val]] [-Uname]\n"); + fprintf(stderr, "usage: m4 [-Dname[=val]] [-Uname]\n"); exit(1); } diff --git a/usr/src/usr.bin/m4/serv.c b/usr/src/usr.bin/m4/serv.c index 51dbf10d8b..d15681e322 100644 --- a/usr/src/usr.bin/m4/serv.c +++ b/usr/src/usr.bin/m4/serv.c @@ -9,7 +9,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)serv.c 5.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)serv.c 5.3 (Berkeley) %G%"; #endif /* not lint */ /* @@ -18,12 +18,15 @@ static char sccsid[] = "@(#)serv.c 5.2 (Berkeley) %G%"; * by: oz */ +#include +#include +#include #include "mdef.h" #include "extr.h" +#include "pathnames.h" extern ndptr lookup(); extern ndptr addent(); -extern char *strsave(); char *dumpfmt = "`%s'\t`%s'\n"; /* format string for dumpdef */ @@ -107,7 +110,7 @@ register char *defn; if (!*defn) p->defn = null; else - p->defn = strsave(defn); + p->defn = strdup(defn); p->type = MACRTYPE; } @@ -149,7 +152,7 @@ register char *defn; if (!*defn) p->defn = null; else - p->defn = strsave(defn); + p->defn = strdup(defn); p->type = MACRTYPE; } -- 2.20.1