diff options
author | hoek <hoek@FreeBSD.org> | 1999-07-31 20:40:23 +0000 |
---|---|---|
committer | hoek <hoek@FreeBSD.org> | 1999-07-31 20:40:23 +0000 |
commit | 09a53fd5c6f60c39e4e980d9caf11e21482bb3c4 (patch) | |
tree | 5eda2d69466e89801b4a09d8a0aad94fbf3f5840 /usr.bin/make | |
parent | 19b723feccd9221ccdb7e7f9cd0fc56d767938cc (diff) | |
download | FreeBSD-src-09a53fd5c6f60c39e4e980d9caf11e21482bb3c4.zip FreeBSD-src-09a53fd5c6f60c39e4e980d9caf11e21482bb3c4.tar.gz |
Print an error message on illegal numerical arguments.
Submitted by: bin/9349 (slightly modified) Assar Westerlund <assar@sics.se>
Diffstat (limited to 'usr.bin/make')
-rw-r--r-- | usr.bin/make/main.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 6f9f8f6..6b06e68 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -47,7 +47,7 @@ static const char copyright[] = static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #endif static const char rcsid[] = - "$Id: main.c,v 1.29 1998/11/15 05:55:58 bde Exp $"; + "$Id: main.c,v 1.30 1999/03/01 06:01:05 imp Exp $"; #endif /* not lint */ /*- @@ -95,6 +95,7 @@ static const char rcsid[] = #include <errno.h> #include <fcntl.h> #include <stdio.h> +#include <sysexits.h> #if __STDC__ #include <stdarg.h> #else @@ -204,11 +205,18 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL); break; #ifdef REMOTE - case 'L': - maxLocal = atoi(optarg); + case 'L': { + char *endptr; + + maxLocal = strtol(optarg, &endptr, 10); + if (maxLocal < 0 || *endptr != '\0') { + errx(EX_USAGE, + "illegal argument to -L -- %s", optarg); + } Var_Append(MAKEFLAGS, "-L", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; + } #endif case 'P': usePipes = FALSE; @@ -282,15 +290,22 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { ignoreErrors = TRUE; Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL); break; - case 'j': + case 'j': { + char *endptr; + forceJobs = TRUE; - maxJobs = atoi(optarg); + maxJobs = strtol(optarg, &endptr, 10); + if (maxJobs <= 0 || *endptr != '\0') { + errx(EX_USAGE, + "illegal argument to -j -- %s", optarg); + } #ifndef REMOTE maxLocal = maxJobs; #endif Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; + } case 'k': keepgoing = TRUE; Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL); |