#include "support/convert.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/convert.h"
#include "support/FileName.h"
#include "support/filetools.h"
// Note that we do not always call this function when there is an error.
// For example, if there is an error but an output file is produced we
// still would like to output (export/view) the file.
// Note that we do not always call this function when there is an error.
// For example, if there is an error but an output file is produced we
// still would like to output (export/view) the file.
// Also remove all children which are included
Buffer const * buf = theBufferList().getBufferFromTmp(file.absFileName());
if (buf && buf->params().maintain_unincluded_children == BufferParams::CM_Mostly) {
// Also remove all children which are included
Buffer const * buf = theBufferList().getBufferFromTmp(file.absFileName());
if (buf && buf->params().maintain_unincluded_children == BufferParams::CM_Mostly) {
string const incm =
DocFileName(changeExtension(makeAbsPath(incfile, path)
.absFileName(), ".tex")).mangledFileName();
string const incm =
DocFileName(changeExtension(makeAbsPath(incfile, path)
.absFileName(), ".tex")).mangledFileName();
scanres = scanLogFile(terr);
if (scanres & ERROR_RERUN) {
LYXERR(Debug::LATEX, "Rerunning LaTeX");
terr.clearErrors();
exit_code = startscript();
scanres = scanLogFile(terr);
if (scanres & ERROR_RERUN) {
LYXERR(Debug::LATEX, "Rerunning LaTeX");
terr.clearErrors();
exit_code = startscript();
// onlyFileName() is needed for cygwin
int const ret =
runMakeIndex(onlyFileName(idxfile.absFileName()), runparams);
// onlyFileName() is needed for cygwin
int const ret =
runMakeIndex(onlyFileName(idxfile.absFileName()), runparams);
FileName const ilgfile(changeExtension(file.absFileName(), ".ilg"));
if (ilgfile.exists())
iscanres = scanIlgFile(terr);
FileName const ilgfile(changeExtension(file.absFileName(), ".ilg"));
if (ilgfile.exists())
iscanres = scanIlgFile(terr);
// FIXME: Sort out the real problem in DepTable.
if (head.haschanged(nlofile) || (nlofile.exists() && nlofile.isFileEmpty())) {
int const ret = runMakeIndexNomencl(file, ".nlo", ".nls");
// FIXME: Sort out the real problem in DepTable.
if (head.haschanged(nlofile) || (nlofile.exists() && nlofile.isFileEmpty())) {
int const ret = runMakeIndexNomencl(file, ".nlo", ".nls");
updateBibtexDependencies(head, bibtex_info);
int exit_code;
rerun |= runBibTeX(bibtex_info, runparams, exit_code);
updateBibtexDependencies(head, bibtex_info);
int exit_code;
rerun |= runBibTeX(bibtex_info, runparams, exit_code);
FileName const blgfile(changeExtension(file.absFileName(), ".blg"));
if (blgfile.exists())
bscanres = scanBlgFile(head, terr);
FileName const blgfile(changeExtension(file.absFileName(), ".blg"));
if (blgfile.exists())
bscanres = scanBlgFile(head, terr);
LYXERR(Debug::LATEX, "Run #" << count);
message(runMessage(count));
int exit_code = startscript();
LYXERR(Debug::LATEX, "Run #" << count);
message(runMessage(count));
int exit_code = startscript();
updateBibtexDependencies(head, bibtex_info);
int exit_code;
rerun |= runBibTeX(bibtex_info, runparams, exit_code);
updateBibtexDependencies(head, bibtex_info);
int exit_code;
rerun |= runBibTeX(bibtex_info, runparams, exit_code);
FileName const blgfile(changeExtension(file.absFileName(), ".blg"));
if (blgfile.exists())
bscanres = scanBlgFile(head, terr);
FileName const blgfile(changeExtension(file.absFileName(), ".blg"));
if (blgfile.exists())
bscanres = scanBlgFile(head, terr);
// onlyFileName() is needed for cygwin
int const ret = runMakeIndex(onlyFileName(changeExtension(
file.absFileName(), ".idx")), runparams);
// onlyFileName() is needed for cygwin
int const ret = runMakeIndex(onlyFileName(changeExtension(
file.absFileName(), ".idx")), runparams);
FileName const ilgfile(changeExtension(file.absFileName(), ".ilg"));
if (ilgfile.exists())
iscanres = scanIlgFile(terr);
FileName const ilgfile(changeExtension(file.absFileName(), ".ilg"));
if (ilgfile.exists())
iscanres = scanIlgFile(terr);
if (contains(tmp, "$$x")) {
// This adds appropriate [te]xindy options
// such as language and codepage (for the
// main document language/encoding) as well
// as input markup (latex or xelatex)
if (contains(tmp, "$$x")) {
// This adds appropriate [te]xindy options
// such as language and codepage (for the
// main document language/encoding) as well
// as input markup (latex or xelatex)
"idx file has been made, running index processor ("
<< tmp << ") on file " << f);
"idx file has been made, running index processor ("
<< tmp << ") on file " << f);
- tmp = subst(tmp, "$$lang", rp.document_language);
+ if (doc_lang) {
+ tmp = subst(tmp, "$$lang", doc_lang->babel());
+ tmp = subst(tmp, "$$lcode", doc_lang->code());
+ }
exit_code = one.startscript(starttype, tmp, path, lpath, true);
if (exit_code) {
return result;
exit_code = one.startscript(starttype, tmp, path, lpath, true);
if (exit_code) {
return result;
string tmp =
onlyFileName(changeExtension(file.absFileName(), ".log"));
LYXERR(Debug::LATEX, "Log file: " << tmp);
string tmp =
onlyFileName(changeExtension(file.absFileName(), ".log"));
LYXERR(Debug::LATEX, "Log file: " << tmp);
// FIXME we should use an ifdocstream here and a docstring for token
// below. The encoding of the log file depends on the _output_ (font)
// encoding of the TeX file (T1, TU etc.). See #10728.
// FIXME we should use an ifdocstream here and a docstring for token
// below. The encoding of the log file depends on the _output_ (font)
// encoding of the TeX file (T1, TU etc.). See #10728.
// 15 is somewhat arbitrarily chosen, based on practice.
// We used 10 for 14 years and increased it to 15 when we
// saw one case.
// 15 is somewhat arbitrarily chosen, based on practice.
// We used 10 for 14 years and increased it to 15 when we
// saw one case.
sscanf(tmp.c_str(), "l.%d", &line);
// get the rest of the message:
string errstr(tmp, tmp.find(' '));
sscanf(tmp.c_str(), "l.%d", &line);
// get the rest of the message:
string errstr(tmp, tmp.find(' '));
+ bool preamble_error = false;
+ if (suffixIs(errstr, "\\begin{document}")) {
+ // this is an error in preamble
+ // the real error is in the
+ // intermediate lines
+ errstr = intermediate;
+ tmp = intermediate;
+ preamble_error = true;
+ }
LYXERR(Debug::LATEX, "line: " << line << '\n'
<< "Desc: " << desc << '\n' << "Text: " << errstr);
if (line == last_line)
LYXERR(Debug::LATEX, "line: " << line << '\n'
<< "Desc: " << desc << '\n' << "Text: " << errstr);
if (line == last_line)
} else if (regex_match(token, sub, biberError)) {
retval |= BIBTEX_ERROR;
string errstr = N_("Biber error: ") + sub.str(2);
} else if (regex_match(token, sub, biberError)) {
retval |= BIBTEX_ERROR;
string errstr = N_("Biber error: ") + sub.str(2);
string prevtoken;
while (getline(ifs, token)) {
token = rtrim(token, "\r");
string prevtoken;
while (getline(ifs, token)) {
token = rtrim(token, "\r");
if (prefixIs(token, "!! "))
prevtoken = token;
else if (!prevtoken.empty()) {
if (prefixIs(token, "!! "))
prevtoken = token;
else if (!prevtoken.empty()) {
} else if (prefixIs(token, "ERROR: ")) {
retval |= BIBTEX_ERROR;
string errstr = N_("Xindy error: ") + token.substr(6);
} else if (prefixIs(token, "ERROR: ")) {
retval |= BIBTEX_ERROR;
string errstr = N_("Xindy error: ") + token.substr(6);