From c57b67f24fdcb6f2c506b833f430bc3fd841a290 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Sat, 11 Oct 2003 01:21:26 +0000 Subject: [PATCH] Bug: 820 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2003-10-11 Lars Gullik Bj�nnes * 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 --- src/ChangeLog | 6 ++ src/LaTeX.C | 159 ++++++++++++++++++++++++++++---------------------- 2 files changed, 94 insertions(+), 71 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 795b2780cc..eece349091 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-10-11 Lars Gullik Bjønnes + + * 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 diff --git a/src/LaTeX.C b/src/LaTeX.C index 1f2a2e5343..de40f6112d 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -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); + 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)) { - foundfile = sub.str(1); + handleFoundFile(sub.str(1), head); } else if (regex_match(token, sub, reg3)) { - foundfile = sub.str(1); + handleFoundFile(sub.str(1), head); } else if (regex_match(token, sub, reg4)) { - foundfile = sub.str(1); + handleFoundFile(sub.str(1), head); } else if (regex_match(token, sub, reg5)) { - foundfile = sub.str(1); - } else { - continue; + handleFoundFile(sub.str(1), head); } - - // 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)); - } - } else - lyxerr[Debug::DEPEND] - << "Not a file or we are unable to find it." - << endl; } // Make sure that the main .tex file is in the dependancy file. -- 2.39.2