2003-10-11  Lars Gullik Bj�nnes  <larsbj@gullik.net>

* LaTeX.C (deplog): move found file handlig from here...
(handleFoundFile): .. to new function here.
(deplog): make sure to discover several files mentioned on the
same log line.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7896 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-10-11 01:21:26 +00:00
parent 1c4ae33f9a
commit c57b67f24f
2 changed files with 97 additions and 74 deletions

View File

@ -1,3 +1,9 @@
2003-10-11 Lars Gullik Bjønnes <larsbj@gullik.net>
* LaTeX.C (deplog): move found file handlig from here...
(handleFoundFile): .. to new function here.
(deplog): make sure to discover several files mentioned on the
same log line.
2003-10-10 André Pönitz <poenitz@gmx.net>

View File

@ -46,6 +46,7 @@ using lyx::support::split;
using lyx::support::suffixIs;
using lyx::support::Systemcall;
using lyx::support::unlink;
using lyx::support::trim;
namespace os = lyx::support::os;
@ -86,7 +87,7 @@ string runMessage(unsigned int count)
return bformat(_("Waiting for LaTeX run number %1$s"), tostr(count));
}
};
} // anon namespace
/*
* CLASS TEXERRORS
@ -671,6 +672,71 @@ int LaTeX::scanLogFile(TeXErrors & terr)
}
namespace {
void handleFoundFile(string const & ff, DepTable & head)
{
static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
// convert from native os path to unix path
string const foundfile = os::internal_path(trim(ff));
string const onlyfile = OnlyFilename(foundfile);
lyxerr[Debug::DEPEND] << "Found file: " << foundfile << endl;
// Ok now we found a file.
// Now we should make sure that this is a file that we can
// access through the normal paths.
// We will not try any fancy search methods to
// find the file.
// (1) foundfile is an
// absolute path and should
// be inserted.
if (AbsolutePath(foundfile)) {
lyxerr[Debug::DEPEND] << "AbsolutePath file: "
<< foundfile << endl;
// On initial insert we want to do the update at once
// since this file can not be a file generated by
// the latex run.
if (FileInfo(foundfile).exist())
head.insert(foundfile, true);
}
// (2) foundfile is in the tmpdir
// insert it into head
else if (FileInfo(onlyfile).exist()) {
if (regex_match(foundfile, unwanted)) {
lyxerr[Debug::DEPEND]
<< "We don't want "
<< onlyfile
<< " in the dep file"
<< endl;
} else if (suffixIs(foundfile, ".tex")) {
// This is a tex file generated by LyX
// and latex is not likely to change this
// during its runs.
lyxerr[Debug::DEPEND]
<< "Tmpdir TeX file: "
<< onlyfile
<< endl;
head.insert(foundfile, true);
} else {
lyxerr[Debug::DEPEND]
<< "In tmpdir file:"
<< onlyfile
<< endl;
head.insert(onlyfile);
}
} else
lyxerr[Debug::DEPEND]
<< "Not a file or we are unable to find it."
<< endl;
}
} // anon namespace
void LaTeX::deplog(DepTable & head)
{
// This function reads the LaTeX log file end extracts all the external
@ -679,25 +745,25 @@ void LaTeX::deplog(DepTable & head)
string const logfile = OnlyFilename(ChangeExtension(file, ".log"));
regex reg1("\\)* *\\(([^ )]+).*");
regex reg2("File: ([^ ]+).*");
regex reg3("No file ([^ ]+)\\..*");
regex reg4("\\\\openout[0-9]+.*=.*`([^ ]+)'\\..*");
static regex reg1(".*\\([^)]+.*");
static regex reg2("File: ([^ ]+).*");
static regex reg3("No file ([^ ]+)\\..*");
static regex reg4("\\\\openout[0-9]+.*=.*`([^ ]+)'\\..*");
// If an index should be created, MikTex does not write a line like
// \openout# = 'sample,idx'.
// but intstead only a line like this into the log:
// Writing index file sample.idx
regex reg5("Writing index file ([^ ]+).*");
regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
static regex reg5("Writing index file ([^ ]+).*");
ifstream ifs(logfile.c_str());
while (ifs) {
// Ok, the scanning of files here is not sufficient.
// Sometimes files are named by "File: xxx" only
// So I think we should use some regexps to find files instead.
// "(\([^ ]+\)" should match the "(file " variant
// "(\([^ ]+\)" should match the "(file " variant, note
// that we can have several of these on one line.
// "File: \([^ ]+\)" should match the "File: file" variant
string foundfile;
string token;
getline(ifs, token);
token = rtrim(token, "\r");
@ -706,73 +772,24 @@ void LaTeX::deplog(DepTable & head)
smatch sub;
if (regex_match(token, sub, reg1)) {
foundfile = sub.str(1);
} else if (regex_match(token, sub, reg2)) {
foundfile = sub.str(1);
} else if (regex_match(token, sub, reg3)) {
foundfile = sub.str(1);
} else if (regex_match(token, sub, reg4)) {
foundfile = sub.str(1);
} else if (regex_match(token, sub, reg5)) {
foundfile = sub.str(1);
} else {
continue;
}
static regex reg1_1("\\(([^()]+)");
smatch what;
string::const_iterator first = token.begin();
string::const_iterator end = token.end();
// convert from native os path to unix path
foundfile = os::internal_path(foundfile);
lyxerr[Debug::DEPEND] << "Found file: "
<< foundfile << endl;
// Ok now we found a file.
// Now we should make sure that this is a file that we can
// access through the normal paths.
// We will not try any fancy search methods to
// find the file.
// (1) foundfile is an
// absolute path and should
// be inserted.
if (AbsolutePath(foundfile)) {
lyxerr[Debug::DEPEND] << "AbsolutePath file: "
<< foundfile << endl;
// On initial insert we want to do the update at once
// since this file can not be a file generated by
// the latex run.
if (FileInfo(foundfile).exist())
head.insert(foundfile, true);
}
// (2) foundfile is in the tmpdir
// insert it into head
else if (FileInfo(OnlyFilename(foundfile)).exist()) {
if (regex_match(foundfile, unwanted)) {
lyxerr[Debug::DEPEND]
<< "We don't want "
<< OnlyFilename(foundfile)
<< " in the dep file"
<< endl;
} else if (suffixIs(foundfile, ".tex")) {
// This is a tex file generated by LyX
// and latex is not likely to change this
// during its runs.
lyxerr[Debug::DEPEND]
<< "Tmpdir TeX file: "
<< OnlyFilename(foundfile)
<< endl;
head.insert(foundfile, true);
} else {
lyxerr[Debug::DEPEND]
<< "In tmpdir file:"
<< OnlyFilename(foundfile)
<< endl;
head.insert(OnlyFilename(foundfile));
while (regex_search(first, end, what, reg1_1)) {
first = what[0].second;
handleFoundFile(what.str(1), head);
}
} else
lyxerr[Debug::DEPEND]
<< "Not a file or we are unable to find it."
<< endl;
} else if (regex_match(token, sub, reg2)) {
handleFoundFile(sub.str(1), head);
} else if (regex_match(token, sub, reg3)) {
handleFoundFile(sub.str(1), head);
} else if (regex_match(token, sub, reg4)) {
handleFoundFile(sub.str(1), head);
} else if (regex_match(token, sub, reg5)) {
handleFoundFile(sub.str(1), head);
}
}
// Make sure that the main .tex file is in the dependancy file.