diff options
author | obrien <obrien@FreeBSD.org> | 2001-07-24 14:09:47 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-07-24 14:09:47 +0000 |
commit | 0004ccf79876c8bdda19ea656a8360faae38bd8c (patch) | |
tree | fc273fb6f58ca353dc8b70c80556ee29a1278ba7 | |
parent | f842b779c36c44bc686f6d57b2392f5fdb3fd25b (diff) | |
download | FreeBSD-src-0004ccf79876c8bdda19ea656a8360faae38bd8c.zip FreeBSD-src-0004ccf79876c8bdda19ea656a8360faae38bd8c.tar.gz |
Remove the local basename in favor of the libc version.
Remove xmalloc and xstrdup and do the error checking at the place of use.
-rw-r--r-- | usr.bin/m4/eval.c | 11 | ||||
-rw-r--r-- | usr.bin/m4/extern.h | 3 | ||||
-rw-r--r-- | usr.bin/m4/look.c | 9 | ||||
-rw-r--r-- | usr.bin/m4/main.c | 9 | ||||
-rw-r--r-- | usr.bin/m4/misc.c | 33 |
5 files changed, 22 insertions, 43 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c index 7133013..ced63cd 100644 --- a/usr.bin/m4/eval.c +++ b/usr.bin/m4/eval.c @@ -86,6 +86,7 @@ register int td; { register int c, n; static int sysval = 0; + char *p; #ifdef DEBUG printf("argc = %d\n", argc); @@ -352,7 +353,9 @@ register int td; * dom4wrap - set up for * wrap-up/wind-down activity */ - m4wraps = (argc > 2) ? xstrdup(argv[2]) : null; + if ((p = strdup(argv[2])) == NULL) + err(1, "strdup"); + m4wraps = (argc > 2) ? p : null; break; case EXITTYPE: @@ -472,7 +475,8 @@ register char *defn; if (!*defn) p->defn = null; else - p->defn = xstrdup(defn); + if ((p->defn = strdup(defn)) == NULL) + err(1, "strdup"); p->type = MACRTYPE; } @@ -515,7 +519,8 @@ register char *defn; if (!*defn) p->defn = null; else - p->defn = xstrdup(defn); + if ((p->defn = strdup(defn)) == NULL) + err(1, "strdup"); p->type = MACRTYPE; } diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h index e791ee2..a9e51f7 100644 --- a/usr.bin/m4/extern.h +++ b/usr.bin/m4/extern.h @@ -37,8 +37,6 @@ * $FreeBSD$ */ -char *basename __P((char *)); -char *xalloc __P((unsigned long)); int expr __P((char *)); ndptr addent __P((char *)); void chrsave __P((int)); @@ -58,7 +56,6 @@ void doundiv __P((char *[], int)); void eval __P((char *[], int, int)); void expand __P((char *[], int)); void getdiv __P((int)); -char *xstrdup __P((const char *)); int hash __P((char *)); int indx __P((char *, char *)); void killdiv __P((void)); diff --git a/usr.bin/m4/look.c b/usr.bin/m4/look.c index 3635e1b..73f5a22 100644 --- a/usr.bin/m4/look.c +++ b/usr.bin/m4/look.c @@ -36,6 +36,8 @@ #ifndef lint static char sccsid[] = "@(#)look.c 8.1 (Berkeley) 6/6/93"; +static char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ /* @@ -45,6 +47,7 @@ static char sccsid[] = "@(#)look.c 8.1 (Berkeley) 6/6/93"; */ #include <sys/types.h> +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -89,10 +92,12 @@ char *name; ndptr p; h = hash(name); - p = (ndptr) xalloc(sizeof(struct ndblock)); + if ((p = malloc(sizeof(struct ndblock))) == NULL) + err(1, "malloc"); p->nxtptr = hashtab[h]; hashtab[h] = p; - p->name = xstrdup(name); + if ((p->name = strdup(name)) == NULL) + err(1, "strdup"); return p; } diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index 86253eb..037cbd7 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -59,6 +59,7 @@ static const char rcsid[] = #include <err.h> #include <signal.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include "mdef.h" @@ -181,8 +182,11 @@ main(argc,argv) argv += optind; active = stdout; /* default active output */ + if ((p = strdup(_PATH_DIVDIRNAME)) == NULL) + err(1, "strdup"); + /* filename for diversions */ - m4dir = mkdtemp(xstrdup(_PATH_DIVDIRNAME)); + m4dir = mkdtemp(p); err_set_exit(cleanup); (void) asprintf(&m4temp, "%s/%s", m4dir, _PATH_DIVNAME); @@ -406,7 +410,8 @@ initkwds() { for (i = 0; i < MAXKEYS; i++) { h = hash(keywrds[i].knam); - p = (ndptr) xalloc(sizeof(struct ndblock)); + if ((p = malloc(sizeof(struct ndblock))) == NULL) + err(1, "malloc"); p->nxtptr = hashtab[h]; hashtab[h] = p; p->name = keywrds[i].knam; diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c index 3c64eb1..907f909 100644 --- a/usr.bin/m4/misc.c +++ b/usr.bin/m4/misc.c @@ -203,39 +203,6 @@ killdiv() } } -char * -xalloc(n) -unsigned long n; -{ - register char *p = malloc(n); - - if (p == NULL) - err(1, "malloc"); - return p; -} - -char * -xstrdup(s) -const char *s; -{ - register char *p = strdup(s); - if (p == NULL) - err(1, "strdup"); - return p; -} - -char * -basename(s) -register char *s; -{ - register char *p; - - if ((p = strrchr(s, '/')) == NULL) - return s; - - return ++p; -} - void cleanup(n) int n; |