Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix to allow a new line in the Option definition.
The problem manifests on platforms where '$' does not match new line.

According to:

  http://cplusplus.github.io/LWG/lwg-active.html#2343

some RegEx implementations e.g. GCC have multiline property
turned off so '$' does not match a new line character
and the Option parser fails to recognise an option's
parameter if it is present.

Example
=======

Usage:
    my_app [--so-long-option-that-the-description-is-on-a-new-line <param>]

Options:
    --so-long-option-that-the-description-is-on-a-new-line <param>
                         Something very important [default: 43]

	modified:   docopt.cpp
  • Loading branch information
rhorenov committed Oct 10, 2015
commit c6253f4e9f50cce8fa438e4103160e02e34276fc
2 changes: 1 addition & 1 deletion docopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Option Option::parse(std::string const& option_description)
options_end = option_description.begin() + double_space;
}

static const std::regex pattern {"(--|-)?(.*?)([,= ]|$)"};
static const std::regex pattern {"(--|-)?(.*?)([,= \\n]|$)"};
for(std::sregex_iterator i {option_description.begin(), options_end, pattern, std::regex_constants::match_not_null},
e{};
i != e;
Expand Down