From fdc48261e5d2fa13a3a8e8a38a14a7aa6f6fa165 Mon Sep 17 00:00:00 2001 From: rhorenov Date: Sat, 10 Oct 2015 12:57:00 +0200 Subject: [PATCH 1/2] Fixes parsing of [default: x] in some cases on Win. If the option definition spans over multiple lines, then parsing of the [default: x] was not working on Windows - tested on MS Visual Studio 2015. This is due to the differences in regex's multiline property implementation. On some platforms - Linux libstd++ the multiline property is off, on some platforms - msvc2015 the multiline property is on. It cannot be changed programmatically AFAIK. I was not able to come up with a regex expression which would work on Linux and on Windows as well. So I tried to be smart and replace '\n' by '\f' in the string beforehand. The regex was easy and worked on Linux and Windows just fine - up until I tried a longer option definition. Then the msvc2015 regex failed with 'stack' exception. Hence this change. It splits the option definition section by a simple regex which does not use the problematic '$'. modified: docopt.cpp modified: docopt_util.h --- docopt.cpp | 28 ++++++++++------------------ docopt_util.h | 12 ++++++++++++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/docopt.cpp b/docopt.cpp index 2aed8a4..03d8719 100644 --- a/docopt.cpp +++ b/docopt.cpp @@ -908,32 +908,24 @@ PatternList parse_argv(Tokens tokens, std::vector