From 99e3eeca9f4456341877bc762157f303388af204 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 8 Sep 2018 16:33:21 +0200 Subject: [PATCH] Library: formatting of simplified types adjusted Need to be more careful when eating trailing spaces after a std::string. Because the full-blown type is a template, sometimes the compiler adds a spurious additional space behind the closing angle bracket, due to the now obsolete "maximum munch rule" of C++98 -- to prevent closing angle brackets to become '>>'. But in other cases, some type adornments or other language identifiers follow the string type, like e.g. 'const'. In those cases, the trailing space must be retained. We solve this by a look-ahead assertion in the regular expression: consume the trailing space _only_ if a non-word character follows (like '>'). --- src/lib/format-obj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/format-obj.cpp b/src/lib/format-obj.cpp index f2cdc0216..9de89b7d4 100644 --- a/src/lib/format-obj.cpp +++ b/src/lib/format-obj.cpp @@ -205,7 +205,7 @@ apologies for that." "|lumiera::" , regex::ECMAScript | regex::optimize}; - static regex stdString {"(__cxx11::)?basic_string, allocator\\s*>\\s*" + static regex stdString {"(__cxx11::)?basic_string, allocator\\s*>(\\s+\\B)?" , regex::ECMAScript | regex::optimize}; static regex stdAllocator {"(\\w+<(" TYP_EXP ")), allocator<\\2>\\s*"