Skip to content

Commit b430a83

Browse files
committed
Fix report of error for options with dashes.
Fixes #8009. Patch from Markus Roth. [SVN r82805]
1 parent 96b365c commit b430a83

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

include/boost/program_options/errors.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ namespace boost { namespace program_options {
2525

2626
inline std::string strip_prefixes(const std::string& text)
2727
{
28-
return text.substr(text.find_last_of("-/") + 1);
28+
// "--foo-bar" -> "foo-bar"
29+
return text.substr(text.find_first_not_of("-/"));
2930
}
3031

3132
/** Base class for all errors in the library. */

test/exception_txt_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void test_invalid_option_value_exception_msg()
160160
const char* argv1[] = { "program", "--int", "A_STRING"}; VEC_STR_PUSH_BACK(argv, argv1);
161161
const char* argv2[] = { "program", "-d", "A_STRING"} ; VEC_STR_PUSH_BACK(argv, argv2);
162162
const char* argv3[] = { "program", "/d", "A_STRING"} ; VEC_STR_PUSH_BACK(argv, argv3);
163-
const char* argv4[] = { "int_option=A_STRING"} ; VEC_STR_PUSH_BACK(argv, argv4);
163+
const char* argv4[] = { "int-option=A_STRING"} ; VEC_STR_PUSH_BACK(argv, argv4);
164164

165165
const char* expected_msg[5] = {
166166
"the argument ('A_STRING') for option '--int-option' is invalid",

0 commit comments

Comments
 (0)