Subject: lib/22733: Few typos in getopt.3
To: None <gnats-bugs@gnats.netbsd.org>
From: Quentin Garnier <cube@cubidou.net>
List: netbsd-bugs
Date: 09/09/2003 21:07:27
>Number: 22733
>Category: lib
>Synopsis: Few typos in getopt.3
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: open
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Tue Sep 09 19:08:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Quentin Garnier
>Release: NetBSD 1.6Y
>Organization:
Quentin Garnier - cube@cubidou.net
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.
>Environment:
System: NetBSD padme 1.6Y NetBSD 1.6Y (PADME) #1: Sat Sep 6 09:39:49 CEST 2003 cube@padme:/amd/c3po/rep/NetBSD-src/padme/obj/amd/c3po/rep/NetBSD-src/current/src/sys/arch/i386/compile/NVIDIA i386
Architecture: i386
Machine: i386
>Description:
o Small typo in the text
o A typo in the final code snippet
o While we're here, also declare the variable
The s/ch/c typo was reported by masi on #NetBSD at freenode.
>How-To-Repeat:
>Fix:
Index: getopt.3
===================================================================
RCS file: /cvsroot/src/lib/libc/stdlib/getopt.3,v
retrieving revision 1.26
diff -u -r1.26 getopt.3
--- getopt.3 2003/08/07 16:43:39 1.26
+++ getopt.3 2003/09/09 19:05:26
@@ -127,7 +127,7 @@
.Ql --
(double dash) which causes
.Fn getopt
-to signal the end of argument processing and returns \-1.
+to signal the end of argument processing and return \-1.
When all options have been processed (i.e., up to the first non-option
argument),
.Fn getopt
@@ -242,14 +242,14 @@
The following code fragment works in most cases.
.Bd -literal -offset indent
int length;
-char *p;
+char *p,c;
while ((c = getopt(argc, argv, "0123456789")) != -1) {
switch (c) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
p = argv[optind - 1];
- if (p[0] == '-' \*[Am]\*[Am] p[1] == ch \*[Am]\*[Am] !p[2])
+ if (p[0] == '-' \*[Am]\*[Am] p[1] == c \*[Am]\*[Am] !p[2])
length = atoi(++p);
else
length = atoi(argv[optind] + 1);
>Release-Note:
>Audit-Trail:
>Unformatted: