mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
* LaTeX.{cpp,h}:
- refine biber support: parse blg file to get the bib file into the dependency table with biber. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37581 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4a8698c808
commit
14146a43fe
@ -207,8 +207,7 @@ int LaTeX::run(TeXErrors & terr)
|
|||||||
LYXERR(Debug::DEPEND, "Dependency file has changed");
|
LYXERR(Debug::DEPEND, "Dependency file has changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (head.extchanged(".bib") || head.extchanged(".bst")
|
if (head.extchanged(".bib") || head.extchanged(".bst"))
|
||||||
|| head.extchanged(".bcf"))
|
|
||||||
run_bibtex = true;
|
run_bibtex = true;
|
||||||
} else
|
} else
|
||||||
LYXERR(Debug::DEPEND,
|
LYXERR(Debug::DEPEND,
|
||||||
@ -276,9 +275,9 @@ int LaTeX::run(TeXErrors & terr)
|
|||||||
|
|
||||||
// check if we're using biber instead of bibtex
|
// check if we're using biber instead of bibtex
|
||||||
// biber writes no info to the aux file, so we just check
|
// 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"));
|
FileName const bcffile(changeExtension(file.absFileName(), ".bcf"));
|
||||||
bool const biber = bcffile.exists();
|
bool const biber = head.exist(bcffile);
|
||||||
|
|
||||||
// run bibtex
|
// run bibtex
|
||||||
// if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex)
|
// if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex)
|
||||||
@ -289,13 +288,21 @@ int LaTeX::run(TeXErrors & terr)
|
|||||||
// no checks for now
|
// no checks for now
|
||||||
LYXERR(Debug::LATEX, "Running BibTeX.");
|
LYXERR(Debug::LATEX, "Running BibTeX.");
|
||||||
message(_("Running BibTeX."));
|
message(_("Running BibTeX."));
|
||||||
updateBibtexDependencies(head, bibtex_info);
|
updateBibtexDependencies(head, bibtex_info, biber);
|
||||||
rerun |= runBibTeX(bibtex_info, runparams, 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) {
|
} else if (!had_depfile) {
|
||||||
/// If we run pdflatex on the file after running latex on it,
|
/// 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
|
/// then we do not need to run bibtex, but we do need to
|
||||||
/// insert the .bib and .bst files into the .dep-pdf file.
|
/// insert the .bib and .bst files into the .dep-pdf file.
|
||||||
updateBibtexDependencies(head, bibtex_info);
|
updateBibtexDependencies(head, bibtex_info, biber);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2
|
// 2
|
||||||
@ -341,7 +348,7 @@ int LaTeX::run(TeXErrors & terr)
|
|||||||
// no checks for now
|
// no checks for now
|
||||||
LYXERR(Debug::LATEX, "Running BibTeX.");
|
LYXERR(Debug::LATEX, "Running BibTeX.");
|
||||||
message(_("Running BibTeX."));
|
message(_("Running BibTeX."));
|
||||||
updateBibtexDependencies(head, bibtex_info);
|
updateBibtexDependencies(head, bibtex_info, biber);
|
||||||
rerun |= runBibTeX(bibtex_info, runparams, biber);
|
rerun |= runBibTeX(bibtex_info, runparams, biber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,7 +548,8 @@ void LaTeX::scanAuxFile(FileName const & file, AuxInfo & aux_info)
|
|||||||
|
|
||||||
|
|
||||||
void LaTeX::updateBibtexDependencies(DepTable & dep,
|
void LaTeX::updateBibtexDependencies(DepTable & dep,
|
||||||
vector<AuxInfo> const & bibtex_info)
|
vector<AuxInfo> const & bibtex_info,
|
||||||
|
bool biber)
|
||||||
{
|
{
|
||||||
// Since a run of Bibtex mandates more latex runs it is ok to
|
// Since a run of Bibtex mandates more latex runs it is ok to
|
||||||
// remove all ".bib" and ".bst" files.
|
// remove all ".bib" and ".bst" files.
|
||||||
@ -565,6 +573,12 @@ void LaTeX::updateBibtexDependencies(DepTable & dep,
|
|||||||
dep.insert(file, true);
|
dep.insert(file, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// biber writes nothing into the aux file.
|
||||||
|
// Instead, we have to scan the blg file
|
||||||
|
if (biber) {
|
||||||
|
scanBlgFile(dep);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1124,4 +1138,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
|
} // namespace lyx
|
||||||
|
@ -185,7 +185,12 @@ private:
|
|||||||
void scanAuxFile(support::FileName const &, AuxInfo &);
|
void scanAuxFile(support::FileName const &, AuxInfo &);
|
||||||
|
|
||||||
///
|
///
|
||||||
void updateBibtexDependencies(DepTable &, std::vector<AuxInfo> const &);
|
void updateBibtexDependencies(DepTable &,
|
||||||
|
std::vector<AuxInfo> const &,
|
||||||
|
bool biber);
|
||||||
|
|
||||||
|
///
|
||||||
|
void scanBlgFile(DepTable & head);
|
||||||
|
|
||||||
///
|
///
|
||||||
bool runBibTeX(std::vector<AuxInfo> const &,
|
bool runBibTeX(std::vector<AuxInfo> const &,
|
||||||
|
Loading…
Reference in New Issue
Block a user