From f74cc0ec92d3591c16483cf230f37656f48eb83e Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Wed, 8 Nov 2023 16:17:58 +0100 Subject: [PATCH] Limit nomencl backwards support to case when old package is really used This is only needed for very old versions of the nomencl package (before March 2005) No need to output compatibility code with newer versions Furthermore, this breaks the use of the glossary package which also has .glo extension (#12968) --- lib/chkconfig.ltx | 2 +- src/LaTeX.cpp | 23 +++++++++++++++-------- src/LaTeXFeatures.cpp | 12 +++++++----- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 156fd06176..bde9d59e4b 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -369,7 +369,7 @@ \TestPackage{named} \TestPackage{natbib} \TestPackage{nicefrac} -\TestPackage{nomencl} +\TestPackageAddVersion{nomencl} \TestPackage{paralist} \TestPackage{parskip} \TestPackage{pdflscape} diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp index 3afe312d30..84141d8341 100644 --- a/src/LaTeX.cpp +++ b/src/LaTeX.cpp @@ -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")); @@ -315,8 +318,12 @@ int LaTeX::run(TeXErrors & terr) // 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()); - FileName const glofile(changeExtension(file.absFileName(), ".glo")); - bool const run_nomencl_glo = head.haschanged(glofile); + 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. diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 3d7a09b35e..20abc00c6c 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -1529,14 +1529,16 @@ string const LaTeXFeatures::getPackages() const "\\usepackage{ulem}\n"; if (mustProvide("nomencl")) { + packages << "\\usepackage{nomencl}\n"; // Make it work with the new and old version of the package, // but don't use the compatibility option since it is // incompatible to other packages. - packages << "\\usepackage{nomencl}\n" - "% the following is useful when we have the old nomencl.sty package\n" - "\\providecommand{\\printnomenclature}{\\printglossary}\n" - "\\providecommand{\\makenomenclature}{\\makeglossary}\n" - "\\makenomenclature\n"; + if (!LaTeXFeatures::isAvailableAtLeastFrom("nomencl", 2005, 3, 31)) { + packages << "% Needed with nomencl < v4.1\n" + "\\providecommand{\\printnomenclature}{\\printglossary}\n" + "\\providecommand{\\makenomenclature}{\\makeglossary}\n"; + } + packages << "\\makenomenclature\n"; } // fixltx2e provides subscript