[phobos] [BUG] Space not handled in std.getopt as documented
Jens Mueller
jens.k.mueller at gmx.de
Mon Jan 10 04:04:33 PST 2011
Hi,
there is a bug in std.getopt. The documentation says:
"To set timeout to 5, use either of the following: --timeout=5,
--timeout 5, --t=5, --t 5, or -t5. Forms such as -t 5 and -timeout=5
will be not accepted."
(http://www.digitalmars.com/d/2.0/phobos/std_getopt.html)
I.e. the following should work
unittest {
auto args = ["program.name", "--timeout 5"];
getopt(args, "timeout|t", &timeout);
assert(timeout == 5);
timeout = 0;
args = ["program.name", "--t 5"];
getopt(args, "timeout|t", &timeout);
assert(timeout == 5);
timeout = 0;
}
But it does not.
optMatch is missing the handling in case of a space character. Should
one adjust the documentation or handle the space character as
documented?
The attached patch fixes getopt to handle the space character properly.
Please review.
Jens
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getopt.d-dmd.2.051.patch
Type: text/x-diff
Size: 2036 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20110110/134b44ce/attachment.patch>
More information about the phobos
mailing list