// different way.
// - the makeindex style files should be taken care of with
// the dependency mechanism.
-// - we should perhaps also scan the bibtex log file
namespace {
bool had_depfile = depfile.exists();
bool run_bibtex = false;
- FileName const aux_file(changeExtension(file.absFileName(), "aux"));
+ FileName const aux_file(changeExtension(file.absFileName(), ".aux"));
if (had_depfile) {
LYXERR(Debug::DEPEND, "Dependency file exists");
runparams);
}
FileName const nlofile(changeExtension(file.absFileName(), ".nlo"));
- if (head.haschanged(nlofile))
+ // If all nomencl entries are removed, nomencl writes an empty nlo file.
+ // DepTable::hasChanged() returns false in this case, since it does not
+ // distinguish empty files from non-existing files. This is why we need
+ // the extra checks here (to trigger a rerun). Cf. discussions in #8905.
+ // FIXME: Sort out the real problem in DepTable.
+ if (head.haschanged(nlofile) || (nlofile.exists() && nlofile.isFileEmpty()))
rerun |= runMakeIndexNomencl(file, ".nlo", ".nls");
FileName const glofile(changeExtension(file.absFileName(), ".glo"));
if (head.haschanged(glofile))
message(_("Running BibTeX."));
updateBibtexDependencies(head, bibtex_info);
rerun |= runBibTeX(bibtex_info, runparams);
- 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);
+ FileName const blgfile(changeExtension(file.absFileName(), ".blg"));
+ if (blgfile.exists()) {
+ int bscanres = scanBlgFile(head, terr);
+ if (bscanres & ERRORS) {
+ deleteFilesOnError();
+ return bscanres; // return on error
+ }
}
} else if (!had_depfile) {
/// If we run pdflatex on the file after running latex on it,
message(_("Running BibTeX."));
updateBibtexDependencies(head, bibtex_info);
rerun |= runBibTeX(bibtex_info, runparams);
+ FileName const blgfile(changeExtension(file.absFileName(), ".blg"));
+ if (blgfile.exists()) {
+ int bscanres = scanBlgFile(head, terr);
+ if (bscanres & ERRORS) {
+ deleteFilesOnError();
+ return bscanres; // return on error
+ }
+ }
}
// 4
// biber writes nothing into the aux file.
// Instead, we have to scan the blg file
if (biber) {
- scanBlgFile(dep);
+ TeXErrors terr;
+ scanBlgFile(dep, terr);
}
}
FileName const fn = FileName(makeAbsPath(tmp));
ifstream ifs(fn.toFilesystemEncoding().c_str());
bool fle_style = false;
- static regex file_line_error(".+\\.\\D+:[0-9]+: (.+)");
- static regex child_file(".*([0-9]+[A-Za-z]*_.+\\.tex).*");
+ static regex const file_line_error(".+\\.\\D+:[0-9]+: (.+)");
+ static regex const child_file(".*([0-9]+[A-Za-z]*_.+\\.tex).*");
// Flag for 'File ended while scanning' message.
// We need to wait for subsequent processing.
string wait_for_error;
&& contains(token, "on page")
&& contains(token, "undefined")) {
retval |= UNDEF_CIT;
+ } else if (contains(token, "Citation")
+ && contains(token, "on input line")
+ && contains(token, "undefined")) {
+ retval |= UNDEF_CIT;
}
} else if (prefixIs(token, "Package")) {
// Package warnings
// we have a latex error
retval |= TEX_ERROR;
if (contains(desc,
- "Package babel Error: You haven't defined the language") ||
- contains(desc,
- "Package babel Error: You haven't loaded the option"))
+ "Package babel Error: You haven't defined the language")
+ || contains(desc,
+ "Package babel Error: You haven't loaded the option")
+ || contains(desc,
+ "Package babel Error: Unknown language"))
retval |= ERROR_RERUN;
// get the line number:
int line = 0;
// (and in addition to those above)
if (regex_match(token, sub, reg5)) {
// search for strings in <...>
- static regex reg5_1("<([^>]+)(.)");
+ static regex const reg5_1("<([^>]+)(.)");
fragment_pos = iterateLine(token, reg5_1, ">",
fragment_pos, head);
fragment = (fragment_pos != -1);
// where "File: file.ext" would be skipped
if (regex_match(token, sub, reg6)) {
// search for strings in (...)
- static regex reg6_1("\\(([^()]+)(.)");
+ static regex const reg6_1("\\(([^()]+)(.)");
fragment_pos = iterateLine(token, reg6_1, ")",
fragment_pos, head);
fragment = (fragment_pos != -1);
}
-void LaTeX::scanBlgFile(DepTable & dep)
+int LaTeX::scanBlgFile(DepTable & dep, TeXErrors & terr)
{
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|BibTeX) data (file|source) '([^']+).*");
+ static regex const bibtexError("^(.*---line [0-9]+ of file).*$");
+ static regex const bibtexError2("^(.*---while reading file).*$");
+ static regex const bibtexError3("(A bad cross reference---).*");
+ static regex const bibtexError4("(Sorry---you've exceeded BibTeX's).*");
+ static regex const bibtexError5("\\*Please notify the BibTeX maintainer\\*");
+ static regex const biberError("^.*> (FATAL|ERROR) - (.*)$");
+ int retval = NO_ERRORS;
+ string prevtoken;
while (getline(ifs, token)) {
token = rtrim(token, "\r");
smatch sub;
handleFoundFile(data, dep);
}
}
- }
+ else if (regex_match(token, sub, bibtexError)
+ || regex_match(token, sub, bibtexError2)
+ || regex_match(token, sub, bibtexError4)
+ || regex_match(token, sub, bibtexError5)) {
+ retval |= BIBTEX_ERROR;
+ string errstr = N_("BibTeX error: ") + token;
+ string message;
+ if ((prefixIs(token, "while executing---line")
+ || prefixIs(token, "---line ")
+ || prefixIs(token, "*Please notify the BibTeX"))
+ && !prevtoken.empty()) {
+ errstr = N_("BibTeX error: ") + prevtoken;
+ message = prevtoken + '\n';
+ }
+ message += token;
+ terr.insertError(0,
+ from_local8bit(errstr),
+ from_local8bit(message));
+ } else if (regex_match(prevtoken, sub, bibtexError3)) {
+ retval |= BIBTEX_ERROR;
+ string errstr = N_("BibTeX error: ") + prevtoken;
+ string message = prevtoken + '\n' + token;
+ terr.insertError(0,
+ from_local8bit(errstr),
+ from_local8bit(message));
+ } else if (regex_match(token, sub, biberError)) {
+ retval |= BIBTEX_ERROR;
+ string errstr = N_("Biber error: ") + sub.str(2);
+ string message = token;
+ terr.insertError(0,
+ from_local8bit(errstr),
+ from_local8bit(message));
+ }
+ prevtoken = token;
+ }
+ return retval;
}