]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeX.cpp
CaMeLbUmP all function names, private or not.
[lyx.git] / src / LaTeX.cpp
index 3569ba87f5d3cf6cb240c938863ad50fae6fcbbe..db2037f8d2f4edeca588dfc09aa257998ad40f2d 100644 (file)
@@ -50,8 +50,6 @@ namespace os = support::os;
 //   different way.
 // - the makeindex style files should be taken care of with
 //   the dependency mechanism.
-// - makeindex commandline options should be supported
-// - somewhere support viewing of bibtex and makeindex log files.
 // - we should perhaps also scan the bibtex log file
 
 namespace {
@@ -148,7 +146,7 @@ int LaTeX::run(TeXErrors & terr)
        // We know that this function will only be run if the lyx buffer
        // has been changed. We also know that a newly written .tex file
        // is always different from the previous one because of the date
-       // in it. However it seems safe to run latex (at least) on time
+       // in it. However it seems safe to run latex (at least) one time
        // each time the .tex file changes.
 {
        int scanres = NO_ERRORS;
@@ -245,7 +243,7 @@ int LaTeX::run(TeXErrors & terr)
        deplog(head); // reads the latex log
        head.update();
 
-       // 0.5
+       // 1
        // At this point we must run external programs if needed.
        // makeindex will be run if a .idx file changed or was generated.
        // And if there were undefined citations or changes in references
@@ -283,7 +281,7 @@ int LaTeX::run(TeXErrors & terr)
                LYXERR(Debug::LATEX, "Running BibTeX.");
                message(_("Running BibTeX."));
                updateBibtexDependencies(head, bibtex_info);
-               rerun |= runBibTeX(bibtex_info);
+               rerun |= runBibTeX(bibtex_info, runparams);
        } else if (!had_depfile) {
                /// If we run pdflatex on the file after running latex on it,
                /// then we do not need to run bibtex, but we do need to
@@ -291,7 +289,7 @@ int LaTeX::run(TeXErrors & terr)
                updateBibtexDependencies(head, bibtex_info);
        }
 
-       // 1
+       // 2
        // we know on this point that latex has been run once (or we just
        // returned) and the question now is to decide if we need to run
        // it any more. This is done by asking if any of the files in the
@@ -301,7 +299,7 @@ int LaTeX::run(TeXErrors & terr)
        //             run latex once more and
        //             update the dependency structure
        //     -> if not changed:
-       //             we does nothing at this point
+       //             we do nothing at this point
        //
        if (rerun || head.sumchange()) {
                rerun = false;
@@ -322,9 +320,24 @@ int LaTeX::run(TeXErrors & terr)
        } else {
                LYXERR(Debug::DEPEND, "Dep. file has NOT changed");
        }
+       
+       // 3
+       // rerun bibtex?
+       // Complex bibliography packages such as Biblatex require
+       // an additional bibtex cycle sometimes.
+       if (scanres & UNDEF_CIT) {
+               // Here we must scan the .aux file and look for
+               // "\bibdata" and/or "\bibstyle". If one of those
+               // tags is found -> run bibtex and set rerun = true;
+               // no checks for now
+               LYXERR(Debug::LATEX, "Running BibTeX.");
+               message(_("Running BibTeX."));
+               updateBibtexDependencies(head, bibtex_info);
+               rerun |= runBibTeX(bibtex_info, runparams);
+       }
 
-       // 1.5
-       // The inclusion of files generated by external programs like
+       // 4
+       // The inclusion of files generated by external programs such as
        // makeindex or bibtex might have done changes to pagenumbering,
        // etc. And because of this we must run the external programs
        // again to make sure everything is redone correctly.
@@ -347,7 +360,7 @@ int LaTeX::run(TeXErrors & terr)
        if (head.haschanged(glofile))
                rerun |= runMakeIndexNomencl(file, ".glo", ".gls");
 
-       // 2
+       // 5
        // we will only run latex more if the log file asks for it.
        // or if the sumchange() is true.
        //     -> rerun asked for:
@@ -397,11 +410,23 @@ int LaTeX::startscript()
 bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams,
                         string const & params)
 {
+       string tmp = runparams.use_japanese ?
+               lyxrc.jindex_command : lyxrc.index_command;
+       
+       if (!runparams.index_command.empty())
+               tmp = runparams.index_command;
+
        LYXERR(Debug::LATEX,
-               "idx file has been made, running makeindex on file " << f);
-       string tmp = lyxrc.index_command + ' ';
+               "idx file has been made, running index processor ("
+               << tmp << ") on file " << f);
 
        tmp = subst(tmp, "$$lang", runparams.document_language);
+       if (runparams.use_indices) {
+               tmp = lyxrc.splitindex_command + " -m " + quoteName(tmp);
+               LYXERR(Debug::LATEX,
+               "Multiple indices. Using splitindex command: " << tmp);
+       }
+       tmp += ' ';
        tmp += quoteName(f);
        tmp += params;
        Systemcall one;
@@ -534,7 +559,8 @@ void LaTeX::updateBibtexDependencies(DepTable & dep,
 }
 
 
-bool LaTeX::runBibTeX(vector<AuxInfo> const & bibtex_info)
+bool LaTeX::runBibTeX(vector<AuxInfo> const & bibtex_info,
+                     OutputParams const & runparams)
 {
        bool result = false;
        for (vector<AuxInfo>::const_iterator it = bibtex_info.begin();
@@ -543,7 +569,12 @@ bool LaTeX::runBibTeX(vector<AuxInfo> const & bibtex_info)
                        continue;
                result = true;
 
-               string tmp = lyxrc.bibtex_command + " ";
+               string tmp = runparams.use_japanese ?
+                       lyxrc.jbibtex_command : lyxrc.bibtex_command;
+
+               if (!runparams.bibtex_command.empty())
+                       tmp = runparams.bibtex_command;
+               tmp += " ";
                // onlyFilename() is needed for cygwin
                tmp += quoteName(onlyFilename(removeExtension(
                                it->aux_file.absFilename())));
@@ -625,6 +656,12 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                LYXERR(Debug::LATEX, "We should rerun.");
                                retval |= RERUN;
                        }
+               } else if (prefixIs(token, "LETTRE WARNING:")) {
+                       if (contains(token, "veuillez recompiler")) {
+                               // lettre.cls
+                               LYXERR(Debug::LATEX, "We should rerun.");
+                               retval |= RERUN;
+                       }
                } else if (token[0] == '(') {
                        if (contains(token, "Rerun LaTeX") ||
                            contains(token, "Rerun to get")) {
@@ -633,7 +670,9 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                retval |= RERUN;
                        }
                } else if (prefixIs(token, "! ")
-                           || (fle_style && regex_match(token, sub, file_line_error))) {
+                           || (fle_style
+                               && regex_match(token, sub, file_line_error)
+                               && !contains(token, "pdfTeX warning"))) {
                           // Ok, we have something that looks like a TeX Error
                           // but what do we really have.
 
@@ -752,12 +791,13 @@ bool handleFoundFile(string const & ff, DepTable & head)
        // (1) foundfile is an
        //     absolute path and should
        //     be inserted.
-       FileName absname(foundfile);
-       if (absname.isAbsolute()) {
+       FileName absname;
+       if (FileName::isAbsolute(foundfile)) {
                LYXERR(Debug::DEPEND, "AbsolutePath file: " << foundfile);
                // On initial insert we want to do the update at once
                // since this file cannot be a file generated by
                // the latex run.
+               absname.set(foundfile);
                if (!insertIfExists(absname, head)) {
                        // check for spaces
                        string strippedfile = foundfile;
@@ -986,7 +1026,7 @@ void LaTeX::deplog(DepTable & head)
                // where "File: file.ext" would be skipped
                if (regex_match(token, sub, reg6)) {
                        // search for strings in (...)
-                       static regex reg6_1("\\(([^()]+)(.).*");
+                       static regex reg6_1("\\(([^()]+)(.)");
                        smatch what;
                        string::const_iterator first = token.begin();
                        string::const_iterator end = token.end();