From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: [PATCH] manual: Document optind zero set behaviour (BZ#23157)
Date: Mon, 21 May 2018 19:39:00 -0000 [thread overview]
Message-ID: <1526931539-11863-1-git-send-email-adhemerval.zanella@linaro.org> (raw)
POSIX [1] does not explicit state the expected way to rescans the same
vector more than once. FreeBSD [2], for instance, exports a non-standard
variable 'optreset' which must be set to '1' prior the second and each
additional call to 'getopt'. GLIBC in turn requires the program to
reset 'optind' to 0 instead (and POSIX states the behavior is unspecified).
Unfortunately this is not documented on the manual, only on man-pages [3]
(on NOTES). This patch adds an explanation of this behavior on manual.
* manual/getopt.texi: Document optind zero set behaviour.
[1] http://pubs.opengroup.org/onlinepubs/9699919799/
[2] https://www.freebsd.org/cgi/man.cgi?getopt(3)
[3] http://man7.org/linux/man-pages/man3/getopt.3.html
---
ChangeLog | 4 ++++
manual/getopt.texi | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/manual/getopt.texi b/manual/getopt.texi
index 5485fc4..a4f6366 100644
--- a/manual/getopt.texi
+++ b/manual/getopt.texi
@@ -45,6 +45,12 @@ of the @var{argv} array to be processed. Once @code{getopt} has found
all of the option arguments, you can use this variable to determine
where the remaining non-option arguments begin. The initial value of
this variable is @code{1}.
+
+Resetting the variable value to @code{0} forces the invocation of an
+internal initialization routine and it is used mainly when a program
+wants to rescan the same vector more than once. It also should be used
+to scan multiple argument vectors or if @code{POSIXLY_CORRECT} is changed
+between scans.
@end deftypevar
@deftypevar {char *} optarg
--
2.7.4
next reply other threads:[~2018-05-21 19:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 19:39 Adhemerval Zanella [this message]
2018-05-23 17:52 ` Carlos O'Donell
2018-05-29 18:45 ` Adhemerval Zanella
2018-05-29 20:02 ` Carlos O'Donell
2018-05-29 21:52 ` Adhemerval Zanella
2018-05-29 22:47 ` Paul Eggert
2018-05-30 16:18 ` Carlos O'Donell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1526931539-11863-1-git-send-email-adhemerval.zanella@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).