X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff..a9aaacca3a68bb8d74fec09d8d8681a0efda2581:/stdlib/FreeBSD/getopt_long.3 diff --git a/stdlib/FreeBSD/getopt_long.3 b/stdlib/FreeBSD/getopt_long.3 index dde7980..6904716 100644 --- a/stdlib/FreeBSD/getopt_long.3 +++ b/stdlib/FreeBSD/getopt_long.3 @@ -29,9 +29,9 @@ .\" SUCH DAMAGE. .\" .\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 -.\" $FreeBSD: src/lib/libc/stdlib/getopt_long.3,v 1.11 2004/03/06 14:47:49 ache Exp $ +.\" $FreeBSD$ .\" -.Dd April 1, 2000 +.Dd December 25, 2011 .Dt GETOPT_LONG 3 .Os .Sh NAME @@ -130,11 +130,11 @@ field should be one of: .Pp .Bl -tag -width ".Dv optional_argument" -offset indent -compact .It Dv no_argument -no argument to the option is expect +no argument to the option is expected .It Dv required_argument an argument to the option is required -.It Li optional_argument -an argument to the option may be presented. +.It Dv optional_argument +an argument to the option may be presented .El .Pp If @@ -190,7 +190,7 @@ the single-character option is returned. If the .Fa flag field in -.Li struct option +.Vt "struct option" is .Dv NULL , .Fn getopt_long @@ -213,6 +213,18 @@ if there was a missing option argument, .Ql \&? if the user specified an unknown or ambiguous option, and \-1 when the argument list has been exhausted. +.Sh ENVIRONMENT +.Bl -tag -width ".Ev POSIXLY_CORRECT" +.It Ev POSIXLY_CORRECT +If set, option processing stops when the first non-option is found and +a leading +.Ql - +or +.Ql + +in the +.Fa optstring +is ignored. +.El .Sh EXAMPLES .Bd -literal -compact int bflag, ch, fd; @@ -227,7 +239,7 @@ static struct option longopts[] = { }; bflag = 0; -while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) +while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) { switch (ch) { case 'b': bflag = 1; @@ -244,6 +256,7 @@ while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) break; default: usage(); + } } argc -= optind; argv += optind; @@ -450,18 +463,6 @@ relative to current positions) are the same, though. (We do fewer variable swaps.) .El -.Sh ENVIRONMENT -.Bl -tag -width POSIXLY_CORRECT -.It Ev POSIXLY_CORRECT -If set, option processing stops when the first non-option is found and -a leading -.Ql - -or -.Ql + -in the -.Ar optstring -is ignored. -.El .Sh SEE ALSO .Xr getopt 3 .Sh HISTORY @@ -469,9 +470,9 @@ The .Fn getopt_long and .Fn getopt_long_only -functions first appeared in +functions first appeared in the .Tn GNU -libiberty. +libiberty library. The first .Bx implementation of @@ -494,9 +495,9 @@ in .Fx 5.2 . .Sh BUGS The -.Ar argv +.Fa argv argument is not really -.Dv const +.Vt const as its elements may be permuted (unless .Ev POSIXLY_CORRECT is set).