3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alfredo Braunstein
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author Angus Leeming
11 * \author Jürgen Spitzmüller
13 * Full author contact details are available in file CREDITS.
19 #include "BufferList.h"
20 #include "BufferParams.h"
27 #include "support/debug.h"
28 #include "support/convert.h"
29 #include "support/FileName.h"
30 #include "support/filetools.h"
31 #include "support/gettext.h"
32 #include "support/lstrings.h"
33 #include "support/Systemcall.h"
34 #include "support/os.h"
36 #include "support/regex.h"
43 using namespace lyx::support;
47 namespace os = support::os;
49 // TODO: in no particular order
50 // - get rid of the call to
51 // BufferList::updateIncludedTeXfiles, this should either
52 // be done before calling LaTeX::funcs or in a completely
54 // - the makeindex style files should be taken care of with
55 // the dependency mechanism.
59 docstring runMessage(unsigned int count)
61 return bformat(_("Waiting for LaTeX run number %1$d"), count);
70 void TeXErrors::insertError(int line, docstring const & error_desc,
71 docstring const & error_text,
72 string const & child_name)
74 Error newerr(line, error_desc, error_text, child_name);
75 errors.push_back(newerr);
79 void TeXErrors::insertRef(int line, docstring const & error_desc,
80 docstring const & error_text,
81 string const & child_name)
83 Error newerr(line, error_desc, error_text, child_name);
84 undef_ref.push_back(newerr);
88 bool operator==(AuxInfo const & a, AuxInfo const & o)
90 return a.aux_file == o.aux_file
91 && a.citations == o.citations
92 && a.databases == o.databases
93 && a.styles == o.styles;
97 bool operator!=(AuxInfo const & a, AuxInfo const & o)
107 LaTeX::LaTeX(string const & latex, OutputParams const & rp,
108 FileName const & f, string const & p, string const & lp,
109 bool allow_cancellation, bool const clean_start)
110 : cmd(latex), file(f), path(p), lpath(lp), runparams(rp), biber(false),
111 allow_cancel(allow_cancellation)
114 // lualatex can still produce a DVI with --output-format=dvi. However,
115 // we do not use that internally (we use the "dvilualatex" command) so
116 // it would only happen from a custom converter. Thus, it is better to
117 // guess that lualatex produces a PDF than to guess a DVI.
118 // FIXME we should base the extension on the output format, which we should
119 // get in a robust way, e.g. from the converter.
120 if (prefixIs(cmd, "pdf") || prefixIs(cmd, "lualatex") || prefixIs(cmd, "xelatex")) {
121 depfile = FileName(file.absFileName() + ".dep-pdf");
123 FileName(changeExtension(file.absFileName(), ".pdf"));
125 depfile = FileName(file.absFileName() + ".dep");
127 FileName(changeExtension(file.absFileName(), ".dvi"));
130 removeAuxiliaryFiles();
134 void LaTeX::removeAuxiliaryFiles() const
136 // Note that we do not always call this function when there is an error.
137 // For example, if there is an error but an output file is produced we
138 // still would like to output (export/view) the file.
140 // What files do we have to delete?
142 // This will at least make latex do all the runs
143 depfile.removeFile();
145 // but the reason for the error might be in a generated file...
148 FileName const bbl(changeExtension(file.absFileName(), ".bbl"));
152 FileName const bcf(changeExtension(file.absFileName(), ".bcf"));
156 FileName const ind(changeExtension(file.absFileName(), ".ind"));
160 FileName const nls(changeExtension(file.absFileName(), ".nls"));
163 // nomencl file (old version of the package)
164 FileName const gls(changeExtension(file.absFileName(), ".gls"));
168 FileName const ent(changeExtension(file.absFileName(), ".ent"));
171 // Also remove the aux file
172 FileName const aux(changeExtension(file.absFileName(), ".aux"));
175 // Also remove the .out file (e.g. hyperref bookmarks) (#9963)
176 FileName const out(changeExtension(file.absFileName(), ".out"));
179 // Remove the output file, which is often generated even if error
180 output_file.removeFile();
184 int LaTeX::run(TeXErrors & terr)
185 // We know that this function will only be run if the lyx buffer
186 // has been changed. We also know that a newly written .tex file
187 // is always different from the previous one because of the date
188 // in it. However it seems safe to run latex (at least) one time
189 // each time the .tex file changes.
191 int scanres = NO_ERRORS;
192 int bscanres = NO_ERRORS;
193 int iscanres = NO_ERRORS;
194 unsigned int count = 0; // number of times run
195 num_errors = 0; // just to make sure.
196 unsigned int const MAX_RUN = 6;
197 DepTable head; // empty head
198 bool rerun = false; // rerun requested
200 // The class LaTeX does not know the temp path.
201 theBufferList().updateIncludedTeXfiles(FileName::getcwd().absFileName(),
205 // first check if the file dependencies exist:
206 // ->If it does exist
207 // check if any of the files mentioned in it have
208 // changed (done using a checksum).
210 // run latex once and
211 // remake the dependency file
212 // -> if not changed:
213 // just return there is nothing to do for us.
214 // ->if it doesn't exist
216 // run latex once (we need to run latex once anyway) and
217 // remake the dependency file.
220 bool had_depfile = depfile.exists();
221 bool run_bibtex = false;
222 FileName const aux_file(changeExtension(file.absFileName(), ".aux"));
225 LYXERR(Debug::DEPEND, "Dependency file exists");
226 // Read the dep file:
227 had_depfile = head.read(depfile);
231 if (runparams.includeall) {
232 // On an "includeall" call (whose purpose is to set up/maintain counters and references
233 // for includeonly), we remove the master from the dependency list since
234 // (1) it will be checked anyway on the subsequent includeonly run
235 // (2) the master is always changed (due to the \includeonly line), and this alone would
236 // trigger a complete, expensive run each time
237 head.remove_file(file);
238 // Also remove all children which are included
239 Buffer const * buf = theBufferList().getBufferFromTmp(file.absFileName());
240 if (buf && buf->params().maintain_unincluded_children == BufferParams::CM_Mostly) {
241 for (auto const incfile : buf->params().getIncludedChildren()) {
243 DocFileName(changeExtension(makeAbsPath(incfile, path)
244 .absFileName(), ".tex")).mangledFileName();
245 FileName inc = makeAbsPath(incm, file.onlyPath().realPath());
246 head.remove_file(inc);
250 // Update the checksums
252 // Can't just check if anything has changed because it might
253 // have aborted on error last time... in which cas we need
254 // to re-run latex and collect the error messages
255 // (even if they are the same).
256 if (!output_file.exists()) {
257 LYXERR(Debug::DEPEND,
258 "re-running LaTeX because output file doesn't exist.");
259 } else if (!head.sumchange()) {
260 LYXERR(Debug::DEPEND, "return no_change");
263 LYXERR(Debug::DEPEND, "Dependency file has changed");
266 if (head.extchanged(".bib") || head.extchanged(".bst"))
269 LYXERR(Debug::DEPEND,
270 "Dependency file does not exist, or has wrong format");
272 /// We scan the aux file even when had_depfile = false,
273 /// because we can run pdflatex on the file after running latex on it,
274 /// in which case we will not need to run bibtex again.
275 vector<AuxInfo> bibtex_info_old;
277 bibtex_info_old = scanAuxFiles(aux_file, runparams.only_childbibs);
280 LYXERR(Debug::LATEX, "Run #" << count);
281 message(runMessage(count));
283 int exit_code = startscript();
284 if (exit_code == Systemcall::KILLED)
285 return Systemcall::KILLED;
287 scanres = scanLogFile(terr);
288 if (scanres & ERROR_RERUN) {
289 LYXERR(Debug::LATEX, "Rerunning LaTeX");
291 exit_code = startscript();
292 if (exit_code == Systemcall::KILLED)
293 return Systemcall::KILLED;
294 scanres = scanLogFile(terr);
297 vector<AuxInfo> const bibtex_info = scanAuxFiles(aux_file, runparams.only_childbibs);
298 if (!run_bibtex && bibtex_info_old != bibtex_info)
301 // update the dependencies.
302 deplog(head); // reads the latex log
306 // At this point we must run external programs if needed.
307 // makeindex will be run if a .idx file changed or was generated.
308 // And if there were undefined citations or changes in references
309 // the .aux file is checked for signs of bibtex. Bibtex is then run
312 // memoir (at least) writes an empty *idx file in the first place.
313 // A second latex run is needed.
314 FileName const idxfile(changeExtension(file.absFileName(), ".idx"));
315 rerun = idxfile.exists() && idxfile.isFileEmpty();
318 if (head.haschanged(idxfile)) {
320 LYXERR(Debug::LATEX, "Running MakeIndex.");
321 message(_("Running Index Processor."));
322 // onlyFileName() is needed for cygwin
324 runMakeIndex(onlyFileName(idxfile.absFileName()), runparams);
325 if (ret == Systemcall::KILLED)
326 return Systemcall::KILLED;
327 FileName const ilgfile(changeExtension(file.absFileName(), ".ilg"));
328 if (ilgfile.exists())
329 iscanres = scanIlgFile(terr);
333 FileName const nlofile(changeExtension(file.absFileName(), ".nlo"));
334 // If all nomencl entries are removed, nomencl writes an empty nlo file.
335 // DepTable::hasChanged() returns false in this case, since it does not
336 // distinguish empty files from non-existing files. This is why we need
337 // the extra checks here (to trigger a rerun). Cf. discussions in #8905.
338 // FIXME: Sort out the real problem in DepTable.
339 if (head.haschanged(nlofile) || (nlofile.exists() && nlofile.isFileEmpty())) {
340 int const ret = runMakeIndexNomencl(file, ".nlo", ".nls");
341 if (ret == Systemcall::KILLED)
342 return Systemcall::KILLED;
346 FileName const glofile(changeExtension(file.absFileName(), ".glo"));
347 if (head.haschanged(glofile)) {
348 int const ret = runMakeIndexNomencl(file, ".glo", ".gls");
355 // check if we're using biber instead of bibtex
356 // biber writes no info to the aux file, so we just check
357 // if a bcf file exists (and if it was updated)
358 FileName const bcffile(changeExtension(file.absFileName(), ".bcf"));
359 biber |= head.exist(bcffile);
362 // if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex)
363 // We do not run bibtex/biber on an "includeall" call (whose purpose is
364 // to set up/maintain counters and references for includeonly) since
365 // (1) bibliographic references will be updated on the subsequent includeonly run
366 // (2) this would trigger a complete run each time (as references in non-included
367 // children are removed on subsequent includeonly runs)
368 if (!runparams.includeall && (scanres & UNDEF_CIT || run_bibtex)) {
369 // Here we must scan the .aux file and look for
370 // "\bibdata" and/or "\bibstyle". If one of those
371 // tags is found -> run bibtex and set rerun = true;
373 LYXERR(Debug::LATEX, "Running BibTeX.");
374 message(_("Running BibTeX."));
375 updateBibtexDependencies(head, bibtex_info);
377 rerun |= runBibTeX(bibtex_info, runparams, exit_code);
378 if (exit_code == Systemcall::KILLED)
379 return Systemcall::KILLED;
380 FileName const blgfile(changeExtension(file.absFileName(), ".blg"));
381 if (blgfile.exists())
382 bscanres = scanBlgFile(head, terr);
383 } else if (!had_depfile) {
384 /// If we run pdflatex on the file after running latex on it,
385 /// then we do not need to run bibtex, but we do need to
386 /// insert the .bib and .bst files into the .dep-pdf file.
387 updateBibtexDependencies(head, bibtex_info);
391 // we know on this point that latex has been run once (or we just
392 // returned) and the question now is to decide if we need to run
393 // it any more. This is done by asking if any of the files in the
394 // dependency file has changed. (remember that the checksum for
395 // a given file is reported to have changed if it just was created)
396 // -> if changed or rerun == true:
397 // run latex once more and
398 // update the dependency structure
399 // -> if not changed:
400 // we do nothing at this point
402 if (rerun || head.sumchange()) {
405 LYXERR(Debug::DEPEND, "Dep. file has changed or rerun requested");
406 LYXERR(Debug::LATEX, "Run #" << count);
407 message(runMessage(count));
408 int exit_code = startscript();
409 if (exit_code == Systemcall::KILLED)
410 return Systemcall::KILLED;
411 scanres = scanLogFile(terr);
413 // update the depedencies
414 deplog(head); // reads the latex log
417 LYXERR(Debug::DEPEND, "Dep. file has NOT changed");
422 // Complex bibliography packages such as Biblatex require
423 // an additional bibtex cycle sometimes.
424 // We do not run bibtex/biber on an "includeall" call (whose purpose is
425 // to set up/maintain counters and references for includeonly) since
426 // (1) bibliographic references will be updated on the subsequent includeonly run
427 // (2) this would trigger a complete run each time (as references in non-included
428 // children are removed on subsequent includeonly runs)
429 if (!runparams.includeall && scanres & UNDEF_CIT) {
430 // Here we must scan the .aux file and look for
431 // "\bibdata" and/or "\bibstyle". If one of those
432 // tags is found -> run bibtex and set rerun = true;
434 LYXERR(Debug::LATEX, "Running BibTeX.");
435 message(_("Running BibTeX."));
436 updateBibtexDependencies(head, bibtex_info);
438 rerun |= runBibTeX(bibtex_info, runparams, exit_code);
439 if (exit_code == Systemcall::KILLED)
440 return Systemcall::KILLED;
441 FileName const blgfile(changeExtension(file.absFileName(), ".blg"));
442 if (blgfile.exists())
443 bscanres = scanBlgFile(head, terr);
447 // The inclusion of files generated by external programs such as
448 // makeindex or bibtex might have done changes to pagenumbering,
449 // etc. And because of this we must run the external programs
450 // again to make sure everything is redone correctly.
451 // Also there should be no need to run the external programs any
454 // run makeindex if the <file>.idx has changed or was generated.
455 if (head.haschanged(idxfile)) {
457 LYXERR(Debug::LATEX, "Running MakeIndex.");
458 message(_("Running Index Processor."));
459 // onlyFileName() is needed for cygwin
460 int const ret = runMakeIndex(onlyFileName(changeExtension(
461 file.absFileName(), ".idx")), runparams);
462 if (ret == Systemcall::KILLED)
463 return Systemcall::KILLED;
464 FileName const ilgfile(changeExtension(file.absFileName(), ".ilg"));
465 if (ilgfile.exists())
466 iscanres = scanIlgFile(terr);
470 // MSVC complains that bool |= int is unsafe. Not sure why.
471 if (head.haschanged(nlofile))
472 rerun |= (runMakeIndexNomencl(file, ".nlo", ".nls") != 0);
473 if (head.haschanged(glofile))
474 rerun |= (runMakeIndexNomencl(file, ".glo", ".gls") != 0);
477 // we will only run latex more if the log file asks for it.
478 // or if the sumchange() is true.
479 // -> rerun asked for:
481 // remake the dependency file
482 // goto 2 or return if max runs are reached.
483 // -> rerun not asked for:
484 // just return (fall out of bottom of func)
486 while ((head.sumchange() || rerun || (scanres & RERUN))
487 && count < MAX_RUN) {
488 // Yes rerun until message goes away, or until
489 // MAX_RUNS are reached.
492 LYXERR(Debug::LATEX, "Run #" << count);
493 message(runMessage(count));
495 scanres = scanLogFile(terr);
501 // Write the dependencies to file.
505 // add flag here, just before return, instead of when exit_code
506 // is defined because scanres is sometimes overwritten above
508 scanres |= NONZERO_ERROR;
511 LYXERR(Debug::LATEX, "Done.");
513 if (bscanres & ERRORS)
514 return bscanres; // return on error
516 if (iscanres & ERRORS)
517 return iscanres; // return on error
523 int LaTeX::startscript()
525 // onlyFileName() is needed for cygwin
526 string tmp = cmd + ' '
527 + quoteName(onlyFileName(file.toFilesystemEncoding()))
528 + " > " + os::nulldev();
530 Systemcall::Starttype const starttype =
531 allow_cancel ? Systemcall::WaitLoop : Systemcall::Wait;
532 return one.startscript(starttype, tmp, path, lpath, true);
536 int LaTeX::runMakeIndex(string const & f, OutputParams const & rp,
537 string const & params)
539 string tmp = rp.use_japanese ?
540 lyxrc.jindex_command : lyxrc.index_command;
542 if (!rp.index_command.empty())
543 tmp = rp.index_command;
545 if (contains(tmp, "$$x")) {
546 // This adds appropriate [te]xindy options
547 // such as language and codepage (for the
548 // main document language/encoding) as well
549 // as input markup (latex or xelatex)
550 string xdyopts = rp.xindy_language;
551 if (!xdyopts.empty())
552 xdyopts = "-L " + xdyopts;
553 if (rp.isFullUnicode() && rp.encoding->package() == Encoding::none) {
554 if (!xdyopts.empty())
556 // xelatex includes lualatex
557 xdyopts += "-I xelatex";
559 else if (rp.encoding->iconvName() == "UTF-8") {
560 if (!xdyopts.empty())
562 // -I not really needed for texindy, but for xindy
563 xdyopts += "-C utf8 -I latex";
566 if (!xdyopts.empty())
568 // not really needed for texindy, but for xindy
569 xdyopts += "-I latex";
571 tmp = subst(tmp, "$$x", xdyopts);
574 if (contains(tmp, "$$b")) {
575 // advise xindy to write a log file
576 tmp = subst(tmp, "$$b", removeExtension(f));
580 "idx file has been made, running index processor ("
581 << tmp << ") on file " << f);
583 tmp = subst(tmp, "$$lang", rp.document_language);
584 if (rp.use_indices) {
585 tmp = lyxrc.splitindex_command + " -m " + quoteName(tmp);
587 "Multiple indices. Using splitindex command: " << tmp);
593 Systemcall::Starttype const starttype =
594 allow_cancel ? Systemcall::WaitLoop : Systemcall::Wait;
595 return one.startscript(starttype, tmp, path, lpath, true);
599 int LaTeX::runMakeIndexNomencl(FileName const & fname,
600 string const & nlo, string const & nls)
602 LYXERR(Debug::LATEX, "Running MakeIndex for nomencl.");
603 message(_("Running MakeIndex for nomencl."));
604 string tmp = lyxrc.nomencl_command + ' ';
605 // onlyFileName() is needed for cygwin
606 tmp += quoteName(onlyFileName(changeExtension(fname.absFileName(), nlo)));
608 + onlyFileName(changeExtension(fname.toFilesystemEncoding(), nls));
610 Systemcall::Starttype const starttype =
611 allow_cancel ? Systemcall::WaitLoop : Systemcall::Wait;
612 return one.startscript(starttype, tmp, path, lpath, true);
616 vector<AuxInfo> const
617 LaTeX::scanAuxFiles(FileName const & fname, bool const only_childbibs)
619 vector<AuxInfo> result;
621 // With chapterbib, we have to bibtex all children's aux files
622 // but _not_ the master's!
623 if (only_childbibs) {
624 for (string const &s: children) {
626 makeAbsPath(s, fname.onlyPath().realPath());
627 fn.changeExtension("aux");
629 result.push_back(scanAuxFile(fn));
634 result.push_back(scanAuxFile(fname));
636 // This is for bibtopic
637 string const basename = removeExtension(fname.absFileName());
638 for (int i = 1; i < 1000; ++i) {
639 FileName const file2(basename
640 + '.' + convert<string>(i)
644 result.push_back(scanAuxFile(file2));
650 AuxInfo const LaTeX::scanAuxFile(FileName const & fname)
653 result.aux_file = fname;
654 scanAuxFile(fname, result);
659 void LaTeX::scanAuxFile(FileName const & fname, AuxInfo & aux_info)
661 LYXERR(Debug::LATEX, "Scanning aux file: " << fname);
663 ifstream ifs(fname.toFilesystemEncoding().c_str());
665 static regex const reg1("\\\\citation\\{([^}]+)\\}");
666 static regex const reg2("\\\\bibdata\\{([^}]+)\\}");
667 static regex const reg3("\\\\bibstyle\\{([^}]+)\\}");
668 static regex const reg4("\\\\@input\\{([^}]+)\\}");
670 while (getline(ifs, token)) {
671 token = rtrim(token, "\r");
673 // FIXME UNICODE: We assume that citation keys and filenames
674 // in the aux file are in the file system encoding.
675 token = to_utf8(from_filesystem8bit(token));
676 if (regex_match(token, sub, reg1)) {
677 string data = sub.str(1);
678 while (!data.empty()) {
680 data = split(data, citation, ',');
681 LYXERR(Debug::LATEX, "Citation: " << citation);
682 aux_info.citations.insert(citation);
684 } else if (regex_match(token, sub, reg2)) {
685 string data = sub.str(1);
686 // data is now all the bib files separated by ','
687 // get them one by one and pass them to the helper
688 while (!data.empty()) {
690 data = split(data, database, ',');
691 database = changeExtension(database, "bib");
692 LYXERR(Debug::LATEX, "BibTeX database: `" << database << '\'');
693 aux_info.databases.insert(database);
695 } else if (regex_match(token, sub, reg3)) {
696 string style = sub.str(1);
697 // token is now the style file
698 // pass it to the helper
699 style = changeExtension(style, "bst");
700 LYXERR(Debug::LATEX, "BibTeX style: `" << style << '\'');
701 aux_info.styles.insert(style);
702 } else if (regex_match(token, sub, reg4)) {
703 string const file2 = sub.str(1);
704 scanAuxFile(makeAbsPath(file2), aux_info);
710 void LaTeX::updateBibtexDependencies(DepTable & dep,
711 vector<AuxInfo> const & bibtex_info)
713 // Since a run of Bibtex mandates more latex runs it is ok to
714 // remove all ".bib" and ".bst" files.
715 dep.remove_files_with_extension(".bib");
716 dep.remove_files_with_extension(".bst");
717 //string aux = OnlyFileName(ChangeExtension(file, ".aux"));
719 for (vector<AuxInfo>::const_iterator it = bibtex_info.begin();
720 it != bibtex_info.end(); ++it) {
721 for (set<string>::const_iterator it2 = it->databases.begin();
722 it2 != it->databases.end(); ++it2) {
723 FileName const file = findtexfile(*it2, "bib");
725 dep.insert(file, true);
728 for (set<string>::const_iterator it2 = it->styles.begin();
729 it2 != it->styles.end(); ++it2) {
730 FileName const file = findtexfile(*it2, "bst");
732 dep.insert(file, true);
736 // biber writes nothing into the aux file.
737 // Instead, we have to scan the blg file
740 scanBlgFile(dep, terr);
745 bool LaTeX::runBibTeX(vector<AuxInfo> const & bibtex_info,
746 OutputParams const & rp, int & exit_code)
750 for (vector<AuxInfo>::const_iterator it = bibtex_info.begin();
751 it != bibtex_info.end(); ++it) {
752 if (!biber && it->databases.empty())
756 string tmp = rp.bibtex_command;
758 // onlyFileName() is needed for cygwin
759 tmp += quoteName(onlyFileName(removeExtension(
760 it->aux_file.absFileName())));
762 Systemcall::Starttype const starttype =
763 allow_cancel ? Systemcall::WaitLoop : Systemcall::Wait;
764 exit_code = one.startscript(starttype, tmp, path, lpath, true);
769 // Return whether bibtex was run
774 //helper func for scanLogFile; gets line number X from strings "... on input line X ..."
775 //returns 0 if none is found
776 int getLineNumber(const string &token){
777 string l = support::token(token, ' ', tokenPos(token,' ',"line") + 1);
778 return l.empty() ? 0 : convert<int>(l);
782 int LaTeX::scanLogFile(TeXErrors & terr)
786 int retval = NO_ERRORS;
788 onlyFileName(changeExtension(file.absFileName(), ".log"));
789 LYXERR(Debug::LATEX, "Log file: " << tmp);
790 FileName const fn = FileName(makeAbsPath(tmp));
791 // FIXME we should use an ifdocstream here and a docstring for token
792 // below. The encoding of the log file depends on the _output_ (font)
793 // encoding of the TeX file (T1, TU etc.). See #10728.
794 ifstream ifs(fn.toFilesystemEncoding().c_str());
795 bool fle_style = false;
796 static regex const file_line_error(".+\\.\\D+:[0-9]+: (.+)");
797 static regex const child_file("[^0-9]*([0-9]+[A-Za-z]*_.+\\.tex).*");
798 static regex const undef_ref(".*Reference `(\\w+)\\' on page.*");
799 // Flag for 'File ended while scanning' message.
800 // We need to wait for subsequent processing.
801 string wait_for_error;
804 stack <pair<string, int> > child;
810 while (getline(ifs, token)) {
811 // MikTeX sometimes inserts \0 in the log file. They can't be
812 // removed directly with the existing string utility
813 // functions, so convert them first to \r, and remove all
814 // \r's afterwards, since we need to remove them anyway.
815 token = subst(token, '\0', '\r');
816 token = subst(token, "\r", "");
819 LYXERR(Debug::LATEX, "Log line: " << token);
824 // Track child documents
825 for (size_t i = 0; i < token.length(); ++i) {
826 if (token[i] == '(') {
828 size_t j = token.find('(', i + 1);
829 size_t len = j == string::npos
830 ? token.substr(i + 1).length()
832 string const substr = token.substr(i + 1, len);
833 if (regex_match(substr, sub, child_file)) {
834 string const name = sub.str(1);
835 // Sometimes also masters have a name that matches
836 // (if their name starts with a number and _)
837 if (name != file.onlyFileName()) {
838 child.push(make_pair(name, pnest));
839 children.push_back(name);
843 } else if (token[i] == ')') {
845 && child.top().second == pnest)
850 child_name = child.empty() ? empty_string() : child.top().first;
852 if (contains(token, "file:line:error style messages enabled"))
855 //Handles both "LaTeX Warning:" & "Package natbib Warning:"
856 //Various handlers for missing citations below won't catch the problem if citation
857 //key is long (>~25chars), because pdflatex splits output at line length 80.
858 //TODO: TL 2020 engines will contain new commandline switch --cnf-line which we
859 //can use to set max_print_line variable for appropriate length and detect all
861 if (!runparams.includeall && (contains(token, "There were undefined citations.") ||
862 prefixIs(token, "Package biblatex Warning: The following entry could not be found")))
865 if (prefixIs(token, "LaTeX Warning:") ||
866 prefixIs(token, "! pdfTeX warning")) {
867 // Here shall we handle different
869 retval |= LATEX_WARNING;
870 LYXERR(Debug::LATEX, "LaTeX Warning.");
871 if (contains(token, "Rerun to get cross-references")) {
873 LYXERR(Debug::LATEX, "We should rerun.");
874 // package clefval needs 2 latex runs before bibtex
875 } else if (contains(token, "Value of")
876 && contains(token, "on page")
877 && contains(token, "undefined")) {
878 retval |= ERROR_RERUN;
879 LYXERR(Debug::LATEX, "Force rerun.");
881 } else if (contains(token, "Etaremune labels have changed")) {
882 retval |= ERROR_RERUN;
883 LYXERR(Debug::LATEX, "Force rerun.");
885 } else if (contains(token, "Endnotes may have changed. Rerun")) {
887 LYXERR(Debug::LATEX, "We should rerun.");
888 //"Citation `cit' on page X undefined on input line X."
889 } else if (!runparams.includeall && contains(token, "Citation")
890 //&& contains(token, "on input line") //often split to newline
891 && contains(token, "undefined")) {
893 terr.insertRef(getLineNumber(token), from_ascii("Citation undefined"),
894 from_utf8(token), child_name);
895 //"Reference `X' on page Y undefined on input line Z."
896 } else if (contains(token, "Reference")
897 //&& contains(token, "on input line")) //often split to new line
898 && contains(token, "undefined")) {
899 if (regex_match(token, sub, undef_ref)) {
900 string const ref = sub.str(1);
901 Buffer const * buf = theBufferList().getBufferFromTmp(file.absFileName());
902 if (!buf || !buf->masterBuffer()->activeLabel(from_utf8(ref))) {
903 terr.insertRef(getLineNumber(token), from_ascii("Reference undefined"),
904 from_utf8(token), child_name);
905 retval |= UNDEF_UNKNOWN_REF;
910 //If label is too long pdlaftex log line splitting will make the above fail
911 //so we catch at least this generic statement occuring for both CIT & REF.
912 } else if (!runparams.includeall && contains(token, "There were undefined references.")) {
913 if (!(retval & UNDEF_CIT)) { //if not handled already
914 if (regex_match(token, sub, undef_ref)) {
915 string const ref = sub.str(1);
916 Buffer const * buf = theBufferList().getBufferFromTmp(file.absFileName());
917 if (!buf || !buf->masterBuffer()->activeLabel(from_utf8(ref)))
918 retval |= UNDEF_UNKNOWN_REF;
924 } else if (prefixIs(token, "Package")) {
926 retval |= PACKAGE_WARNING;
927 if (contains(token, "natbib Warning:")) {
929 if (!runparams.includeall
930 && contains(token, "Citation")
931 && contains(token, "on page")
932 && contains(token, "undefined")) {
934 //Unf only keys up to ~6 chars will make it due to line splits
935 terr.insertRef(getLineNumber(token), from_ascii("Citation undefined"),
936 from_utf8(token), child_name);
938 } else if (!runparams.includeall && contains(token, "run BibTeX")) {
940 } else if (!runparams.includeall && contains(token, "run Biber")) {
943 } else if (contains(token, "Rerun LaTeX") ||
944 contains(token, "Please rerun LaTeX") ||
945 contains(token, "Rerun to get")) {
946 // at least longtable.sty and bibtopic.sty
948 LYXERR(Debug::LATEX, "We should rerun.");
951 } else if (prefixIs(token, "LETTRE WARNING:")) {
952 if (contains(token, "veuillez recompiler")) {
954 LYXERR(Debug::LATEX, "We should rerun.");
957 } else if (token[0] == '(') {
958 if (contains(token, "Rerun LaTeX") ||
959 contains(token, "Rerun to get")) {
961 LYXERR(Debug::LATEX, "We should rerun.");
964 } else if (prefixIs(token, "! ")
966 && regex_match(token, sub, file_line_error)
967 && !contains(token, "pdfTeX warning"))) {
968 // Ok, we have something that looks like a TeX Error
969 // but what do we really have.
971 // Just get the error description:
973 if (prefixIs(token, "! "))
974 desc = string(token, 2);
977 if (contains(token, "LaTeX Error:"))
978 retval |= LATEX_ERROR;
980 if (prefixIs(token, "! File ended while scanning")) {
981 if (prefixIs(token, "! File ended while scanning use of \\Hy@setref@link.")){
982 // bug 7344. We must rerun LaTeX if hyperref has been toggled.
983 retval |= ERROR_RERUN;
984 LYXERR(Debug::LATEX, "Force rerun.");
986 // bug 6445. At this point its not clear we finish with error.
987 wait_for_error = desc;
992 if (prefixIs(token, "! Incomplete \\if")) {
993 // bug 10666. At this point its not clear we finish with error.
994 wait_for_error = desc;
998 if (prefixIs(token, "! Paragraph ended before \\Hy@setref@link was complete.")){
999 // bug 7344. We must rerun LaTeX if hyperref has been toggled.
1000 retval |= ERROR_RERUN;
1001 LYXERR(Debug::LATEX, "Force rerun.");
1004 if (!wait_for_error.empty() && prefixIs(token, "! Emergency stop.")){
1005 retval |= LATEX_ERROR;
1008 errstr = wait_for_error;
1009 wait_for_error.clear();
1011 if (!getline(ifs, tmp))
1013 tmp = rtrim(tmp, "\r");
1014 errstr += "\n" + tmp;
1017 } while (!contains(tmp, "(job aborted"));
1020 from_ascii("Emergency stop"),
1021 from_local8bit(errstr),
1025 // get the next line
1028 if (!getline(ifs, tmp))
1030 tmp = rtrim(tmp, "\r");
1031 // 15 is somewhat arbitrarily chosen, based on practice.
1032 // We used 10 for 14 years and increased it to 15 when we
1036 } while (!prefixIs(tmp, "l."));
1037 if (prefixIs(tmp, "l.")) {
1038 // we have a latex error
1039 retval |= TEX_ERROR;
1041 "Package babel Error: You haven't defined the language")
1043 "Package babel Error: You haven't loaded the option")
1045 "Package babel Error: Unknown language"))
1046 retval |= ERROR_RERUN;
1047 // get the line number:
1049 sscanf(tmp.c_str(), "l.%d", &line);
1050 // get the rest of the message:
1051 string errstr(tmp, tmp.find(' '));
1054 tmp = rtrim(tmp, "\r");
1055 while (!contains(errstr, "l.")
1057 && !prefixIs(tmp, "! ")
1058 && !contains(tmp, "(job aborted")) {
1062 tmp = rtrim(tmp, "\r");
1064 LYXERR(Debug::LATEX, "line: " << line << '\n'
1065 << "Desc: " << desc << '\n' << "Text: " << errstr);
1066 if (line == last_line)
1072 if (line_count <= 5) {
1074 // We have no idea what the encoding of
1076 // It seems that the output from the
1077 // latex compiler itself is pure ASCII,
1078 // but it can include bits from the
1079 // document, so whatever encoding we
1080 // assume here it can be wrong.
1081 terr.insertError(line,
1082 from_local8bit(desc),
1083 from_local8bit(errstr),
1089 // information messages, TeX warnings and other
1090 // warnings we have not caught earlier.
1091 if (prefixIs(token, "Overfull ")) {
1092 retval |= TEX_WARNING;
1093 } else if (prefixIs(token, "Underfull ")) {
1094 retval |= TEX_WARNING;
1095 } else if (!runparams.includeall && contains(token, "Rerun to get citations")) {
1096 // Natbib seems to use this.
1097 retval |= UNDEF_CIT;
1098 } else if (contains(token, "No pages of output")
1099 || contains(token, "no pages of output")) {
1100 // No output file (e.g. the DVI or PDF) was created
1101 retval |= NO_OUTPUT;
1102 } else if (contains(token, "Error 256 (driver return code)")) {
1103 // This is a xdvipdfmx driver error reported by XeTeX.
1104 // We have to check whether an output PDF file was created.
1105 FileName pdffile = file;
1106 pdffile.changeExtension("pdf");
1107 if (!pdffile.exists())
1108 // No output PDF file was created (see #10076)
1109 retval |= NO_OUTPUT;
1110 } else if (contains(token, "That makes 100 errors")) {
1111 // More than 100 errors were reported
1112 retval |= TOO_MANY_ERRORS;
1113 } else if (prefixIs(token, "!pdfTeX error:")) {
1114 // otherwise we dont catch e.g.:
1115 // !pdfTeX error: pdflatex (file feyn10): Font feyn10 at 600 not found
1118 from_ascii("pdfTeX Error"),
1119 from_local8bit(token),
1121 } else if (!ignore_missing_glyphs
1122 && prefixIs(token, "Missing character: There is no ")
1123 && !contains(token, "nullfont")) {
1124 // Warning about missing glyph in selected font
1125 // may be dataloss (bug 9610)
1126 // but can be ignored for 'nullfont' (bug 10394).
1127 // as well as for ZERO WIDTH NON-JOINER (0x200C) which is
1128 // missing in many fonts and output for ligature break (bug 10727).
1129 // Since this error only occurs with utf8 output, we can safely assume
1130 // that the log file is utf8-encoded
1131 docstring const utoken = from_utf8(token);
1132 if (!contains(utoken, 0x200C)) {
1133 retval |= LATEX_ERROR;
1135 from_ascii("Missing glyphs!"),
1139 } else if (!wait_for_error.empty()) {
1140 // We collect information until we know we have an error.
1141 wait_for_error += token + '\n';
1145 LYXERR(Debug::LATEX, "Log line: " << token);
1152 bool insertIfExists(FileName const & absname, DepTable & head)
1154 if (absname.exists() && !absname.isDirectory()) {
1155 head.insert(absname, true);
1162 bool handleFoundFile(string const & ff, DepTable & head)
1164 // convert from native os path to unix path
1165 string foundfile = os::internal_path(trim(ff));
1167 LYXERR(Debug::DEPEND, "Found file: " << foundfile);
1169 // Ok now we found a file.
1170 // Now we should make sure that this is a file that we can
1171 // access through the normal paths.
1172 // We will not try any fancy search methods to
1175 // (1) foundfile is an
1176 // absolute path and should
1179 if (FileName::isAbsolute(foundfile)) {
1180 LYXERR(Debug::DEPEND, "AbsolutePath file: " << foundfile);
1181 // On initial insert we want to do the update at once
1182 // since this file cannot be a file generated by
1184 absname.set(foundfile);
1185 if (!insertIfExists(absname, head)) {
1187 string strippedfile = foundfile;
1188 while (contains(strippedfile, " ")) {
1189 // files with spaces are often enclosed in quotation
1190 // marks; those have to be removed
1191 string unquoted = subst(strippedfile, "\"", "");
1192 absname.set(unquoted);
1193 if (insertIfExists(absname, head))
1195 // strip off part after last space and try again
1196 string tmp = strippedfile;
1197 rsplit(tmp, strippedfile, ' ');
1198 absname.set(strippedfile);
1199 if (insertIfExists(absname, head))
1205 string onlyfile = onlyFileName(foundfile);
1206 absname = makeAbsPath(onlyfile);
1209 while (contains(foundfile, ' ')) {
1210 if (absname.exists())
1214 // files with spaces are often enclosed in quotation
1215 // marks; those have to be removed
1216 string unquoted = subst(foundfile, "\"", "");
1217 absname = makeAbsPath(unquoted);
1218 if (absname.exists())
1220 // strip off part after last space and try again
1221 string strippedfile;
1222 rsplit(foundfile, strippedfile, ' ');
1223 foundfile = strippedfile;
1224 onlyfile = onlyFileName(strippedfile);
1225 absname = makeAbsPath(onlyfile);
1229 // (2) foundfile is in the tmpdir
1230 // insert it into head
1231 if (absname.exists() && !absname.isDirectory()) {
1232 // FIXME: This regex contained glo, but glo is used by the old
1233 // version of nomencl.sty. Do we need to put it back?
1234 static regex const unwanted("^.*\\.(aux|log|dvi|bbl|ind)$");
1235 if (regex_match(onlyfile, unwanted)) {
1236 LYXERR(Debug::DEPEND, "We don't want " << onlyfile
1237 << " in the dep file");
1238 } else if (suffixIs(onlyfile, ".tex")) {
1239 // This is a tex file generated by LyX
1240 // and latex is not likely to change this
1242 LYXERR(Debug::DEPEND, "Tmpdir TeX file: " << onlyfile);
1243 head.insert(absname, true);
1245 LYXERR(Debug::DEPEND, "In tmpdir file:" << onlyfile);
1246 head.insert(absname);
1250 LYXERR(Debug::DEPEND, "Not a file or we are unable to find it.");
1256 bool completeFilename(string const & ff, DepTable & head)
1258 // If we do not find a dot, we suspect
1259 // a fragmental file name
1260 if (!contains(ff, '.'))
1263 // if we have a dot, we let handleFoundFile decide
1264 return handleFoundFile(ff, head);
1268 int iterateLine(string const & token, regex const & reg, string const & opening,
1269 string const & closing, int fragment_pos, DepTable & head)
1272 string::const_iterator first = token.begin();
1273 string::const_iterator end = token.end();
1274 bool fragment = false;
1277 while (regex_search(first, end, what, reg)) {
1278 // if we have a dot, try to handle as file
1279 if (contains(what.str(1), '.')) {
1280 first = what[0].second;
1281 if (what.str(2) == closing) {
1282 handleFoundFile(what.str(1), head);
1283 // since we had a closing bracket,
1284 // do not investigate further
1286 } else if (what.str(2) == opening) {
1287 // if we have another opening bracket,
1288 // we might have a nested file chain
1289 // as is (file.ext (subfile.ext))
1290 fragment = !handleFoundFile(rtrim(what.str(1)), head);
1291 // decrease first position by one in order to
1292 // consider the opening delimiter on next iteration
1293 if (first > token.begin())
1296 // if we have no closing bracket,
1297 // try to handle as file nevertheless
1298 fragment = !handleFoundFile(
1299 what.str(1) + what.str(2), head);
1301 // if we do not have a dot, check if the line has
1302 // a closing bracket (else, we suspect a line break)
1303 else if (what.str(2) != closing) {
1304 first = what[0].second;
1307 // we have a closing bracket, so the content
1308 // is not a file name.
1309 // no need to investigate further
1310 first = what[0].second;
1313 last_match = what.str(1);
1316 // We need to consider the result from previous line iterations:
1317 // We might not find a fragment here, but another one might follow
1318 // E.g.: (filename.ext) <filenam
1319 // Vice versa, we consider the search completed if a real match
1320 // follows a potential fragment from a previous iteration.
1321 // E.g. <some text we considered a fragment (filename.ext)
1322 // result = -1 means we did not find a fragment!
1324 int last_match_pos = -1;
1325 if (!last_match.empty() && token.find(last_match) != string::npos)
1326 last_match_pos = int(token.find(last_match));
1328 if (last_match_pos > fragment_pos)
1329 result = last_match_pos;
1331 result = fragment_pos;
1333 if (last_match_pos < fragment_pos)
1334 result = fragment_pos;
1342 void LaTeX::deplog(DepTable & head)
1344 // This function reads the LaTeX log file end extracts all the
1345 // external files used by the LaTeX run. The files are then
1346 // entered into the dependency file.
1348 string const logfile =
1349 onlyFileName(changeExtension(file.absFileName(), ".log"));
1351 static regex const reg1("File: (.+).*");
1352 static regex const reg2("No file (.+)(.).*");
1353 static regex const reg3a("\\\\openout[0-9]+.*=.*`(.+)(..).*");
1354 // LuaTeX has a slightly different output
1355 static regex const reg3b("\\\\openout[0-9]+.*=\\s*(.+)");
1356 // If an index should be created, MikTex does not write a line like
1357 // \openout# = 'sample.idx'.
1358 // but instead only a line like this into the log:
1359 // Writing index file sample.idx
1360 static regex const reg4("Writing index file (.+).*");
1361 static regex const regoldnomencl("Writing glossary file (.+).*");
1362 static regex const regnomencl(".*Writing nomenclature file (.+).*");
1363 // If a toc should be created, MikTex does not write a line like
1364 // \openout# = `sample.toc'.
1365 // but only a line like this into the log:
1367 // This line is also written by tetex.
1368 // This line is not present if no toc should be created.
1369 static regex const miktexTocReg("\\\\tf@toc=\\\\write.*");
1370 // file names can be enclosed in <...> (anywhere on the line)
1371 static regex const reg5(".*<[^>]+.*");
1372 // and also (...) anywhere on the line
1373 static regex const reg6(".*\\([^)]+.*");
1375 FileName const fn = makeAbsPath(logfile);
1376 ifstream ifs(fn.toFilesystemEncoding().c_str());
1379 // Ok, the scanning of files here is not sufficient.
1380 // Sometimes files are named by "File: xxx" only
1381 // Therefore we use some regexps to find files instead.
1382 // Note: all file names and paths might contains spaces.
1383 // Also, file names might be broken across lines. Therefore
1384 // we mark (potential) fragments and merge those lines.
1385 bool fragment = false;
1387 getline(ifs, token);
1388 // MikTeX sometimes inserts \0 in the log file. They can't be
1389 // removed directly with the existing string utility
1390 // functions, so convert them first to \r, and remove all
1391 // \r's afterwards, since we need to remove them anyway.
1392 token = subst(token, '\0', '\r');
1393 token = subst(token, "\r", "");
1394 if (token.empty() || token == ")") {
1395 lastline = string();
1399 // FIXME UNICODE: We assume that the file names in the log
1400 // file are in the file system encoding.
1401 token = to_utf8(from_filesystem8bit(token));
1403 // Sometimes, filenames are broken across lines.
1404 // We care for that and save suspicious lines.
1405 // Here we exclude some cases where we are sure
1406 // that there is no continued filename
1407 if (!lastline.empty()) {
1408 static regex const package_info("Package \\w+ Info: .*");
1409 static regex const package_warning("Package \\w+ Warning: .*");
1410 if (prefixIs(token, "File:") || prefixIs(token, "(Font)")
1411 || prefixIs(token, "Package:")
1412 || prefixIs(token, "Language:")
1413 || prefixIs(token, "LaTeX Info:")
1414 || prefixIs(token, "LaTeX Font Info:")
1415 || prefixIs(token, "\\openout[")
1416 || prefixIs(token, "))")
1417 || regex_match(token, package_info)
1418 || regex_match(token, package_warning))
1419 lastline = string();
1422 if (!lastline.empty())
1423 // probably a continued filename from last line
1424 token = lastline + token;
1425 if (token.length() > 255) {
1426 // string too long. Cut off.
1427 token.erase(0, token.length() - 251);
1432 // (1) "File: file.ext"
1433 if (regex_match(token, sub, reg1)) {
1434 // is this a fragmental file name?
1435 fragment = !completeFilename(sub.str(1), head);
1437 if (suffixIs(token, ")"))
1438 // no fragment for sure
1440 // (2) "No file file.ext"
1441 } else if (regex_match(token, sub, reg2)) {
1442 // file names must contains a dot, line ends with dot
1443 if (contains(sub.str(1), '.') && sub.str(2) == ".")
1444 fragment = !handleFoundFile(sub.str(1), head);
1446 // we suspect a line break
1448 // (3)(a) "\openout<nr> = `file.ext'."
1449 } else if (regex_match(token, sub, reg3a)) {
1450 // search for closing '. at the end of the line
1451 if (sub.str(2) == "\'.")
1452 fragment = !handleFoundFile(sub.str(1), head);
1454 // potential fragment
1456 // (3)(b) "\openout<nr> = file.ext" (LuaTeX)
1457 } else if (regex_match(token, sub, reg3b)) {
1458 // file names must contains a dot
1459 if (contains(sub.str(1), '.'))
1460 fragment = !handleFoundFile(sub.str(1), head);
1462 // potential fragment
1464 // (4) "Writing index file file.ext"
1465 } else if (regex_match(token, sub, reg4))
1466 // fragmential file name?
1467 fragment = !completeFilename(sub.str(1), head);
1468 // (5) "Writing nomenclature file file.ext"
1469 else if (regex_match(token, sub, regnomencl) ||
1470 regex_match(token, sub, regoldnomencl))
1471 // fragmental file name?
1472 fragment= !completeFilename(sub.str(1), head);
1473 // (6) "\tf@toc=\write<nr>" (for MikTeX)
1474 else if (regex_match(token, sub, miktexTocReg))
1475 fragment = !handleFoundFile(onlyFileName(changeExtension(
1476 file.absFileName(), ".toc")), head);
1478 // not found, but we won't check further
1481 int fragment_pos = -1;
1483 // We can have several of these on one line
1484 // (and in addition to those above)
1485 if (regex_match(token, sub, reg5)) {
1486 // search for strings in <...>
1487 static regex const reg5_1("<([^>]+)(.)");
1488 fragment_pos = iterateLine(token, reg5_1, "<", ">",
1489 fragment_pos, head);
1490 fragment = (fragment_pos != -1);
1494 // We can have several of these on one line
1495 // this must be queried separated, because of
1496 // cases such as "File: file.ext (type eps)"
1497 // where "File: file.ext" would be skipped
1498 if (regex_match(token, sub, reg6)) {
1499 // search for strings in (...)
1500 static regex const reg6_1("\\(([^()]+)(.)");
1501 fragment_pos = iterateLine(token, reg6_1, "(", ")",
1502 fragment_pos, head);
1503 fragment = (fragment_pos != -1);
1507 // probable linebreak within file name:
1511 // no linebreak: reset
1512 lastline = string();
1515 // Make sure that the main .tex file is in the dependency file.
1516 head.insert(file, true);
1520 int LaTeX::scanBlgFile(DepTable & dep, TeXErrors & terr)
1522 FileName const blg_file(changeExtension(file.absFileName(), "blg"));
1523 LYXERR(Debug::LATEX, "Scanning blg file: " << blg_file);
1525 ifstream ifs(blg_file.toFilesystemEncoding().c_str());
1527 static regex const reg1(".*Found (bibtex|BibTeX) data (file|source) '([^']+).*");
1528 static regex const bibtexError("^(.*---line [0-9]+ of file).*$");
1529 static regex const bibtexError2("^(.*---while reading file).*$");
1530 static regex const bibtexError3("(A bad cross reference---).*");
1531 static regex const bibtexError4("(Sorry---you've exceeded BibTeX's).*");
1532 static regex const bibtexError5("\\*Please notify the BibTeX maintainer\\*");
1533 static regex const biberError("^.*> (FATAL|ERROR) - (.*)$");
1534 int retval = NO_ERRORS;
1537 while (getline(ifs, token)) {
1538 token = rtrim(token, "\r");
1540 // FIXME UNICODE: We assume that citation keys and filenames
1541 // in the aux file are in the file system encoding.
1542 token = to_utf8(from_filesystem8bit(token));
1543 if (regex_match(token, sub, reg1)) {
1544 string data = sub.str(3);
1545 if (!data.empty()) {
1546 LYXERR(Debug::LATEX, "Found bib file: " << data);
1547 handleFoundFile(data, dep);
1550 else if (regex_match(token, sub, bibtexError)
1551 || regex_match(token, sub, bibtexError2)
1552 || regex_match(token, sub, bibtexError4)
1553 || regex_match(token, sub, bibtexError5)) {
1554 retval |= BIBTEX_ERROR;
1555 string errstr = N_("BibTeX error: ") + token;
1557 if ((prefixIs(token, "while executing---line")
1558 || prefixIs(token, "---line ")
1559 || prefixIs(token, "*Please notify the BibTeX"))
1560 && !prevtoken.empty()) {
1561 errstr = N_("BibTeX error: ") + prevtoken;
1562 msg = prevtoken + '\n';
1566 from_local8bit(errstr),
1567 from_local8bit(msg));
1568 } else if (regex_match(prevtoken, sub, bibtexError3)) {
1569 retval |= BIBTEX_ERROR;
1570 string errstr = N_("BibTeX error: ") + prevtoken;
1571 string msg = prevtoken + '\n' + token;
1573 from_local8bit(errstr),
1574 from_local8bit(msg));
1575 } else if (regex_match(token, sub, biberError)) {
1576 retval |= BIBTEX_ERROR;
1577 string errstr = N_("Biber error: ") + sub.str(2);
1580 from_local8bit(errstr),
1581 from_local8bit(msg));
1589 int LaTeX::scanIlgFile(TeXErrors & terr)
1591 FileName const ilg_file(changeExtension(file.absFileName(), "ilg"));
1592 LYXERR(Debug::LATEX, "Scanning ilg file: " << ilg_file);
1594 ifstream ifs(ilg_file.toFilesystemEncoding().c_str());
1596 int retval = NO_ERRORS;
1599 while (getline(ifs, token)) {
1600 token = rtrim(token, "\r");
1602 if (prefixIs(token, "!! "))
1604 else if (!prevtoken.empty()) {
1605 retval |= INDEX_ERROR;
1606 string errstr = N_("Makeindex error: ") + prevtoken;
1607 string msg = prevtoken + '\n';
1610 from_local8bit(errstr),
1611 from_local8bit(msg));
1613 } else if (prefixIs(token, "ERROR: ")) {
1614 retval |= BIBTEX_ERROR;
1615 string errstr = N_("Xindy error: ") + token.substr(6);
1618 from_local8bit(errstr),
1619 from_local8bit(msg));