File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -306,6 +306,7 @@ namespace boost { namespace program_options {
306
306
bool short_ignore_case) const
307
307
{
308
308
shared_ptr<option_description> found;
309
+ bool had_full_match = false ;
309
310
vector<string> approximate_matches;
310
311
vector<string> full_matches;
311
312
@@ -323,15 +324,17 @@ namespace boost { namespace program_options {
323
324
if (r == option_description::full_match)
324
325
{
325
326
full_matches.push_back (m_options[i]->key (name));
327
+ found = m_options[i];
328
+ had_full_match = true ;
326
329
}
327
330
else
328
331
{
329
332
// FIXME: the use of 'key' here might not
330
333
// be the best approach.
331
334
approximate_matches.push_back (m_options[i]->key (name));
335
+ if (!had_full_match)
336
+ found = m_options[i];
332
337
}
333
-
334
- found = m_options[i];
335
338
}
336
339
if (full_matches.size () > 1 )
337
340
boost::throw_exception (
Original file line number Diff line number Diff line change @@ -53,6 +53,17 @@ void test_approximation()
53
53
BOOST_CHECK_EQUAL (desc.find (" all" , true ).long_name (), " all" );
54
54
BOOST_CHECK_EQUAL (desc.find (" all-ch" , true ).long_name (), " all-chroots" );
55
55
56
+ options_description desc2;
57
+ desc2.add_options ()
58
+ (" help" , " display this message" )
59
+ (" config" , value<string>(), " config file name" )
60
+ (" config-value" , value<string>(), " single config value" )
61
+ ;
62
+
63
+ BOOST_CHECK_EQUAL (desc2.find (" config" , true ).long_name (), " config" );
64
+ BOOST_CHECK_EQUAL (desc2.find (" config-value" , true ).long_name (),
65
+ " config-value" );
66
+
56
67
57
68
// BOOST_CHECK(desc.count_approx("foo") == 1);
58
69
// set<string> a = desc.approximations("f");
You can’t perform that action at this time.
0 commit comments