From 8c012c72685246870090596db865bac4a4b4d6fc Mon Sep 17 00:00:00 2001 From: lukem Date: Sun, 19 Oct 1997 02:13:39 +0000 Subject: [PATCH] WARNSify, fix .Nm usage --- usr.bin/getconf/getconf.1 | 10 +++++----- usr.bin/getconf/getconf.c | 17 ++++++++++------- usr.bin/getopt/getopt.1 | 31 ++++++++++++++++--------------- usr.bin/getopt/getopt.c | 18 +++++++++++------- 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/usr.bin/getconf/getconf.1 b/usr.bin/getconf/getconf.1 index ccdf92328831..f8d94481e485 100644 --- a/usr.bin/getconf/getconf.1 +++ b/usr.bin/getconf/getconf.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: getconf.1,v 1.3 1997/10/08 22:26:29 jtc Exp $ +.\" $NetBSD: getconf.1,v 1.4 1997/10/19 02:13:39 lukem Exp $ .\" .\" Copyright (c) 1996 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -41,12 +41,12 @@ .Nm getconf .Nd get configuration values .Sh SYNOPSIS -.Nm getconf +.Nm .Ar name .Op Ar pathname .Sh DESCRIPTION The -.Nm getconf +.Nm utility writes the current value of a configurable system limit or option variable to the standard output. .Pp @@ -59,7 +59,7 @@ argument must be supplied for system variables associated with a pathname. .Sh RETURN VALUE The -.Nm getconf +.Nm utility exits 0 on success, and >0 if an error occurs. .Sh SEE ALSO .Xr pathconf 2 , @@ -67,6 +67,6 @@ utility exits 0 on success, and >0 if an error occurs. .Xr sysconf 3 .Sh STANDARDS The -.Nm getconf +.Nm utility conforms to .St -p1003.2-92 . diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c index f419d02e29ac..c01cd006b79e 100644 --- a/usr.bin/getconf/getconf.c +++ b/usr.bin/getconf/getconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: getconf.c,v 1.5 1997/10/08 22:26:30 jtc Exp $ */ +/* $NetBSD: getconf.c,v 1.6 1997/10/19 02:13:41 lukem Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -36,17 +36,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #ifndef lint -static char rcsid[] = "$NetBSD: getconf.c,v 1.5 1997/10/08 22:26:30 jtc Exp $"; +__RCSID("$NetBSD: getconf.c,v 1.6 1997/10/19 02:13:41 lukem Exp $"); #endif /* not lint */ -#include -#include +#include +#include #include #include +#include +#include #include -#include +int main __P((int, char **)); static void usage __P((void)); struct conf_variable @@ -187,7 +190,7 @@ main(argc, argv) slen = confstr (cp->value, (char *) 0, (size_t) 0); if ((sval = malloc(slen)) == NULL) - err(1, NULL); + err(1, "malloc"); confstr(cp->value, sval, slen); printf("%s\n", sval); @@ -197,7 +200,7 @@ main(argc, argv) errno = 0; if ((val = sysconf(cp->value)) == -1) { if (errno != 0) { - err(1, NULL); + err(1, "malloc"); /* NOTREACHED */ } diff --git a/usr.bin/getopt/getopt.1 b/usr.bin/getopt/getopt.1 index ead400cbbda1..410f61b64dc3 100644 --- a/usr.bin/getopt/getopt.1 +++ b/usr.bin/getopt/getopt.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: getopt.1,v 1.7 1997/07/18 00:18:26 phil Exp $ +.\" $NetBSD: getopt.1,v 1.8 1997/10/19 02:16:57 lukem Exp $ .Dd June 21, 1993 .Dt GETOPT 1 .Os @@ -6,10 +6,11 @@ .Nm getopt .Nd parse command options .Sh SYNOPSIS -.Nm args=\`getopt optstring $*\` -.Nm set \-\- \`getopt optstring $*\` +.Li args=\`getopt optstring $*\` +.Pp +.Li set \-\- \`getopt optstring $*\` .Sh DESCRIPTION -.Nm Getopt +.Nm is used to break up options in command lines for easy parsing by shell procedures, and to check for legal options. .Op Optstring @@ -22,7 +23,7 @@ separated from it by white space. The special option .Dq \-\- is used to delimit the end of the options. -.Nm Getopt +.Nm will place .Dq \-\- in the arguments at the end of the options, @@ -76,22 +77,22 @@ cmd \-a \-oarg \-\- file file .Pp .St -p1003.2 mandates that the -.Nm sh +.Xr sh 1 set command return the value of 0 for the exit status. Therefore, the exit status of the -.Nm getopt +.Nm command is lost when -.Nm getopt +.Nm and the -.Nm sh +.Xr sh 1 set command are used on the same line. The example given is one way to detect errors found by -.Nm getopt . +.Nm "" . .Sh SEE ALSO .Xr sh 1 , .Xr getopt 3 .Sh DIAGNOSTICS -.Nm Getopt +.Nm prints an error message on the standard error output when it encounters an option letter not included in .Op optstring . @@ -108,13 +109,13 @@ generally will not survive intact; this looks easy to fix but isn't. .Pp The error message for an invalid option is identified as coming from -.Nm getopt +.Nm rather than from the shell procedure containing the invocation of -.Nm getopt ; +.Nm "" ; this again is hard to fix. .Pp The precise best way to use the -.Nm set +.Ic set command to set the arguments without disrupting the value(s) of -shell options varies from one shell version to another. \ No newline at end of file +shell options varies from one shell version to another. diff --git a/usr.bin/getopt/getopt.c b/usr.bin/getopt/getopt.c index f297f8c20409..a671410c8588 100644 --- a/usr.bin/getopt/getopt.c +++ b/usr.bin/getopt/getopt.c @@ -1,22 +1,26 @@ -/* $NetBSD: getopt.c,v 1.3 1997/01/09 20:19:47 tls Exp $ */ +/* $NetBSD: getopt.c,v 1.4 1997/10/19 02:16:59 lukem Exp $ */ +#include #ifndef lint -static char rcsid[] = "$NetBSD: getopt.c,v 1.3 1997/01/09 20:19:47 tls Exp $"; +__RCSID("$NetBSD: getopt.c,v 1.4 1997/10/19 02:16:59 lukem Exp $"); #endif /* not lint */ +#include #include +#include +int main __P((int, char **)); + +int main(argc, argv) -int argc; -char *argv[]; + int argc; + char *argv[]; { - extern int optind; - extern char *optarg; int c; int status = 0; optind = 2; /* Past the program name and the option letters. */ - while ((c = getopt(argc, argv, argv[1])) != EOF) + while ((c = getopt(argc, argv, argv[1])) != -1) switch (c) { case '?': status = 1; /* getopt routine gave message */