[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] bug in option.cc getopt
From: |
Stephen Leake |
Subject: |
Re: [Monotone-devel] bug in option.cc getopt |
Date: |
Sun, 22 Aug 2010 09:04:58 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) |
Stephen Leake <address@hidden> writes:
> revision 774b2d041536fd47832d7f844688061791847295 Timothy Brownawell
> <address@hidden> 2010-08-11T13:07:52
>
> introduced a bug in option.cc getopt; it can't handle an empty string
> for 'name.
>
> This only happens in MinGW, in tests/automate_identify.
>
> I'm not clear yet why it is getting an empty string.
>
> I also don't see what the proper result should be.
Figured it out. The test is this:
-- check what happens if our filename is the stdin marker (hint: it should stop)
check(mtn("automate", "identify", "-"), 1, false, false)
so the option name is the empty string.
This line:
string err = (F("option '%s' has multiple ambiguous expansions:")
% name).str();
throws an exception:
mtn: fatal: boost::io::bad_format_string: boost::bad_format_string:
format-string is ill-formed
Apparently boost 1.34.1 (on MinGW) doesn't accept an empty string in
this case, while boost 1.42 (on Debian) does? I didn't try to step into
the boost code.
mtn 0.48 says this for 'mtn automate identify -':
mtn: option error: unknown option ''
So I just added a check for an empty name:
if (name.size() == 0)
throw unknown_option(name);
Now all tests are passing on MinGW
Hmm. That may conflict with this change:
075540bcf4d90afcc170e6f19b1e930501206fd6
2010-08-22T12:13:12 address@hidden
* option.cc (getopt): when a user tries to complete "-", we list
all available options, but of course all short-named options match
then as well, so we need to be more careful and cannot simply set
"--" in front of every option name
--
-- Stephe