public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/11041] New: getopt -W doesn't work with optional arguments
@ 2009-12-02 1:16 ebb9 at byu dot net
2009-12-02 3:25 ` [Bug libc/11041] " ebb9 at byu dot net
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: ebb9 at byu dot net @ 2009-12-02 1:16 UTC (permalink / raw)
To: glibc-bugs
According to the getopt documentation, if "W;" is part of optstring, then '-W
foo' should behave like '--foo'. But if "foo" uses an optional_argument, this
is not the case, since optarg is not NULL when using -W.
$ cat foo.c
#include <stdio.h>
#include <getopt.h>
static const struct option opts[] =
{
{ "alpha", optional_argument, NULL, 'a' },
{ NULL, 0, NULL, 0 }
};
int
main(int argc, char **argv)
{
int c = getopt_long (argc, argv, "W;", opts, NULL);
if (c == -1)
puts ("got -1");
else
printf ("got %c, with arg %s\n", c, optarg);
return 0;
}
$ ./foo --a
got a, with arg (null)
$ ./foo -W a
got a, with arg a
--
Summary: getopt -W doesn't work with optional arguments
Product: glibc
Version: 2.11
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: ebb9 at byu dot net
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11041
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/11041] getopt -W doesn't work with optional arguments
2009-12-02 1:16 [Bug libc/11041] New: getopt -W doesn't work with optional arguments ebb9 at byu dot net
@ 2009-12-02 3:25 ` ebb9 at byu dot net
2009-12-02 17:52 ` ebb9 at byu dot net
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: ebb9 at byu dot net @ 2009-12-02 3:25 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From ebb9 at byu dot net 2009-12-02 03:25 -------
Created an attachment (id=4437)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=4437&action=view)
patch
2009-12-01 Eric Blake <ebb9@byu.net>
* posix/getopt.c (_getopt_internal_r): Allow long options with
optional arguments when using "W;" in optstring.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11041
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/11041] getopt -W doesn't work with optional arguments
2009-12-02 1:16 [Bug libc/11041] New: getopt -W doesn't work with optional arguments ebb9 at byu dot net
2009-12-02 3:25 ` [Bug libc/11041] " ebb9 at byu dot net
@ 2009-12-02 17:52 ` ebb9 at byu dot net
2009-12-02 18:08 ` ebb9 at byu dot net
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: ebb9 at byu dot net @ 2009-12-02 17:52 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From ebb9 at byu dot net 2009-12-02 17:52 -------
Another instance:
Commits b8b17701a and fc5f4a974 add special handling of getopt_long (but NOT
getopt_long_only) to recognize alternate spellings that would result in the same
behavior, and treat those as non-ambiguous. But -W did not pick up the same
code change.
$ cat foo.c
#include <stdio.h>
#include <getopt.h>
static const struct option opts[] =
{
{ "a1", no_argument, NULL, 'a' },
{ "a2", no_argument, NULL, 'a' },
{ NULL, 0, NULL, 0 }
};
int
main (int argc, char **argv)
{
int c = getopt_long (argc, argv, ":W;", opts, NULL);
if (c == -1)
puts ("got -1");
else
printf ("got %c\n", c);
return 0;
}
$ ./foo --a
got a
$ ./foo -W a
got ?
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11041
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/11041] getopt -W doesn't work with optional arguments
2009-12-02 1:16 [Bug libc/11041] New: getopt -W doesn't work with optional arguments ebb9 at byu dot net
2009-12-02 3:25 ` [Bug libc/11041] " ebb9 at byu dot net
2009-12-02 17:52 ` ebb9 at byu dot net
@ 2009-12-02 18:08 ` ebb9 at byu dot net
2009-12-02 18:37 ` ebb9 at byu dot net
2010-04-08 0:18 ` drepper at redhat dot com
4 siblings, 0 replies; 7+ messages in thread
From: ebb9 at byu dot net @ 2009-12-02 18:08 UTC (permalink / raw)
To: glibc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |11043
nThis| |
http://sourceware.org/bugzilla/show_bug.cgi?id=11041
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/11041] getopt -W doesn't work with optional arguments
2009-12-02 1:16 [Bug libc/11041] New: getopt -W doesn't work with optional arguments ebb9 at byu dot net
` (2 preceding siblings ...)
2009-12-02 18:08 ` ebb9 at byu dot net
@ 2009-12-02 18:37 ` ebb9 at byu dot net
2010-04-08 0:18 ` drepper at redhat dot com
4 siblings, 0 replies; 7+ messages in thread
From: ebb9 at byu dot net @ 2009-12-02 18:37 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From ebb9 at byu dot net 2009-12-02 18:36 -------
Created an attachment (id=4440)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=4440&action=view)
updated patch
2009-12-02 Eric Blake <ebb9@byu.net>
[BZ #11041]
* posix/getopt.c (_getopt_internal_r): Handle '-Wfoo' identically
to '--foo', with optional argument or non-ambiguous prefix.
--
What |Removed |Added
----------------------------------------------------------------------------
Attachment #4437 is|0 |1
obsolete| |
http://sourceware.org/bugzilla/show_bug.cgi?id=11041
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/11041] getopt -W doesn't work with optional arguments
2009-12-02 1:16 [Bug libc/11041] New: getopt -W doesn't work with optional arguments ebb9 at byu dot net
` (3 preceding siblings ...)
2009-12-02 18:37 ` ebb9 at byu dot net
@ 2010-04-08 0:18 ` drepper at redhat dot com
4 siblings, 0 replies; 7+ messages in thread
From: drepper at redhat dot com @ 2010-04-08 0:18 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2010-04-08 00:18 -------
Fixed in git.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://sourceware.org/bugzilla/show_bug.cgi?id=11041
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/11041] getopt -W doesn't work with optional arguments
[not found] <bug-11041-131@http.sourceware.org/bugzilla/>
@ 2014-06-30 20:36 ` fweimer at redhat dot com
0 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-30 20:36 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=11041
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-06-30 20:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-02 1:16 [Bug libc/11041] New: getopt -W doesn't work with optional arguments ebb9 at byu dot net
2009-12-02 3:25 ` [Bug libc/11041] " ebb9 at byu dot net
2009-12-02 17:52 ` ebb9 at byu dot net
2009-12-02 18:08 ` ebb9 at byu dot net
2009-12-02 18:37 ` ebb9 at byu dot net
2010-04-08 0:18 ` drepper at redhat dot com
[not found] <bug-11041-131@http.sourceware.org/bugzilla/>
2014-06-30 20:36 ` fweimer at redhat dot com
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).