From: Lars Gullik Bjønnes Date: Fri, 17 Oct 2003 18:23:41 +0000 (+0000) Subject: make some more regexs static X-Git-Tag: 1.6.10~15934 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=05347e410191c930106a14d4ae9039ffaf28a7c4;p=lyx.git make some more regexs static git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7932 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LaTeX.C b/src/LaTeX.C index 7623aa3acf..4230c72c00 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -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"); diff --git a/src/frontends/xforms/FormFiledialog.C b/src/frontends/xforms/FormFiledialog.C index c862140df7..3d9d5b05c4 100644 --- a/src/frontends/xforms/FormFiledialog.C +++ b/src/frontends/xforms/FormFiledialog.C @@ -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; diff --git a/src/insets/ExternalTransforms.C b/src/insets/ExternalTransforms.C index 79f2d16ebb..9d77c37d2e 100644 --- a/src/insets/ExternalTransforms.C +++ b/src/insets/ExternalTransforms.C @@ -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\": " diff --git a/src/vc-backend.C b/src/vc-backend.C index 4d72221526..414c8e4d9f 100644 --- a/src/vc-backend.C +++ b/src/vc-backend.C @@ -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)) {