mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
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:
parent
87ca6fbbeb
commit
05347e4101
@ -446,10 +446,10 @@ void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info)
|
|||||||
|
|
||||||
ifstream ifs(file.c_str());
|
ifstream ifs(file.c_str());
|
||||||
string token;
|
string token;
|
||||||
regex reg1("\\\\citation\\{([^}]+)\\}");
|
static regex const reg1("\\\\citation\\{([^}]+)\\}");
|
||||||
regex reg2("\\\\bibdata\\{([^}]+)\\}");
|
static regex const reg2("\\\\bibdata\\{([^}]+)\\}");
|
||||||
regex reg3("\\\\bibstyle\\{([^}]+)\\}");
|
static regex const reg3("\\\\bibstyle\\{([^}]+)\\}");
|
||||||
regex reg4("\\\\@input\\{([^}]+)\\}");
|
static regex const reg4("\\\\@input\\{([^}]+)\\}");
|
||||||
|
|
||||||
while (getline(ifs, token)) {
|
while (getline(ifs, token)) {
|
||||||
token = rtrim(token, "\r");
|
token = rtrim(token, "\r");
|
||||||
|
@ -200,17 +200,23 @@ int FileDialog::Private::minh_ = 0;
|
|||||||
|
|
||||||
namespace {
|
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
|
// We massage the pattern a bit so that the usual
|
||||||
// shell pattern we all are used to will work.
|
// shell pattern we all are used to will work.
|
||||||
// One nice thing about using a real regex is that
|
// One nice thing about using a real regex is that
|
||||||
// things like "*.*[^~]" will work also.
|
// things like "*.*[^~]" will work also.
|
||||||
// build the regex string.
|
// build the regex string.
|
||||||
string regex = subst(pattern, ".", "\\.");
|
string pattern = subst(pat, ".", "\\.");
|
||||||
regex = subst(regex, "*", ".*");
|
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);
|
return boost::regex_match(a, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,6 +263,8 @@ void FileDialog::Private::Reread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parses all entries of the given subdirectory
|
// Parses all entries of the given subdirectory
|
||||||
|
boost::regex reg = getRegex(mask_);
|
||||||
|
|
||||||
time_t curTime = time(0);
|
time_t curTime = time(0);
|
||||||
rewinddir(dir);
|
rewinddir(dir);
|
||||||
while (dirent * entry = readdir(dir)) {
|
while (dirent * entry = readdir(dir)) {
|
||||||
@ -340,7 +348,7 @@ void FileDialog::Private::Reread()
|
|||||||
|| fileInfo.isChar()
|
|| fileInfo.isChar()
|
||||||
|| fileInfo.isBlock()
|
|| fileInfo.isBlock()
|
||||||
|| fileInfo.isFifo()) {
|
|| fileInfo.isFifo()) {
|
||||||
if (!globMatch(fname, mask_))
|
if (!globMatch(fname, reg))
|
||||||
continue;
|
continue;
|
||||||
} else if (!(isDir = fileInfo.isDir()))
|
} else if (!(isDir = fileInfo.isDir()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -258,7 +258,7 @@ string const sanitizeLatexOption(string const & input)
|
|||||||
// "[,,,,foo..." -> "foo..."
|
// "[,,,,foo..." -> "foo..."
|
||||||
string output;
|
string output;
|
||||||
boost::smatch what;
|
boost::smatch what;
|
||||||
boost::regex const front("^( *[[],*)(.*)$");
|
static boost::regex const front("^( *[[],*)(.*)$");
|
||||||
|
|
||||||
regex_match(it, end, what, front, boost::match_partial);
|
regex_match(it, end, what, front, boost::match_partial);
|
||||||
if (!what[0].matched) {
|
if (!what[0].matched) {
|
||||||
@ -271,7 +271,7 @@ string const sanitizeLatexOption(string const & input)
|
|||||||
// Replace any consecutive commas with a single one
|
// Replace any consecutive commas with a single one
|
||||||
// "foo,,,,bar" -> "foo,bar"
|
// "foo,,,,bar" -> "foo,bar"
|
||||||
// with iterator now pointing to 'b'
|
// with iterator now pointing to 'b'
|
||||||
boost::regex const commas("([^,]*)(,,*)(.*)$");
|
static boost::regex const commas("([^,]*)(,,*)(.*)$");
|
||||||
for (; it != end;) {
|
for (; it != end;) {
|
||||||
regex_match(it, end, what, commas, boost::match_partial);
|
regex_match(it, end, what, commas, boost::match_partial);
|
||||||
if (!what[0].matched) {
|
if (!what[0].matched) {
|
||||||
@ -284,7 +284,7 @@ string const sanitizeLatexOption(string const & input)
|
|||||||
|
|
||||||
// Strip any trailing commas
|
// Strip any trailing commas
|
||||||
// "...foo,,,]" -> "...foo"
|
// "...foo,,,]" -> "...foo"
|
||||||
boost::regex const back("^(.*[^,])(,*[]] *)$");
|
static boost::regex const back("^(.*[^,])(,*[]] *)$");
|
||||||
regex_match(output, what, back);
|
regex_match(output, what, back);
|
||||||
if (!what[0].matched) {
|
if (!what[0].matched) {
|
||||||
lyxerr << "Unable to sanitize LaTeX \"Option\": "
|
lyxerr << "Unable to sanitize LaTeX \"Option\": "
|
||||||
|
@ -264,7 +264,7 @@ void CVS::scanMaster()
|
|||||||
string tmpf = "/" + OnlyFilename(file_) + "/";
|
string tmpf = "/" + OnlyFilename(file_) + "/";
|
||||||
lyxerr[Debug::LYXVC] << "\tlooking for `" << tmpf << '\'' << endl;
|
lyxerr[Debug::LYXVC] << "\tlooking for `" << tmpf << '\'' << endl;
|
||||||
string line;
|
string line;
|
||||||
regex reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
|
static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
|
||||||
while (getline(ifs, line)) {
|
while (getline(ifs, line)) {
|
||||||
lyxerr[Debug::LYXVC] << "\t line: " << line << endl;
|
lyxerr[Debug::LYXVC] << "\t line: " << line << endl;
|
||||||
if (contains(line, tmpf)) {
|
if (contains(line, tmpf)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user