mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-12 16:50:39 +00:00
backport r37581:
URL: http://www.lyx.org/trac/changeset/37581 Log: * LaTeX.{cpp,h}: - refine biber support: parse blg file to get the bib file into the dependency table with biber. I've tested this thoroughly. No status entry necessary. This is a polishment of a previous change (r37539) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@37583 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
553ef65afd
commit
6b673e1b6c
@ -211,8 +211,7 @@ int LaTeX::run(TeXErrors & terr)
|
||||
LYXERR(Debug::DEPEND, "Dependency file has changed");
|
||||
}
|
||||
|
||||
if (head.extchanged(".bib") || head.extchanged(".bst")
|
||||
|| head.extchanged(".bcf"))
|
||||
if (head.extchanged(".bib") || head.extchanged(".bst"))
|
||||
run_bibtex = true;
|
||||
} else
|
||||
LYXERR(Debug::DEPEND,
|
||||
@ -280,9 +279,9 @@ int LaTeX::run(TeXErrors & terr)
|
||||
|
||||
// check if we're using biber instead of bibtex
|
||||
// biber writes no info to the aux file, so we just check
|
||||
// if a bcf file exists (and, above, if it was updated)
|
||||
// if a bcf file exists (and if it was updated)
|
||||
FileName const bcffile(changeExtension(file.absFilename(), ".bcf"));
|
||||
bool const biber = bcffile.exists();
|
||||
bool const biber = head.exist(bcffile);
|
||||
|
||||
// run bibtex
|
||||
// if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex)
|
||||
@ -293,13 +292,21 @@ int LaTeX::run(TeXErrors & terr)
|
||||
// no checks for now
|
||||
LYXERR(Debug::LATEX, "Running BibTeX.");
|
||||
message(_("Running BibTeX."));
|
||||
updateBibtexDependencies(head, bibtex_info);
|
||||
updateBibtexDependencies(head, bibtex_info, biber);
|
||||
rerun |= runBibTeX(bibtex_info, runparams, biber);
|
||||
if (biber) {
|
||||
// since biber writes no info to the aux file, we have
|
||||
// to parse the blg file (which only exists after biber
|
||||
// was first issued)
|
||||
FileName const blgfile(changeExtension(file.absFilename(), ".blg"));
|
||||
if (blgfile.exists())
|
||||
scanBlgFile(head);
|
||||
}
|
||||
} else if (!had_depfile) {
|
||||
/// If we run pdflatex on the file after running latex on it,
|
||||
/// then we do not need to run bibtex, but we do need to
|
||||
/// insert the .bib and .bst files into the .dep-pdf file.
|
||||
updateBibtexDependencies(head, bibtex_info);
|
||||
updateBibtexDependencies(head, bibtex_info, biber);
|
||||
}
|
||||
|
||||
// 2
|
||||
@ -345,7 +352,7 @@ int LaTeX::run(TeXErrors & terr)
|
||||
// no checks for now
|
||||
LYXERR(Debug::LATEX, "Running BibTeX.");
|
||||
message(_("Running BibTeX."));
|
||||
updateBibtexDependencies(head, bibtex_info);
|
||||
updateBibtexDependencies(head, bibtex_info, biber);
|
||||
rerun |= runBibTeX(bibtex_info, runparams, biber);
|
||||
}
|
||||
|
||||
@ -535,7 +542,8 @@ void LaTeX::scanAuxFile(FileName const & file, Aux_Info & aux_info)
|
||||
|
||||
|
||||
void LaTeX::updateBibtexDependencies(DepTable & dep,
|
||||
vector<Aux_Info> const & bibtex_info)
|
||||
vector<Aux_Info> const & bibtex_info,
|
||||
bool biber)
|
||||
{
|
||||
// Since a run of Bibtex mandates more latex runs it is ok to
|
||||
// remove all ".bib" and ".bst" files.
|
||||
@ -559,6 +567,12 @@ void LaTeX::updateBibtexDependencies(DepTable & dep,
|
||||
dep.insert(file, true);
|
||||
}
|
||||
}
|
||||
|
||||
// biber writes nothing into the aux file.
|
||||
// Instead, we have to scan the blg file
|
||||
if (biber) {
|
||||
scanBlgFile(dep);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1088,4 +1102,30 @@ void LaTeX::deplog(DepTable & head)
|
||||
}
|
||||
|
||||
|
||||
void LaTeX::scanBlgFile(DepTable & dep)
|
||||
{
|
||||
FileName const blg_file(changeExtension(file.absFilename(), "blg"));
|
||||
LYXERR(Debug::LATEX, "Scanning blg file: " << blg_file);
|
||||
|
||||
ifstream ifs(blg_file.toFilesystemEncoding().c_str());
|
||||
string token;
|
||||
static regex const reg1(".*Found bibtex data file '([^']+).*");
|
||||
|
||||
while (getline(ifs, token)) {
|
||||
token = rtrim(token, "\r");
|
||||
smatch sub;
|
||||
// FIXME UNICODE: We assume that citation keys and filenames
|
||||
// in the aux file are in the file system encoding.
|
||||
token = to_utf8(from_filesystem8bit(token));
|
||||
if (regex_match(token, sub, reg1)) {
|
||||
string data = sub.str(1);
|
||||
if (!data.empty()) {
|
||||
LYXERR(Debug::LATEX, "Found bib file: " << data);
|
||||
handleFoundFile(data, dep);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -186,7 +186,10 @@ private:
|
||||
|
||||
///
|
||||
void updateBibtexDependencies(DepTable &,
|
||||
std::vector<Aux_Info> const &);
|
||||
std::vector<Aux_Info> const &, bool biber);
|
||||
|
||||
///
|
||||
void scanBlgFile(DepTable & head);
|
||||
|
||||
///
|
||||
bool runBibTeX(std::vector<Aux_Info> const &,
|
||||
|
Loading…
Reference in New Issue
Block a user