]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/tests/biblio.cpp
Revert "Amend 3093789e for cmake build"
[lyx.git] / src / frontends / tests / biblio.cpp
index 933c87ae058205355bc3f0279690ac3af008c5b8..9fa7c237df84a76ef3732119b950ff05c17d3d0e 100644 (file)
@@ -2,30 +2,26 @@
 
 #include <iostream>
 #include <map>
-
-#include "support/regex.h"
+#include <regex>
 
 using namespace std;
 
 // Escape special chars.
 // All characters are literals except: '.|*?+(){}[]^$\'
 // These characters are literals when preceded by a "\", which is done here
-// This function is unfortunately copied from ../qt4/GuiCitation.cpp, so we
+// This function is unfortunately copied from ../qt/GuiCitation.cpp, so we
 // should try to make sure to keep the two in sync.
 string const escape_special_chars(string const & expr)
 {
        // Search for all chars '.|*?+(){}[^$]\'
-       // Note that '[' and '\' must be escaped.
-       // This is a limitation of lyx::regex, but all other chars in BREs
-       // are assumed literal.
-       lyx::regex reg("[].|*?+(){}^$\\[\\\\]");
+       // Note that '[', ']', and '\' must be escaped.
+       regex reg("[.|*?+(){}^$\\[\\]\\\\]");
 
-       // $& is a perl-like expression that expands to all
+       // $& is a ECMAScript format expression that expands to all
        // of the current match
-       // The '$' must be prefixed with the escape character '\' for
-       // boost to treat it as a literal.
-       // Thus, to prefix a matched expression with '\', we use:
-       return lyx::regex_replace(expr, reg, "\\\\$&");
+       // To prefix a matched expression with a single literal backslash, we
+       // need to escape it for the C++ compiler and use:
+       return regex_replace(expr, reg, "\\$&");
 }
 
 
@@ -35,7 +31,7 @@ typedef map<string, string> InfoMap;
 // data entry matches the required regex_
 // This class is unfortunately copied from ../frontend_helpers.cpp, so we should
 // try to make sure to keep the two in sync.
-class RegexMatch : public unary_function<string, bool>
+class RegexMatch
 {
 public:
        // re is used to construct an instance of lyx::regex.
@@ -52,11 +48,11 @@ public:
 
                // Attempts to find a match for the current RE
                // somewhere in data.
-               return lyx::regex_search(data, regex_);
+               return regex_search(data, regex_);
        }
 private:
        InfoMap const map_;
-       mutable lyx::regex regex_;
+       mutable regex regex_;
 };
 
 
@@ -80,7 +76,7 @@ void test_RegexMatch()
                cout << rm("hello") << endl;
                cout << rm("hei") << endl;
        }
-       catch (lyx::regex_error & regerr) {
+       catch (regex_error & regerr) {
                cout << regerr.what() << endl;
        }
 }