]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeX.cpp
Amend 207eaeee9071cb
[lyx.git] / src / LaTeX.cpp
index 7d9810aef1a8b22e147c8d571191ec98145ae693..84141d83416d0f040440a86878f17ac908bf1cdd 100644 (file)
@@ -25,6 +25,7 @@
 #include "DepTable.h"
 #include "Encoding.h"
 #include "Language.h"
+#include "LaTeXFeatures.h"
 
 #include "support/debug.h"
 #include "support/docstring.h"
@@ -160,12 +161,14 @@ void LaTeX::removeAuxiliaryFiles() const
        ind.removeFile();
 
        // nomencl file
-       FileName const nls(changeExtension(file.absFileName(), ".nls"));
-       nls.removeFile();
-
-       // nomencl file (old version of the package)
-       FileName const gls(changeExtension(file.absFileName(), ".gls"));
-       gls.removeFile();
+       if (LaTeXFeatures::isAvailableAtLeastFrom("nomencl", 2005, 3, 31)) {
+               FileName const nls(changeExtension(file.absFileName(), ".nls"));
+               nls.removeFile();
+       } else if (LaTeXFeatures::isAvailable("nomencl")) {
+               // nomencl file (old version of the package up to v. 4.0)
+               FileName const gls(changeExtension(file.absFileName(), ".gls"));
+               gls.removeFile();
+       }
 
        // endnotes file
        FileName const ent(changeExtension(file.absFileName(), ".ent"));
@@ -305,6 +308,23 @@ int LaTeX::run(TeXErrors & terr)
        deplog(head); // reads the latex log
        head.update();
 
+       // Record here (after the first LaTeX run) whether nomencl aux files exist
+       // and have changed.
+       // The programs itself are then launched later after the pagination has settled.
+       FileName const nlofile(changeExtension(file.absFileName(), ".nlo"));
+       // If all nomencl entries are removed, nomencl writes an empty nlo file.
+       // DepTable::hasChanged() returns false in this case, since it does not
+       // distinguish empty files from non-existing files. This is why we need
+       // the extra checks here (to trigger a rerun). Cf. discussions in #8905.
+       // FIXME: Sort out the real problem in DepTable.
+       bool const run_nomencl = head.haschanged(nlofile) || (nlofile.exists() && nlofile.isFileEmpty());
+       bool run_nomencl_glo = false;
+       if (!LaTeXFeatures::isAvailableAtLeastFrom("nomencl", 2005, 3, 31)) {
+               // nomencl package up to v4.0
+               FileName const glofile(changeExtension(file.absFileName(), ".glo"));
+               run_nomencl_glo = head.haschanged(glofile);
+       }
+
        // 1
        // At this point we must run the bibliography processor if needed.
        // First, check if we're using biber instead of bibtex --
@@ -446,20 +466,13 @@ int LaTeX::run(TeXErrors & terr)
                        iscanres = scanIlgFile(terr);
                rerun = true;
        }
-       FileName const nlofile(changeExtension(file.absFileName(), ".nlo"));
-       // If all nomencl entries are removed, nomencl writes an empty nlo file.
-       // DepTable::hasChanged() returns false in this case, since it does not
-       // distinguish empty files from non-existing files. This is why we need
-       // the extra checks here (to trigger a rerun). Cf. discussions in #8905.
-       // FIXME: Sort out the real problem in DepTable.
-       if (head.haschanged(nlofile) || (nlofile.exists() && nlofile.isFileEmpty())) {
+       if (run_nomencl) {
                int const ret = runMakeIndexNomencl(file, ".nlo", ".nls");
                if (ret == Systemcall::KILLED || ret == Systemcall::TIMEOUT)
                        return ret;
                rerun = true;
        }
-       FileName const glofile(changeExtension(file.absFileName(), ".glo"));
-       if (head.haschanged(glofile)) {
+       if (run_nomencl_glo) {
                int const ret = runMakeIndexNomencl(file, ".glo", ".gls");
                if (ret)
                        return ret;