Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82805 - in trunk: boost/program_options libs/program_options/test
From: ghost_at_[hidden]
Date: 2013-02-10 07:07:06


Author: vladimir_prus
Date: 2013-02-10 07:07:05 EST (Sun, 10 Feb 2013)
New Revision: 82805
URL: http://svn.boost.org/trac/boost/changeset/82805

Log:
Fix report of error for options with dashes.

Fixes #8009.
Patch from Markus Roth.

Text files modified:
   trunk/boost/program_options/errors.hpp | 3 ++-
   trunk/libs/program_options/test/exception_txt_test.cpp | 2 +-
   2 files changed, 3 insertions(+), 2 deletions(-)

Modified: trunk/boost/program_options/errors.hpp
==============================================================================
--- trunk/boost/program_options/errors.hpp (original)
+++ trunk/boost/program_options/errors.hpp 2013-02-10 07:07:05 EST (Sun, 10 Feb 2013)
@@ -25,7 +25,8 @@
 
     inline std::string strip_prefixes(const std::string& text)
     {
- return text.substr(text.find_last_of("-/") + 1);
+ // "--foo-bar" -> "foo-bar"
+ return text.substr(text.find_first_not_of("-/"));
     }
 
     /** Base class for all errors in the library. */

Modified: trunk/libs/program_options/test/exception_txt_test.cpp
==============================================================================
--- trunk/libs/program_options/test/exception_txt_test.cpp (original)
+++ trunk/libs/program_options/test/exception_txt_test.cpp 2013-02-10 07:07:05 EST (Sun, 10 Feb 2013)
@@ -160,7 +160,7 @@
     const char* argv1[] = { "program", "--int", "A_STRING"}; VEC_STR_PUSH_BACK(argv, argv1);
     const char* argv2[] = { "program", "-d", "A_STRING"} ; VEC_STR_PUSH_BACK(argv, argv2);
     const char* argv3[] = { "program", "/d", "A_STRING"} ; VEC_STR_PUSH_BACK(argv, argv3);
- const char* argv4[] = { "int_option=A_STRING"} ; VEC_STR_PUSH_BACK(argv, argv4);
+ const char* argv4[] = { "int-option=A_STRING"} ; VEC_STR_PUSH_BACK(argv, argv4);
 
     const char* expected_msg[5] = {
                                 "the argument ('A_STRING') for option '--int-option' is invalid",


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk