WARNSify, fix .Nm usage

This commit is contained in:
lukem 1997-10-19 02:13:39 +00:00
parent fb9ee7e315
commit 8c012c7268
4 changed files with 42 additions and 34 deletions

View File

@ -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 .

View File

@ -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 <sys/cdefs.h>
#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 <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
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 */
}

View File

@ -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.
shell options varies from one shell version to another.

View File

@ -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 <sys/cdefs.h>
#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 <errno.h>
#include <stdio.h>
#include <stdlib.h>
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 */