]> git.lyx.org Git - features.git/commitdiff
Rewrite regexes in ECMAScript style (bug #9799)
authorGuillaume Munch <gm@lyx.org>
Mon, 16 Nov 2015 22:40:52 +0000 (22:40 +0000)
committerGuillaume Munch <gm@lyx.org>
Wed, 18 Nov 2015 01:52:50 +0000 (01:52 +0000)
src/frontends/qt4/GuiCitation.cpp
src/frontends/tests/biblio.cpp
src/insets/ExternalTransforms.cpp

index 052d700b2b0a7f8c6f3b100206c3603d4bf78cee..dc41fbdc871828da61c9eacc865e490ddb2cdc0d 100644 (file)
@@ -665,12 +665,10 @@ void GuiCitation::filterByEntryType(BiblioInfo const & bi,
 static docstring escape_special_chars(docstring 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.
-       static const lyx::regex reg("[].|*?+(){}^$\\[\\\\]");
+       // Note that '[', ']', and '\' must be escaped.
+       static const lyx::regex reg("[.|*?+(){}^$\\[\\]\\\\]");
 
-       // $& is a perl-like expression that expands to all
+       // $& is an 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.
index 933c87ae058205355bc3f0279690ac3af008c5b8..5a7a376d3e40a33086b9eb07cee86a7cb456eff2 100644 (file)
@@ -15,12 +15,10 @@ using namespace std;
 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.
+       lyx::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.
index f8ce18d3ec09fd0c53e573a967859e35af7c6c8e..a3bf82df65a08b612cf191233526a57e2c711e22 100644 (file)
@@ -283,7 +283,7 @@ string const sanitizeLatexOption(string const & input)
        // "[,,,,foo..." -> "foo..." ("foo..." may be empty)
        string output;
        lyx::smatch what;
-       static lyx::regex const front("^( *[[],*)(.*)$");
+       static lyx::regex const front("^( *\\[,*)(.*)$");
 
        regex_match(it, end, what, front);
        if (!what[0].matched) {
@@ -309,7 +309,7 @@ string const sanitizeLatexOption(string const & input)
 
        // Strip any trailing commas
        // "...foo,,,]" -> "...foo" ("...foo,,," may be empty)
-       static lyx::regex const back("^(.*[^,])?,*[]] *$");
+       static lyx::regex const back("^(.*[^,])?,*\\] *$");
        regex_match(output, what, back);
        if (!what[0].matched) {
                lyxerr << "Unable to sanitize LaTeX \"Option\": "