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");
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);
}
}
// Parses all entries of the given subdirectory
+ boost::regex reg = getRegex(mask_);
+
time_t curTime = time(0);
rewinddir(dir);
while (dirent * entry = readdir(dir)) {
|| fileInfo.isChar()
|| fileInfo.isBlock()
|| fileInfo.isFifo()) {
- if (!globMatch(fname, mask_))
+ if (!globMatch(fname, reg))
continue;
} else if (!(isDir = fileInfo.isDir()))
continue;
// "[,,,,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) {
// 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) {
// 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\": "
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)) {