From 8c506d8611ea560d9137057867733005b0edc1bb Mon Sep 17 00:00:00 2001 From: Trent Tuggle Date: Wed, 1 May 2019 15:55:36 -0400 Subject: [PATCH 1/2] Fixes bug where usage parsing fails on multiple blank lines. --- docopt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docopt.cpp b/docopt.cpp index 937845d..be089e7 100644 --- a/docopt.cpp +++ b/docopt.cpp @@ -171,7 +171,7 @@ static std::vector parse_section(std::string const& name, std::stri "(?:^|\\n)" // anchored at a linebreak (or start of string) "(" "[^\\n]*" + name + "[^\\n]*(?=\\n?)" // a line that contains the name - "(?:\\n[ \\t].*?(?=\\n|$))*" // followed by any number of lines that are indented + "(?:\\n*[ \\t].*?(?=\\n|$))*" // followed by any number of blank lines, or lines that are indented ")", std::regex::icase }; From ea2be50245ba4c55c77777d76e894dc4ce0c8dee Mon Sep 17 00:00:00 2001 From: ttuggle Date: Mon, 27 Jul 2020 17:35:39 -0400 Subject: [PATCH 2/2] Added support for C++ libs that do not match EOL As explained in https://stackoverflow.com/questions/39645660/stdregex-to-match-begin-end-of-string this helps when running on c++ libraries that do not match EOL with $. --- docopt_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docopt_private.h b/docopt_private.h index 931986b..7f2834a 100644 --- a/docopt_private.h +++ b/docopt_private.h @@ -532,7 +532,7 @@ namespace docopt { options_end = option_description.begin() + static_cast(double_space); } - static const std::regex pattern {"(-{1,2})?(.*?)([,= ]|$)"}; + static const std::regex pattern {"(-{1,2})?(.*?)([,= ]|$|\n)"}; for(std::sregex_iterator i {option_description.begin(), options_end, pattern, std::regex_constants::match_not_null}, e{}; i != e;