make some more regexs static

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7932 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-10-17 18:23:41 +00:00
parent 87ca6fbbeb
commit 05347e4101
4 changed files with 21 additions and 13 deletions

View 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");

View 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;

View 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\": "

View 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)) {