[Libreoffice-commits] core.git: compilerplugins/clang

Miklos Vajna vmiklos at collabora.co.uk
Mon Dec 21 08:31:32 PST 2015


 compilerplugins/clang/getimplementationname.cxx |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

New commits:
commit 29aec38789fa180964ce9f023c0c6808656591b5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Dec 21 17:30:27 2015 +0100

    compilerplugins: avoid std::regex_replace
    
    My clang 3.7 built against libstdc++ 5.2.1 doesn't seem to have it. We
    can get away with a non-regex replace all here, though.
    
    Change-Id: Iea36311d89acb434c4e4f7c1f9ce876a6ee84f42

diff --git a/compilerplugins/clang/getimplementationname.cxx b/compilerplugins/clang/getimplementationname.cxx
index a73a757..b918dc6 100644
--- a/compilerplugins/clang/getimplementationname.cxx
+++ b/compilerplugins/clang/getimplementationname.cxx
@@ -60,6 +60,19 @@ bool overridesXServiceInfo(clang::CXXMethodDecl const * decl) {
     return false;
 }
 
+std::string replace_all(std::string subject, const std::string& search, const std::string& replace)
+{
+    size_t pos = 0;
+
+    while ((pos = subject.find(search, pos)) != std::string::npos)
+    {
+        subject.replace(pos, search.length(), replace);
+        pos += replace.length();
+    }
+
+    return subject;
+}
+
 class GetImplementationName:
     public clang::RecursiveASTVisitor<GetImplementationName>,
     public loplugin::Plugin
@@ -263,8 +276,8 @@ void GetImplementationName::generateOutput(FunctionDecl const * decl, const std:
     if(modulematch.empty())
         return;
     const std::string module(modulematch[0]);
-    const std::regex doublecolonregex("::");
-    const std::string cppclassweb(std::regex_replace(cppclass, doublecolonregex, "_1_1"));
+    const std::string doublecolonregex("::");
+    const std::string cppclassweb(replace_all(cppclass, doublecolonregex, "_1_1"));
     std::ofstream redirectfile(m_Outdir + "/" + unoimpl + ".html");
     redirectfile << "<meta http-equiv=\"refresh\" content=\"0; URL=http://docs.libreoffice.org/" << module << "/html/class" << cppclassweb << "\">\n";
     redirectfile.close();


More information about the Libreoffice-commits mailing list