From c6253f4e9f50cce8fa438e4103160e02e34276fc Mon Sep 17 00:00:00 2001 From: rhorenov Date: Sat, 10 Oct 2015 12:36:10 +0200 Subject: [PATCH] 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 ] Options: --so-long-option-that-the-description-is-on-a-new-line Something very important [default: 43] modified: docopt.cpp --- docopt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docopt.cpp b/docopt.cpp index 2aed8a4..5aff3c6 100644 --- a/docopt.cpp +++ b/docopt.cpp @@ -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;