regex About REGEX_MULTILINE and CXX11_REGEX in Document.cxx
When you build scintilla with gcc 12.1 or llvm 14,
using -DREGEX_MULTILINE
But "^" and "$" doesn't work as expected.
So you will add some code in Sci::Position Cxx11RegexFindText()
if (!caseSensitive)
flagsRe = flagsRe | std::regex::icase;
#ifdef REGEX_MULTILINE
flagsRe = flagsRe | std::regex::multiline;
#endif
// Clear the RESearch so can fill in matches
search.Clear();
Now it work.
Replacement with regular expressions allow \1..9
But "$&", "$`", "$'" and "$1..." doesn't work.
May be something would be done in const BuiltinRegex::SubstituteByPosition() ...
MSVC 2022 still doesn't define
std::regex::multiline:Using the preprocessor to avoid the Visual C++ compiler like following causes problems when using Clang for Windows which uses the Microsoft runtime:
Couldn't find a way to detect the Microsoft C++ headers but it may be possible to detect the libc++ and libstdc++ headers. Another possibility may be some C++ trickery to discover if
std::regex::multilineis defined.The "$" based captures wouldn't be compatible with the builtin regex and current behaviour. "$`" and "$'" would be referring to the document text before / after the match which doesn't sound very useful. You probably want the contents of the line before / after the match but the code isn't really oriented towards that.
This should really be a separate issue so that one or the other part can be implemented without leaving behind an partly completed issue.
clang for MSVC target (clang-cl.exe or
--target=x86_64-pc-windows-msvc) defined_MSC_VER(so does Intel C++ compiler for Visual Studio).clang for mingw target (e.g.
--target=x86_64-w64-windows-gnu) doesn't define_MSC_VER.With https://nuwen.net/mingw.html g++ 11.2.0 and
#if defined(REGEX_MULTILINE) && !defined(_MSC_VER)I see:From https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/ChangeLog-2021#L2619 and https://gcc.gnu.org/releases.html
multilineoption requires gcc 11.3 or later, gcc 12.1 can be installed with pacman comes with msys2 or git-for-windows.Committed with [562afc].
Earlier gcc and clang releases failing on
regex::multilinecan be treated as informative and means thatREGEX_MULTILINEshould not be turned on.Related
Commit: [562afc]