diff --git a/build/Jamfile.v2 b/build/Jamfile.v2
index 4d43ee0..e7af5f1 100644
--- a/build/Jamfile.v2
+++ b/build/Jamfile.v2
@@ -12,6 +12,8 @@ SOURCES =
lib boost_program_options
: $(SOURCES).cpp
: shared:BOOST_PROGRAM_OPTIONS_DYN_LINK=1 # tell source we're building dll's
+ # See https://svn.boost.org/trac/boost/ticket/5049
+ hpux,gcc:_INCLUDE_STDC__SOURCE_199901
:
: shared:BOOST_PROGRAM_OPTIONS_DYN_LINK=1
;
diff --git a/doc/overview.xml b/doc/overview.xml
index 09af655..dcfbaf4 100644
--- a/doc/overview.xml
+++ b/doc/overview.xml
@@ -181,7 +181,7 @@ options_description desc;
desc.add_options()
("help", "produce help message")
("compression", value<string>(), "compression level")
- ("verbose", value<string>()->zero_tokens(), "verbosity level")
+ ("verbose", value<string>()->implicit_value("0"), "verbosity level")
("email", value<string>()->multitoken(), "email to send to")
;
diff --git a/example/first.cpp b/example/first.cpp
index 7f9ab57..8763fec 100644
--- a/example/first.cpp
+++ b/example/first.cpp
@@ -20,7 +20,7 @@ int main(int ac, char* av[])
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
- ("compression", po::value(), "set compression level")
+ ("compression", po::value(), "set compression level")
;
po::variables_map vm;
@@ -29,12 +29,12 @@ int main(int ac, char* av[])
if (vm.count("help")) {
cout << desc << "\n";
- return 1;
+ return 0;
}
if (vm.count("compression")) {
cout << "Compression level was set to "
- << vm["compression"].as() << ".\n";
+ << vm["compression"].as() << ".\n";
} else {
cout << "Compression level was not set.\n";
}
diff --git a/example/multiple_sources.cpp b/example/multiple_sources.cpp
index 1daef45..22c8235 100644
--- a/example/multiple_sources.cpp
+++ b/example/multiple_sources.cpp
@@ -18,7 +18,7 @@ using namespace std;
template
ostream& operator<<(ostream& os, const vector& v)
{
- copy(v.begin(), v.end(), ostream_iterator(cout, " "));
+ copy(v.begin(), v.end(), ostream_iterator(os, " "));
return os;
}
diff --git a/example/options_description.cpp b/example/options_description.cpp
index f1bf8ed..d7ef4ce 100644
--- a/example/options_description.cpp
+++ b/example/options_description.cpp
@@ -18,7 +18,7 @@ using namespace std;
template
ostream& operator<<(ostream& os, const vector& v)
{
- copy(v.begin(), v.end(), ostream_iterator(cout, " "));
+ copy(v.begin(), v.end(), ostream_iterator(os, " "));
return os;
}
diff --git a/include/boost/program_options/detail/cmdline.hpp b/include/boost/program_options/detail/cmdline.hpp
index 7c43152..8e3bcc6 100644
--- a/include/boost/program_options/detail/cmdline.hpp
+++ b/include/boost/program_options/detail/cmdline.hpp
@@ -81,6 +81,18 @@ namespace boost { namespace program_options { namespace detail {
cmdline(int argc, const char*const * argv);
void style(int style);
+
+ /** returns the canonical option prefix associated with the command_line_style
+ * In order of precedence:
+ * allow_long : allow_long
+ * allow_long_disguise : allow_long_disguise
+ * allow_dash_for_short : allow_short | allow_dash_for_short
+ * allow_slash_for_short: allow_short | allow_slash_for_short
+ *
+ * This is mainly used for the diagnostic messages in exceptions
+ */
+ int get_canonical_option_prefix();
+
void allow_unregistered();
void set_options_description(const options_description& desc);
diff --git a/include/boost/program_options/detail/parsers.hpp b/include/boost/program_options/detail/parsers.hpp
index a1124b2..af240c6 100644
--- a/include/boost/program_options/detail/parsers.hpp
+++ b/include/boost/program_options/detail/parsers.hpp
@@ -100,7 +100,11 @@ namespace boost { namespace program_options {
basic_parsed_options
basic_command_line_parser::run()
{
- parsed_options result(m_desc);
+ // save the canonical prefixes which were used by this cmdline parser
+ // eventually inside the parsed results
+ // This will be handy to format recognisable options
+ // for diagnostic messages if everything blows up much later on
+ parsed_options result(m_desc, detail::cmdline::get_canonical_option_prefix());
result.options = detail::cmdline::run();
// Presense of parsed_options -> wparsed_options conversion
diff --git a/include/boost/program_options/errors.hpp b/include/boost/program_options/errors.hpp
index ff6bc7f..d6dcf39 100644
--- a/include/boost/program_options/errors.hpp
+++ b/include/boost/program_options/errors.hpp
@@ -12,6 +12,8 @@
#include
#include
#include
+#include