[LyX/master] Report makeindex/xindy errors

Juergen Spitzmueller spitz at lyx.org
Sun Dec 15 12:32:41 UTC 2019


commit 239dee34af43a2a18fee148cfd45e3602a993bcb
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sun Dec 15 13:48:21 2019 +0100

    Report makeindex/xindy errors
    
    Fixes #2569
---
 lib/configure.py            |    2 +-
 src/LaTeX.cpp               |   55 ++++++++++++++++++++++++++++++++++++++++++-
 src/LaTeX.h                 |    7 ++++-
 src/frontends/qt/GuiLog.cpp |    4 +-
 4 files changed, 63 insertions(+), 5 deletions(-)

diff --git a/lib/configure.py b/lib/configure.py
index 9e6db09..24e10e5 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 3ac59b7..fb5af54 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 ba088bb..4899cd6 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
 	};
@@ -226,6 +228,9 @@ private:
 	int scanBlgFile(DepTable & head, TeXErrors & terr);
 
 	///
+	int scanIlgFile(TeXErrors & terr);
+
+	///
 	bool runBibTeX(std::vector<AuxInfo> const &,
 		       OutputParams const &, int & exit_code);
 
diff --git a/src/frontends/qt/GuiLog.cpp b/src/frontends/qt/GuiLog.cpp
index 81c05d3..341f06c 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 ).*$");
 
 
 /////////////////////////////////////////////////////////////////////


More information about the lyx-cvs mailing list