From: Juergen Spitzmueller Date: Sun, 15 Dec 2019 12:48:21 +0000 (+0100) Subject: Report makeindex/xindy errors X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=12af558e3b9bf49612c7ba965ed3932d5251c5bc;p=features.git Report makeindex/xindy errors Fixes #2569 --- diff --git a/lib/configure.py b/lib/configure.py index 9e6db09d99..24e10e5780 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -1238,7 +1238,7 @@ def checkOtherEntries(): rc_entry = [ r'\jbibtex_command "automatic"' ], alt_rc_entry = [ r'\jbibtex_alternatives "%%"' ]) checkProgAlternatives('available index processors', - ['texindy $$x', 'makeindex -c -q', 'xindy $$x'], + ['texindy $$x -t $$b.ilg', 'makeindex -c -q', 'xindy $$x -t $$b.ilg'], rc_entry = [ r'\index_command "%%"' ], alt_rc_entry = [ r'\index_alternatives "%%"' ]) checkProg('an index processor appropriate to Japanese', diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp index 3ac59b71fd..fb5af54e7b 100644 --- a/src/LaTeX.cpp +++ b/src/LaTeX.cpp @@ -188,6 +188,7 @@ int LaTeX::run(TeXErrors & terr) { int scanres = NO_ERRORS; int bscanres = NO_ERRORS; + int iscanres = NO_ERRORS; unsigned int count = 0; // number of times run num_errors = 0; // just to make sure. unsigned int const MAX_RUN = 6; @@ -302,6 +303,9 @@ int LaTeX::run(TeXErrors & terr) runMakeIndex(onlyFileName(idxfile.absFileName()), runparams); if (ret == Systemcall::KILLED) return Systemcall::KILLED; + FileName const ilgfile(changeExtension(file.absFileName(), ".ilg")); + if (ilgfile.exists()) + iscanres = scanIlgFile(terr); rerun = true; } @@ -426,7 +430,10 @@ int LaTeX::run(TeXErrors & terr) file.absFileName(), ".idx")), runparams); if (ret == Systemcall::KILLED) return Systemcall::KILLED; - rerun = true; + FileName const ilgfile(changeExtension(file.absFileName(), ".ilg")); + if (ilgfile.exists()) + iscanres = scanIlgFile(terr); + rerun = true; } // MSVC complains that bool |= int is unsafe. Not sure why. @@ -475,6 +482,9 @@ int LaTeX::run(TeXErrors & terr) if (bscanres & ERRORS) return bscanres; // return on error + if (iscanres & ERRORS) + return iscanres; // return on error + return scanres; } @@ -516,6 +526,11 @@ int LaTeX::runMakeIndex(string const & f, OutputParams const & rp, tmp = subst(tmp, "$$x", xdyopts); } + if (contains(tmp, "$$b")) { + // advise xindy to write a log file + tmp = subst(tmp, "$$b", removeExtension(f)); + } + LYXERR(Debug::LATEX, "idx file has been made, running index processor (" << tmp << ") on file " << f); @@ -1510,4 +1525,42 @@ int LaTeX::scanBlgFile(DepTable & dep, TeXErrors & terr) } +int LaTeX::scanIlgFile(TeXErrors & terr) +{ + FileName const ilg_file(changeExtension(file.absFileName(), "ilg")); + LYXERR(Debug::LATEX, "Scanning ilg file: " << ilg_file); + + ifstream ifs(ilg_file.toFilesystemEncoding().c_str()); + string token; + int retval = NO_ERRORS; + + string prevtoken; + while (getline(ifs, token)) { + token = rtrim(token, "\r"); + smatch sub; + if (prefixIs(token, "!! ")) + prevtoken = token; + else if (!prevtoken.empty()) { + retval |= INDEX_ERROR; + string errstr = N_("Makeindex error: ") + prevtoken; + string msg = prevtoken + '\n'; + msg += token; + terr.insertError(0, + from_local8bit(errstr), + from_local8bit(msg)); + prevtoken.clear(); + } else if (prefixIs(token, "ERROR: ")) { + retval |= BIBTEX_ERROR; + string errstr = N_("Xindy error: ") + token.substr(6); + string msg = token; + terr.insertError(0, + from_local8bit(errstr), + from_local8bit(msg)); + } + } + return retval; +} + + + } // namespace lyx diff --git a/src/LaTeX.h b/src/LaTeX.h index ba088bb5cc..4899cd6bd8 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -153,7 +153,9 @@ public: /// NONZERO_ERROR = 32768, // the command exited with nonzero status /// - ERRORS = TEX_ERROR + LATEX_ERROR + NONZERO_ERROR + BIBTEX_ERROR, + INDEX_ERROR = 65536, + /// + ERRORS = TEX_ERROR + LATEX_ERROR + NONZERO_ERROR + BIBTEX_ERROR + INDEX_ERROR, /// WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING }; @@ -225,6 +227,9 @@ private: /// int scanBlgFile(DepTable & head, TeXErrors & terr); + /// + int scanIlgFile(TeXErrors & terr); + /// bool runBibTeX(std::vector const &, OutputParams const &, int & exit_code); diff --git a/src/frontends/qt/GuiLog.cpp b/src/frontends/qt/GuiLog.cpp index 81c05d3a70..341f06c8ce 100644 --- a/src/frontends/qt/GuiLog.cpp +++ b/src/frontends/qt/GuiLog.cpp @@ -47,9 +47,9 @@ namespace frontend { // Information QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$"); // Warnings -QRegExp exprWarning("^(LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$"); +QRegExp exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$"); // Errors -QRegExp exprError("^(!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$"); +QRegExp exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$"); /////////////////////////////////////////////////////////////////////