]> git.lyx.org Git - features.git/commitdiff
make the nomencl inset work with older versions of nomencl.sty
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 23 Apr 2007 18:33:36 +0000 (18:33 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 23 Apr 2007 18:33:36 +0000 (18:33 +0000)
* src/LaTeXFeatures.C
(LaTeXFeatures::getPackages): Do not require newest nomencl.sty,
output compatibility code instead

* src/LaTeX.C
(LaTeX::deleteFilesOnError): delete .gls file
(LaTeX::run): Check .glo and .gls files, too
(handleFoundFile): do not ignore .glo files
(LaTeX::deplog): add regex for old nomencl version

* src/LaTeX.[Ch]
(LaTeX::runMakeIndexNomencl) new method, factored out to avoid
code duplication

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17923 a592a061-630c-0410-9148-cb99ea01b6c8

src/LaTeX.C
src/LaTeX.h
src/LaTeXFeatures.C

index ab6c9539832a3ec8d7a8a3652c5462144415cc30..29a7d6b2dbe42f9a84a9a41b117bb89f52524367 100644 (file)
@@ -168,6 +168,10 @@ void LaTeX::deleteFilesOnError() const
        FileName const nls(changeExtension(file.absFilename(), ".nls"));
        unlink(nls);
 
+       // nomencl file (old version of the package)
+       FileName const gls(changeExtension(file.absFilename(), ".gls"));
+       unlink(gls);
+
        // Also remove the aux file
        FileName const aux(changeExtension(file.absFilename(), ".aux"));
        unlink(aux);
@@ -300,20 +304,12 @@ int LaTeX::run(TeXErrors & terr)
                rerun |= runMakeIndex(onlyFilename(idxfile.absFilename()),
                                runparams);
        }
-       if (head.haschanged(FileName(changeExtension(file.absFilename(), ".nlo")))) {
-               LYXERR(Debug::LATEX) 
-                       << "Running MakeIndex for nomencl."
-                       << endl;
-               message(_("Running MakeIndex for nomencl."));
-               // onlyFilename() is needed for cygwin
-               string const nomenclstr = " -s nomencl.ist -o " 
-                       + onlyFilename(changeExtension(
-                               file.toFilesystemEncoding(), ".nls"));
-               rerun |= runMakeIndex(onlyFilename(changeExtension(
-                               file.absFilename(), ".nlo")),
-                               runparams,
-                               nomenclstr);
-       }
+       FileName const nlofile(changeExtension(file.absFilename(), ".nlo"));
+       if (head.haschanged(nlofile))
+               rerun |= runMakeIndexNomencl(file, runparams, ".nlo", ".nls");
+       FileName const glofile(changeExtension(file.absFilename(), ".glo"));
+       if (head.haschanged(glofile))
+               rerun |= runMakeIndexNomencl(file, runparams, ".glo", ".gls");
 
        // run bibtex
        // if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex)
@@ -379,7 +375,7 @@ int LaTeX::run(TeXErrors & terr)
        // more after this.
 
        // run makeindex if the <file>.idx has changed or was generated.
-       if (head.haschanged(FileName(changeExtension(file.absFilename(), ".idx")))) {
+       if (head.haschanged(idxfile)) {
                // no checks for now
                LYXERR(Debug::LATEX) << "Running MakeIndex." << endl;
                message(_("Running MakeIndex."));
@@ -389,20 +385,10 @@ int LaTeX::run(TeXErrors & terr)
        }
 
        // I am not pretty sure if need this twice.
-       if (head.haschanged(FileName(changeExtension(file.absFilename(), ".nlo")))) {
-               LYXERR(Debug::LATEX) 
-                       << "Running MakeIndex for nomencl."
-                       << endl;
-               message(_("Running MakeIndex for nomencl."));
-               // onlyFilename() is needed for cygwin
-               string nomenclstr = " -s nomencl.ist -o " 
-                       + onlyFilename(changeExtension(
-                               file.toFilesystemEncoding(), ".nls"));
-               rerun |= runMakeIndex(onlyFilename(changeExtension(
-                               file.absFilename(), ".nlo")),
-                               runparams,
-                               nomenclstr);
-       }
+       if (head.haschanged(nlofile))
+               rerun |= runMakeIndexNomencl(file, runparams, ".nlo", ".nls");
+       if (head.haschanged(glofile))
+               rerun |= runMakeIndexNomencl(file, runparams, ".glo", ".gls");
 
        // 2
        // we will only run latex more if the log file asks for it.
@@ -468,6 +454,21 @@ bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams,
 }
 
 
+bool LaTeX::runMakeIndexNomencl(FileName const & file,
+               OutputParams const & runparams,
+               string const & nlo, string const & nls)
+{
+       LYXERR(Debug::LATEX) << "Running MakeIndex for nomencl." << endl;
+       message(_("Running MakeIndex for nomencl."));
+       // onlyFilename() is needed for cygwin
+       string const nomenclstr = " -s nomencl.ist -o "
+               + onlyFilename(changeExtension(file.toFilesystemEncoding(), nls));
+       return runMakeIndex(
+                       onlyFilename(changeExtension(file.absFilename(), nlo)),
+                       runparams, nomenclstr);
+}
+
+
 vector<Aux_Info> const
 LaTeX::scanAuxFiles(FileName const & file)
 {
@@ -862,7 +863,9 @@ bool handleFoundFile(string const & ff, DepTable & head)
        //     insert it into head
        if (exists(absname) &&
            !fs::is_directory(absname.toFilesystemEncoding())) {
-               static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
+               // FIXME: This regex contained glo, but glo is used by the old
+               // version of nomencl.sty. Do we need to put it back?
+               static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind)$");
                if (regex_match(onlyfile, unwanted)) {
                        LYXERR(Debug::DEPEND)
                                << "We don't want "
@@ -927,6 +930,7 @@ void LaTeX::deplog(DepTable & head)
        static regex reg4("Writing index file (.+).*");
        // files also can be enclosed in <...>
        static regex reg5("<([^>]+)(.).*");
+       static regex regoldnomencl("Writing glossary file (.+).*");
        static regex regnomencl("Writing nomenclature file (.+).*");
        // If a toc should be created, MikTex does not write a line like
        //    \openout# = `sample.toc'.
@@ -1030,7 +1034,8 @@ void LaTeX::deplog(DepTable & head)
                                // probable line break
                                found_file = false;
                // (6) "Writing nomenclature file file.ext"
-               } else if (regex_match(token, sub, regnomencl))
+               } else if (regex_match(token, sub, regnomencl) ||
+                          regex_match(token, sub, regoldnomencl))
                        // check for dot
                        found_file = checkLineBreak(sub.str(1), head);
                // (7) "\tf@toc=\write<nr>" (for MikTeX)
index bc310ec1db5d6d1d493f86d086e121d371365c67..821aa0f5b893b22a21f976f44123d238578a7765 100644 (file)
@@ -171,6 +171,10 @@ private:
        bool runMakeIndex(std::string const &, OutputParams const &,
                          std::string const & = std::string());
 
+       ///
+       bool runMakeIndexNomencl(support::FileName const &, OutputParams const &,
+                                std::string const &, std::string const &);
+
        ///
        std::vector<Aux_Info> const scanAuxFiles(support::FileName const &);
 
index 185ac193a44d0a70522283f61b45096ef48fc26d..8736b111c5d7968fa8c43549a1ef3ce4c7545c97 100644 (file)
@@ -404,8 +404,14 @@ string const LaTeXFeatures::getPackages() const
                packages << "\\usepackage[all]{xy}\n";
 
        if (mustProvide("nomencl")) {
-               packages << "\\usepackage{nomencl}[2005/09/22]\n"
-                        << "\\makenomenclature\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";
        }
  
        return packages.str();