Skip to content
This repository has been archived by the owner on Jul 18, 2018. It is now read-only.

Commit

Permalink
Fix report of error for options with dashes.
Browse files Browse the repository at this point in the history
Fixes #8009.
Patch from Markus Roth.


git-svn-id: http://svn.boost.org/svn/boost/trunk@82805 b8fc166d-592f-0410-95f2-cb63ce0dd405
  • Loading branch information
vladimir_prus committed Feb 10, 2013
1 parent 9004563 commit 63055b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion boost/program_options/errors.hpp
Expand Up @@ -25,7 +25,8 @@ namespace boost { namespace program_options {

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. */
Expand Down
2 changes: 1 addition & 1 deletion libs/program_options/test/exception_txt_test.cpp
Expand Up @@ -160,7 +160,7 @@ void test_invalid_option_value_exception_msg()
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",
Expand Down

0 comments on commit 63055b6

Please sign in to comment.