diff options
Diffstat (limited to 'lib/libc/stdlib/getopt_long.3')
-rw-r--r-- | lib/libc/stdlib/getopt_long.3 | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/lib/libc/stdlib/getopt_long.3 b/lib/libc/stdlib/getopt_long.3 index 2bab9637341..53737d8f257 100644 --- a/lib/libc/stdlib/getopt_long.3 +++ b/lib/libc/stdlib/getopt_long.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: getopt_long.3,v 1.15 2007/07/03 12:06:07 jmc Exp $ +.\" $OpenBSD: getopt_long.3,v 1.16 2010/09/19 22:22:13 jmc Exp $ .\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $ .\" .\" Copyright (c) 1988, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 .\" -.Dd $Mdocdate: July 3 2007 $ +.Dd $Mdocdate: September 19 2010 $ .Dt GETOPT_LONG 3 .Os .Sh NAME @@ -204,41 +204,6 @@ if there was a missing option argument, .Sq \&? if the user specified an unknown or ambiguous option, and \-1 when the argument list has been exhausted. -.Sh EXAMPLES -.Bd -literal -int bflag, ch, fd; -int daggerset; - -/* options descriptor */ -static struct option longopts[] = { - { "buffy", no_argument, NULL, 'b' }, - { "fluoride", required_argument, NULL, 'f' }, - { "daggerset", no_argument, &daggerset, 1 }, - { NULL, 0, NULL, 0 } -}; - -bflag = 0; -while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) - switch (ch) { - case 'b': - bflag = 1; - break; - case 'f': - if ((fd = open(optarg, O_RDONLY, 0)) == -1) - err(1, "unable to open %s", optarg); - break; - case 0: - if (daggerset) - fprintf(stderr, "Buffy will use her dagger to " - "apply fluoride to dracula's teeth\en"); - break; - default: - usage(); - /* NOTREACHED */ - } -argc -= optind; -argv += optind; -.Ed .Sh IMPLEMENTATION DIFFERENCES This section describes differences to the GNU implementation found in glibc-2.1.3: @@ -444,6 +409,41 @@ in the .Ar optstring is ignored. .El +.Sh EXAMPLES +.Bd -literal +int bflag, ch, fd; +int daggerset; + +/* options descriptor */ +static struct option longopts[] = { + { "buffy", no_argument, NULL, 'b' }, + { "fluoride", required_argument, NULL, 'f' }, + { "daggerset", no_argument, &daggerset, 1 }, + { NULL, 0, NULL, 0 } +}; + +bflag = 0; +while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) + switch (ch) { + case 'b': + bflag = 1; + break; + case 'f': + if ((fd = open(optarg, O_RDONLY, 0)) == -1) + err(1, "unable to open %s", optarg); + break; + case 0: + if (daggerset) + fprintf(stderr, "Buffy will use her dagger to " + "apply fluoride to dracula's teeth\en"); + break; + default: + usage(); + /* NOTREACHED */ + } +argc -= optind; +argv += optind; +.Ed .Sh SEE ALSO .Xr getopt 3 .Sh HISTORY |