FileName const bbl(changeExtension(file.absFileName(), ".bbl"));
bbl.removeFile();
+ // biber file
+ FileName const bcf(changeExtension(file.absFileName(), ".bcf"));
+ bcf.removeFile();
+
// makeindex file
FileName const ind(changeExtension(file.absFileName(), ".ind"));
ind.removeFile();
if (head.haschanged(glofile))
rerun |= runMakeIndexNomencl(file, ".glo", ".gls");
+ // 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 if it was updated)
+ FileName const bcffile(changeExtension(file.absFileName(), ".bcf"));
+ bool const biber = head.exist(bcffile);
+
// run bibtex
// if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex)
if (scanres & UNDEF_CIT || run_bibtex) {
// no checks for now
LYXERR(Debug::LATEX, "Running BibTeX.");
message(_("Running BibTeX."));
- updateBibtexDependencies(head, bibtex_info);
- rerun |= runBibTeX(bibtex_info, runparams);
+ 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
// no checks for now
LYXERR(Debug::LATEX, "Running BibTeX.");
message(_("Running BibTeX."));
- updateBibtexDependencies(head, bibtex_info);
- rerun |= runBibTeX(bibtex_info, runparams);
+ updateBibtexDependencies(head, bibtex_info, biber);
+ rerun |= runBibTeX(bibtex_info, runparams, biber);
}
// 4
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
// remove all ".bib" and ".bst" files.
dep.insert(file, true);
}
}
+
+ // biber writes nothing into the aux file.
+ // Instead, we have to scan the blg file
+ if (biber) {
+ scanBlgFile(dep);
+ }
}
bool LaTeX::runBibTeX(vector<AuxInfo> const & bibtex_info,
- OutputParams const & runparams)
+ OutputParams const & runparams, bool biber)
{
bool result = false;
for (vector<AuxInfo>::const_iterator it = bibtex_info.begin();
it != bibtex_info.end(); ++it) {
- if (it->databases.empty())
+ if (!biber && it->databases.empty())
continue;
result = true;
&& contains(token, "undefined")) {
retval |= ERROR_RERUN;
LYXERR(Debug::LATEX, "Force rerun.");
+ // package etaremune
+ } else if (contains(token, "Etaremune labels have changed")) {
+ retval |= ERROR_RERUN;
+ LYXERR(Debug::LATEX, "Force rerun.");
} else if (contains(token, "Citation")
&& contains(token, "on page")
&& contains(token, "undefined")) {
// However, ...
if (suffixIs(token, ")"))
// no line break for sure
- // pretend we've been succesfully searching
+ // pretend we've been successfully searching
found_file = true;
// (2) "No file file.ext"
} else if (regex_match(token, sub, reg2)) {
file.absFileName(), ".toc")), head);
else
// not found, but we won't check further
- // pretend we've been succesfully searching
+ // pretend we've been successfully searching
found_file = true;
// (8) "(file.ext"
// we have a closing bracket, so the content
// is not a file name.
// no need to investigate further
- // pretend we've been succesfully searching
+ // pretend we've been successfully searching
first = what[0].second;
found_file = true;
}
}
+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