]> git.lyx.org Git - features.git/commitdiff
Report makeindex/xindy errors
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 15 Dec 2019 12:48:21 +0000 (13:48 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:47 +0000 (15:48 +0200)
Fixes #2569

lib/configure.py
src/LaTeX.cpp
src/LaTeX.h
src/frontends/qt/GuiLog.cpp

index 9e6db09d99723ee7b14abcd5e2468b60402df0e8..24e10e578021beb616089b2bee32d7a96dc787fe 100644 (file)
@@ -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',
index 3ac59b71fddc96c1d970fcb02058c8d36b73fa41..fb5af54e7b3142dc27ac65d4caf7ad1a9ae8320b 100644 (file)
@@ -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
index ba088bb5cceed9afa352e26049a677a4558e3215..4899cd6bd8cbe0c7289616ec9fac18b9960df039 100644 (file)
@@ -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<AuxInfo> const &,
                       OutputParams const &, int & exit_code);
index 81c05d3a70c0e5ad6200e6487d5b0867088bdae2..341f06c8ce81085e6e0ffd9b963b002b47c2cc54 100644 (file)
@@ -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 ).*$");
 
 
 /////////////////////////////////////////////////////////////////////