[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

documentation/1554: getopt.3 doesn't follow mdoc.template




>Number:         1554
>Category:       documentation
>Synopsis:       getopt.3 is disorienting
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bugs
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 11 14:40:02 MST 2000
>Last-Modified:
>Originator:     Brian Kifiak
>Organization:
>Release:        -current
>Environment:
	System      : OpenBSD 2.8
	Architecture: OpenBSD.i386
	Machine     : i386
>Description:
	getopt.3 is disorienting.  it doesn't follow /usr/share/misc/mdoc.template.
>How-To-Repeat:
	read getopt.3.
>Fix:
Index: lib/libc/stdlib/getopt.3
===================================================================
RCS file: /cvs/src/lib/libc/stdlib/getopt.3,v
retrieving revision 1.13
diff -u -r1.13 getopt.3
--- lib/libc/stdlib/getopt.3	2000/04/20 13:50:02	1.13
+++ lib/libc/stdlib/getopt.3	2000/12/11 08:11:06
@@ -126,9 +126,33 @@
 argument),
 .Fn getopt
 returns \-1.
-.Sh SEE ALSO
-.Xr getopt 1 ,
-.Xr getsubopt 3
+.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 DIAGNOSTICS
 If the
 .Fn getopt
@@ -153,6 +177,9 @@
 Option arguments are allowed to begin with
 .Ql - ;
 this is reasonable but reduces the amount of error checking possible.
+.Sh SEE ALSO
+.Xr getopt 1 ,
+.Xr getsubopt 3
 .Sh EXTENSIONS
 The
 .Va optreset
@@ -162,33 +189,6 @@
 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

>Audit-Trail:
>Unformatted: