]> git.lyx.org Git - lyx.git/commitdiff
make some more regexs static
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 17 Oct 2003 18:23:41 +0000 (18:23 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 17 Oct 2003 18:23:41 +0000 (18:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7932 a592a061-630c-0410-9148-cb99ea01b6c8

src/LaTeX.C
src/frontends/xforms/FormFiledialog.C
src/insets/ExternalTransforms.C
src/vc-backend.C

index 7623aa3acfff738ffd18a6c30dd51219d432ed63..4230c72c00274e007ee8f99052daaf6ae4cb8902 100644 (file)
@@ -446,10 +446,10 @@ void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info)
 
        ifstream ifs(file.c_str());
        string token;
-       regex reg1("\\\\citation\\{([^}]+)\\}");
-       regex reg2("\\\\bibdata\\{([^}]+)\\}");
-       regex reg3("\\\\bibstyle\\{([^}]+)\\}");
-       regex reg4("\\\\@input\\{([^}]+)\\}");
+       static regex const reg1("\\\\citation\\{([^}]+)\\}");
+       static regex const reg2("\\\\bibdata\\{([^}]+)\\}");
+       static regex const reg3("\\\\bibstyle\\{([^}]+)\\}");
+       static regex const reg4("\\\\@input\\{([^}]+)\\}");
 
        while (getline(ifs, token)) {
                token = rtrim(token, "\r");
index c862140df7968888053beb8992e29283fb8bf1f0..3d9d5b05c4c0d608a058e826fb99f0790237c248 100644 (file)
@@ -200,17 +200,23 @@ int FileDialog::Private::minh_ = 0;
 
 namespace {
 
-bool globMatch(string const & a, string const & pattern)
+boost::regex getRegex(string const & pat)
 {
        // We massage the pattern a bit so that the usual
        // shell pattern we all are used to will work.
        // One nice thing about using a real regex is that
        // things like "*.*[^~]" will work also.
        // build the regex string.
-       string regex = subst(pattern, ".", "\\.");
-       regex = subst(regex, "*", ".*");
+       string pattern = subst(pat, ".", "\\.");
+       pattern = subst(pattern, "*", ".*");
 
-       boost::regex reg(regex);
+       boost::regex reg(pattern);
+       return reg;
+}
+
+
+bool globMatch(string const & a, boost::regex const & reg)
+{
        return boost::regex_match(a, reg);
 }
 
@@ -257,6 +263,8 @@ void FileDialog::Private::Reread()
        }
 
        // Parses all entries of the given subdirectory
+       boost::regex reg = getRegex(mask_);
+
        time_t curTime = time(0);
        rewinddir(dir);
        while (dirent * entry = readdir(dir)) {
@@ -340,7 +348,7 @@ void FileDialog::Private::Reread()
                    || fileInfo.isChar()
                    || fileInfo.isBlock()
                    || fileInfo.isFifo()) {
-                       if (!globMatch(fname, mask_))
+                       if (!globMatch(fname, reg))
                                continue;
                } else if (!(isDir = fileInfo.isDir()))
                        continue;
index 79f2d16ebb5fda80d627d8f9327159eb805b3ffd..9d77c37d2ee598dbafa96da9c7fac7220186b3ab 100644 (file)
@@ -258,7 +258,7 @@ string const sanitizeLatexOption(string const & input)
        // "[,,,,foo..." -> "foo..."
        string output;
        boost::smatch what;
-       boost::regex const front("^( *[[],*)(.*)$");
+       static boost::regex const front("^( *[[],*)(.*)$");
 
        regex_match(it, end, what, front, boost::match_partial);
        if (!what[0].matched) {
@@ -271,7 +271,7 @@ string const sanitizeLatexOption(string const & input)
        // Replace any consecutive commas with a single one
        // "foo,,,,bar" -> "foo,bar"
        // with iterator now pointing to 'b'
-       boost::regex const commas("([^,]*)(,,*)(.*)$");
+       static boost::regex const commas("([^,]*)(,,*)(.*)$");
        for (; it != end;) {
                regex_match(it, end, what, commas, boost::match_partial);
                if (!what[0].matched) {
@@ -284,7 +284,7 @@ string const sanitizeLatexOption(string const & input)
 
        // Strip any trailing commas
        // "...foo,,,]" -> "...foo"
-       boost::regex const back("^(.*[^,])(,*[]] *)$");
+       static boost::regex const back("^(.*[^,])(,*[]] *)$");
        regex_match(output, what, back);
        if (!what[0].matched) {
                lyxerr << "Unable to sanitize LaTeX \"Option\": "
index 4d7222152662a3e8152a9c9fd3d9bca911421bed..414c8e4d9f27999afd24d80ace91dfef3116df33 100644 (file)
@@ -264,7 +264,7 @@ void CVS::scanMaster()
        string tmpf = "/" + OnlyFilename(file_) + "/";
        lyxerr[Debug::LYXVC] << "\tlooking for `" << tmpf << '\'' << endl;
        string line;
-       regex reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
+       static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
        while (getline(ifs, line)) {
                lyxerr[Debug::LYXVC] << "\t  line: " << line << endl;
                if (contains(line, tmpf)) {