From 08317ecc0b56a5174270ec0fe0dc87cb4dea6a8e Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 22 Nov 2015 13:02:39 +0100 Subject: [PATCH] Fix some thinkos in MSVC regex hack The changed code is not used, but I tried to use a similar approach for boost::regex, and found some problems: - regex_replace and regex_search are implemented in the replacement, so they must not be used directly - an smatch object must be given by reference (as in the called methods), otherwise an exception would be thrown at runtime - the commented out regex_replace version is actually needed This code is supposed to be deleted, but nevertheless I wanted to record here how it had to be modified if it was actually needed. --- src/support/regex.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/support/regex.h b/src/support/regex.h index dd4875e35f..94140a53ea 100644 --- a/src/support/regex.h +++ b/src/support/regex.h @@ -17,7 +17,7 @@ # ifdef _MSC_VER namespace lyx { // inheriting 'private' to see which functions are used and if there are - // other ECMAScrip defaults + // other ECMAScript defaults // FIXME: Is this really needed? // If yes, then the MSVC regex implementation is not standard-conforming. class regex : private std::regex @@ -35,20 +35,20 @@ namespace lyx { }; template bool regex_match(T t, const regex& r) { return std::regex_match(t, r.toStd()); } + template + bool regex_match(T t, std::smatch& m, const regex& r) { return std::regex_match(t, m, r.toStd()); } template - bool regex_match(T t, V v, const regex& r) { return std::regex_match(t, v, r.toStd()); } - template - bool regex_match(T t, V v, H h, const regex& r, U u) { return std::regex_match(t, v, h, r.toStd(), u); } + bool regex_match(T t, V v, std::smatch& m, const regex& r) { return std::regex_match(t, v, m, r.toStd()); } template std::string regex_replace(T t, const regex& r, V v) { return std::regex_replace(t, r.toStd(), v); } - //template - //std::string regex_replace(T t, V v, U u, const regex& r, H h) { return std::regex_replace(t, v, u, r.toStd(), h); } + template + T regex_replace(T t, V v, U u, const regex& r, H h) { return std::regex_replace(t, v, u, r.toStd(), h); } template bool regex_search(T t, const regex& r) { return std::regex_search(t, r.toStd()); } + template + bool regex_search(T t, std::smatch& m, const regex& r) { return std::regex_search(t, m, r.toStd()); } template - bool regex_search(T t, V v, const regex& r) { return std::regex_search(t, v, r.toStd()); } - template - bool regex_search(T t, V v, U u, const regex& r) { return std::regex_search(t, v, u, r.toStd()); } + bool regex_search(T t, V v, std::smatch& m, const regex& r) { return std::regex_search(t, v, m, r.toStd()); } struct sregex_iterator : std::sregex_iterator { @@ -64,6 +64,8 @@ namespace lyx { namespace lyx { using LR_NS::regex; using LR_NS::regex_match; +using LR_NS::regex_replace; +using LR_NS::regex_search; using LR_NS::sregex_iterator; } # endif @@ -73,16 +75,16 @@ using LR_NS::sregex_iterator; namespace lyx { using LR_NS::regex; using LR_NS::regex_match; +using LR_NS::regex_replace; +using LR_NS::regex_search; using LR_NS::sregex_iterator; } #endif namespace lyx { using LR_NS::smatch; -using LR_NS::regex_replace; using LR_NS::basic_regex; using LR_NS::regex_error; -using LR_NS::regex_search; using LR_NS::match_results; namespace regex_constants