Skip to content

Commit cddd2c5

Browse files
committed
Merge from trunk.
[SVN r77829]
1 parent c054a3b commit cddd2c5

23 files changed

+4965
-456
lines changed

build/Jamfile.v2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ SOURCES =
1212
lib boost_program_options
1313
: $(SOURCES).cpp
1414
: <link>shared:<define>BOOST_PROGRAM_OPTIONS_DYN_LINK=1 # tell source we're building dll's
15+
# See https://svn.boost.org/trac/boost/ticket/5049
16+
<target-os>hpux,<toolset>gcc:<define>_INCLUDE_STDC__SOURCE_199901
1517
:
1618
: <link>shared:<define>BOOST_PROGRAM_OPTIONS_DYN_LINK=1
1719
;

doc/overview.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ options_description desc;
181181
desc.add_options()
182182
("help", "produce help message")
183183
("compression", value&lt;string&gt;(), "compression level")
184-
("verbose", value&lt;string&gt;()->zero_tokens(), "verbosity level")
184+
("verbose", value&lt;string&gt;()->implicit_value("0"), "verbosity level")
185185
("email", value&lt;string&gt;()->multitoken(), "email to send to")
186186
;
187187
</programlisting>

example/first.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int main(int ac, char* av[])
2020
po::options_description desc("Allowed options");
2121
desc.add_options()
2222
("help", "produce help message")
23-
("compression", po::value<int>(), "set compression level")
23+
("compression", po::value<double>(), "set compression level")
2424
;
2525

2626
po::variables_map vm;
@@ -29,12 +29,12 @@ int main(int ac, char* av[])
2929

3030
if (vm.count("help")) {
3131
cout << desc << "\n";
32-
return 1;
32+
return 0;
3333
}
3434

3535
if (vm.count("compression")) {
3636
cout << "Compression level was set to "
37-
<< vm["compression"].as<int>() << ".\n";
37+
<< vm["compression"].as<double>() << ".\n";
3838
} else {
3939
cout << "Compression level was not set.\n";
4040
}

example/multiple_sources.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace std;
1818
template<class T>
1919
ostream& operator<<(ostream& os, const vector<T>& v)
2020
{
21-
copy(v.begin(), v.end(), ostream_iterator<T>(cout, " "));
21+
copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
2222
return os;
2323
}
2424

example/options_description.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace std;
1818
template<class T>
1919
ostream& operator<<(ostream& os, const vector<T>& v)
2020
{
21-
copy(v.begin(), v.end(), ostream_iterator<T>(cout, " "));
21+
copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
2222
return os;
2323
}
2424

include/boost/program_options/detail/cmdline.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ namespace boost { namespace program_options { namespace detail {
8181
cmdline(int argc, const char*const * argv);
8282

8383
void style(int style);
84+
85+
/** returns the canonical option prefix associated with the command_line_style
86+
* In order of precedence:
87+
* allow_long : allow_long
88+
* allow_long_disguise : allow_long_disguise
89+
* allow_dash_for_short : allow_short | allow_dash_for_short
90+
* allow_slash_for_short: allow_short | allow_slash_for_short
91+
*
92+
* This is mainly used for the diagnostic messages in exceptions
93+
*/
94+
int get_canonical_option_prefix();
95+
8496
void allow_unregistered();
8597

8698
void set_options_description(const options_description& desc);

include/boost/program_options/detail/parsers.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ namespace boost { namespace program_options {
100100
basic_parsed_options<charT>
101101
basic_command_line_parser<charT>::run()
102102
{
103-
parsed_options result(m_desc);
103+
// save the canonical prefixes which were used by this cmdline parser
104+
// eventually inside the parsed results
105+
// This will be handy to format recognisable options
106+
// for diagnostic messages if everything blows up much later on
107+
parsed_options result(m_desc, detail::cmdline::get_canonical_option_prefix());
104108
result.options = detail::cmdline::run();
105109

106110
// Presense of parsed_options -> wparsed_options conversion

0 commit comments

Comments
 (0)