summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/getopt.3
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2000-12-15 14:15:28 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2000-12-15 14:15:28 +0000
commit205e0a000b56bf187066e05e7b01634cbff95642 (patch)
tree31939f6dd19d2b858cc1069fd57bca920532c1b7 /lib/libc/stdlib/getopt.3
parent6fa3c29bf1fc1d22f7a3b0a4be7c2d4c8d39af5b (diff)
.Sh EXAMPLE -> .Sh EXAMPLES. Move this section before SEE ALSO where it
belongs. Closes PR/1554 from bk@rt.fm.
Diffstat (limited to 'lib/libc/stdlib/getopt.3')
-rw-r--r--lib/libc/stdlib/getopt.356
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/libc/stdlib/getopt.3 b/lib/libc/stdlib/getopt.3
index ef132cafc59..878290f5425 100644
--- a/lib/libc/stdlib/getopt.3
+++ b/lib/libc/stdlib/getopt.3
@@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: getopt.3,v 1.13 2000/04/20 13:50:02 aaron Exp $
+.\" $OpenBSD: getopt.3,v 1.14 2000/12/15 14:15:27 aaron Exp $
.\"
.Dd April 19, 1994
.Dt GETOPT 3
@@ -126,6 +126,33 @@ When all options have been processed (i.e., up to the first non-option
argument),
.Fn getopt
returns \-1.
+.Sh EXAMPLES
+.Bd -literal -compact
+extern char *optarg;
+extern int optind;
+int bflag, ch, fd;
+
+bflag = 0;
+while ((ch = getopt(argc, argv, "bf:")) != -1) {
+ switch (ch) {
+ case 'b':
+ bflag = 1;
+ break;
+ case 'f':
+ if ((fd = open(optarg, O_RDONLY, 0)) < 0) {
+ (void)fprintf(stderr,
+ "myname: %s: %s\en", optarg, strerror(errno));
+ exit(1);
+ }
+ break;
+ case '?':
+ default:
+ usage();
+ }
+}
+argc -= optind;
+argv += optind;
+.Ed
.Sh SEE ALSO
.Xr getopt 1 ,
.Xr getsubopt 3
@@ -162,33 +189,6 @@ function multiple times.
This is an extension to the
.St -p1003.2
specification.
-.Sh EXAMPLE
-.Bd -literal -compact
-extern char *optarg;
-extern int optind;
-int bflag, ch, fd;
-
-bflag = 0;
-while ((ch = getopt(argc, argv, "bf:")) != -1) {
- switch (ch) {
- case 'b':
- bflag = 1;
- break;
- case 'f':
- if ((fd = open(optarg, O_RDONLY, 0)) < 0) {
- (void)fprintf(stderr,
- "myname: %s: %s\en", optarg, strerror(errno));
- exit(1);
- }
- break;
- case '?':
- default:
- usage();
- }
-}
-argc -= optind;
-argv += optind;
-.Ed
.Sh HISTORY
The
.Fn getopt