mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
Bug: 820
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:
parent
1c4ae33f9a
commit
c57b67f24f
@ -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>
|
2003-10-10 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
127
src/LaTeX.C
127
src/LaTeX.C
@ -46,6 +46,7 @@ using lyx::support::split;
|
|||||||
using lyx::support::suffixIs;
|
using lyx::support::suffixIs;
|
||||||
using lyx::support::Systemcall;
|
using lyx::support::Systemcall;
|
||||||
using lyx::support::unlink;
|
using lyx::support::unlink;
|
||||||
|
using lyx::support::trim;
|
||||||
|
|
||||||
namespace os = lyx::support::os;
|
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));
|
return bformat(_("Waiting for LaTeX run number %1$s"), tostr(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
} // anon namespace
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CLASS TEXERRORS
|
* CLASS TEXERRORS
|
||||||
@ -671,59 +672,17 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LaTeX::deplog(DepTable & head)
|
namespace {
|
||||||
|
|
||||||
|
void handleFoundFile(string const & ff, DepTable & head)
|
||||||
{
|
{
|
||||||
// This function reads the LaTeX log file end extracts all the external
|
static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
|
||||||
// files used by the LaTeX run. The files are then entered into the
|
|
||||||
// dependency file.
|
|
||||||
|
|
||||||
string const logfile = OnlyFilename(ChangeExtension(file, ".log"));
|
|
||||||
|
|
||||||
regex reg1("\\)* *\\(([^ )]+).*");
|
|
||||||
regex reg2("File: ([^ ]+).*");
|
|
||||||
regex reg3("No file ([^ ]+)\\..*");
|
|
||||||
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)$");
|
|
||||||
|
|
||||||
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
|
|
||||||
// "File: \([^ ]+\)" should match the "File: file" variant
|
|
||||||
string foundfile;
|
|
||||||
string token;
|
|
||||||
getline(ifs, token);
|
|
||||||
token = rtrim(token, "\r");
|
|
||||||
if (token.empty()) continue;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert from native os path to unix path
|
// convert from native os path to unix path
|
||||||
foundfile = os::internal_path(foundfile);
|
string const foundfile = os::internal_path(trim(ff));
|
||||||
|
string const onlyfile = OnlyFilename(foundfile);
|
||||||
|
|
||||||
lyxerr[Debug::DEPEND] << "Found file: "
|
lyxerr[Debug::DEPEND] << "Found file: " << foundfile << endl;
|
||||||
<< foundfile << endl;
|
|
||||||
|
|
||||||
// Ok now we found a file.
|
// Ok now we found a file.
|
||||||
// Now we should make sure that this is a file that we can
|
// Now we should make sure that this is a file that we can
|
||||||
@ -746,11 +705,11 @@ void LaTeX::deplog(DepTable & head)
|
|||||||
|
|
||||||
// (2) foundfile is in the tmpdir
|
// (2) foundfile is in the tmpdir
|
||||||
// insert it into head
|
// insert it into head
|
||||||
else if (FileInfo(OnlyFilename(foundfile)).exist()) {
|
else if (FileInfo(onlyfile).exist()) {
|
||||||
if (regex_match(foundfile, unwanted)) {
|
if (regex_match(foundfile, unwanted)) {
|
||||||
lyxerr[Debug::DEPEND]
|
lyxerr[Debug::DEPEND]
|
||||||
<< "We don't want "
|
<< "We don't want "
|
||||||
<< OnlyFilename(foundfile)
|
<< onlyfile
|
||||||
<< " in the dep file"
|
<< " in the dep file"
|
||||||
<< endl;
|
<< endl;
|
||||||
} else if (suffixIs(foundfile, ".tex")) {
|
} else if (suffixIs(foundfile, ".tex")) {
|
||||||
@ -759,20 +718,78 @@ void LaTeX::deplog(DepTable & head)
|
|||||||
// during its runs.
|
// during its runs.
|
||||||
lyxerr[Debug::DEPEND]
|
lyxerr[Debug::DEPEND]
|
||||||
<< "Tmpdir TeX file: "
|
<< "Tmpdir TeX file: "
|
||||||
<< OnlyFilename(foundfile)
|
<< onlyfile
|
||||||
<< endl;
|
<< endl;
|
||||||
head.insert(foundfile, true);
|
head.insert(foundfile, true);
|
||||||
} else {
|
} else {
|
||||||
lyxerr[Debug::DEPEND]
|
lyxerr[Debug::DEPEND]
|
||||||
<< "In tmpdir file:"
|
<< "In tmpdir file:"
|
||||||
<< OnlyFilename(foundfile)
|
<< onlyfile
|
||||||
<< endl;
|
<< endl;
|
||||||
head.insert(OnlyFilename(foundfile));
|
head.insert(onlyfile);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
lyxerr[Debug::DEPEND]
|
lyxerr[Debug::DEPEND]
|
||||||
<< "Not a file or we are unable to find it."
|
<< "Not a file or we are unable to find it."
|
||||||
<< endl;
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anon namespace
|
||||||
|
|
||||||
|
|
||||||
|
void LaTeX::deplog(DepTable & head)
|
||||||
|
{
|
||||||
|
// This function reads the LaTeX log file end extracts all the external
|
||||||
|
// files used by the LaTeX run. The files are then entered into the
|
||||||
|
// dependency file.
|
||||||
|
|
||||||
|
string const logfile = OnlyFilename(ChangeExtension(file, ".log"));
|
||||||
|
|
||||||
|
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
|
||||||
|
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, note
|
||||||
|
// that we can have several of these on one line.
|
||||||
|
// "File: \([^ ]+\)" should match the "File: file" variant
|
||||||
|
|
||||||
|
string token;
|
||||||
|
getline(ifs, token);
|
||||||
|
token = rtrim(token, "\r");
|
||||||
|
if (token.empty()) continue;
|
||||||
|
|
||||||
|
smatch sub;
|
||||||
|
|
||||||
|
if (regex_match(token, sub, reg1)) {
|
||||||
|
static regex reg1_1("\\(([^()]+)");
|
||||||
|
smatch what;
|
||||||
|
string::const_iterator first = token.begin();
|
||||||
|
string::const_iterator end = token.end();
|
||||||
|
|
||||||
|
while (regex_search(first, end, what, reg1_1)) {
|
||||||
|
first = what[0].second;
|
||||||
|
handleFoundFile(what.str(1), head);
|
||||||
|
}
|
||||||
|
} 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.
|
// Make sure that the main .tex file is in the dependancy file.
|
||||||
|
Loading…
Reference in New Issue
Block a user