Skip to content

Commit cbacc90

Browse files
committed
Merge from trunk
[SVN r61962]
1 parent ab9901f commit cbacc90

File tree

6 files changed

+32
-13
lines changed

6 files changed

+32
-13
lines changed

doc/tutorial.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ if (vm.count("compression")) {
7777
<para>It's now a good time to try compiling the code yourself, but if
7878
you're not yet ready, here's an example session:
7979
<screen>
80-
$<userinput>bin/gcc/debug/first</userinput>
80+
$ <userinput>bin/gcc/debug/first</userinput>
8181
Compression level was not set.
82-
$<userinput>bin/gcc/debug/first --help</userinput>
82+
$ <userinput>bin/gcc/debug/first --help</userinput>
8383
Allowed options:
8484
--help : produce help message
8585
--compression arg : set compression level
86-
$<userinput>bin/gcc/debug/first --compression 10</userinput>
86+
$ <userinput>bin/gcc/debug/first --compression 10</userinput>
8787
Compression level was set to 10.
8888
</screen>
8989
</para>
@@ -199,16 +199,16 @@ cout &lt;&lt; &quot;Optimization level is &quot; &lt;&lt; opt &lt;&lt; &quot;\n&
199199

200200
<para>Here's an example session:
201201
<screen>
202-
$<userinput>bin/gcc/debug/options_description --help</userinput>
202+
$ <userinput>bin/gcc/debug/options_description --help</userinput>
203203
Usage: options_description [options]
204204
Allowed options:
205205
--help : produce help message
206206
--optimization arg : optimization level
207207
-I [ --include-path ] arg : include path
208208
--input-file arg : input file
209-
$bin/gcc/debug/options_description
209+
$ <userinput>bin/gcc/debug/options_description</userinput>
210210
Optimization level is 10
211-
$<userinput>bin/gcc/debug/options_description --optimization 4 -I foo a.cpp</userinput>
211+
$ <userinput>bin/gcc/debug/options_description --optimization 4 -I foo a.cpp</userinput>
212212
Include paths are: foo
213213
Input files are: a.cpp
214214
Optimization level is 4
@@ -308,10 +308,10 @@ visible.add(generic).add(config);
308308

309309
<para>Here's an example session:
310310
<screen>
311-
$<userinput>bin/gcc/debug/multiple_sources</userinput>
311+
$ <userinput>bin/gcc/debug/multiple_sources</userinput>
312312
Include paths are: /opt
313313
Optimization level is 1
314-
$<userinput>bin/gcc/debug/multiple_sources --help</userinput>
314+
$ <userinput>bin/gcc/debug/multiple_sources --help</userinput>
315315
Allows options:
316316

317317
Generic options:
@@ -322,7 +322,7 @@ Configuration:
322322
--optimization n : optimization level
323323
-I [ --include-path ] path : include path
324324

325-
$<userinput>bin/gcc/debug/multiple_sources --optimization=4 -I foo a.cpp b.cpp</userinput>
325+
$ <userinput>bin/gcc/debug/multiple_sources --optimization=4 -I foo a.cpp b.cpp</userinput>
326326
Include paths are: foo /opt
327327
Input files are: a.cpp b.cpp
328328
Optimization level is 4

example/Jamfile.v2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
project
33
: requirements <library>../build//boost_program_options
44
<hardcode-dll-paths>true
5+
<link>static
56
;
67

78
exe first : first.cpp ;

example/multiple_sources.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int main(int ac, char* av[])
7979
ifstream ifs(config_file.c_str());
8080
if (!ifs)
8181
{
82-
cout << "can not open config file: " << config_file << "\n";
82+
cout << "can not open config file: " << config_file << "\n";
8383
return 0;
8484
}
8585
else

src/options_description.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ namespace boost { namespace program_options {
306306
bool short_ignore_case) const
307307
{
308308
shared_ptr<option_description> found;
309+
bool had_full_match = false;
309310
vector<string> approximate_matches;
310311
vector<string> full_matches;
311312

@@ -323,15 +324,17 @@ namespace boost { namespace program_options {
323324
if (r == option_description::full_match)
324325
{
325326
full_matches.push_back(m_options[i]->key(name));
327+
found = m_options[i];
328+
had_full_match = true;
326329
}
327330
else
328331
{
329332
// FIXME: the use of 'key' here might not
330333
// be the best approach.
331334
approximate_matches.push_back(m_options[i]->key(name));
335+
if (!had_full_match)
336+
found = m_options[i];
332337
}
333-
334-
found = m_options[i];
335338
}
336339
if (full_matches.size() > 1)
337340
boost::throw_exception(

src/winmain.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace boost { namespace program_options {
3030

3131
std::string current;
3232
bool inside_quoted = false;
33+
bool empty_quote = false;
3334
int backslash_count = 0;
3435

3536
for(; i != e; ++i) {
@@ -38,6 +39,7 @@ namespace boost { namespace program_options {
3839
// n/2 backslashes and is a quoted block delimiter
3940
if (backslash_count % 2 == 0) {
4041
current.append(backslash_count / 2, '\\');
42+
empty_quote = inside_quoted && current.empty();
4143
inside_quoted = !inside_quoted;
4244
// '"' preceded by odd number (n) of backslashes generates
4345
// (n-1)/2 backslashes and is literal quote.
@@ -59,6 +61,7 @@ namespace boost { namespace program_options {
5961
// Space outside quoted section terminate the current argument
6062
result.push_back(current);
6163
current.resize(0);
64+
empty_quote = false;
6265
for(;i != e && isspace((unsigned char)*i); ++i)
6366
;
6467
--i;
@@ -74,7 +77,7 @@ namespace boost { namespace program_options {
7477

7578
// If we have non-empty 'current' or we're still in quoted
7679
// section (even if 'current' is empty), add the last token.
77-
if (!current.empty() || inside_quoted)
80+
if (!current.empty() || inside_quoted || empty_quote)
7881
result.push_back(current);
7982
}
8083
return result;
@@ -94,3 +97,4 @@ namespace boost { namespace program_options {
9497

9598
}}
9699
#endif
100+

test/options_description_test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ void test_approximation()
5353
BOOST_CHECK_EQUAL(desc.find("all", true).long_name(), "all");
5454
BOOST_CHECK_EQUAL(desc.find("all-ch", true).long_name(), "all-chroots");
5555

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+
5667

5768
// BOOST_CHECK(desc.count_approx("foo") == 1);
5869
// set<string> a = desc.approximations("f");

0 commit comments

Comments
 (0)