]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeX.C
cleanup after svn hang-up, #undef CursorShape. Should be compilable ganin now.
[lyx.git] / src / LaTeX.C
index 90092a7cf9b782b795053e8542fa4da1094685eb..2fd28a03881006ac98b73cdf23c9c2ec1da6a266 100644 (file)
@@ -49,6 +49,8 @@ using lyx::support::Systemcall;
 using lyx::support::unlink;
 using lyx::support::trim;
 
+using lyx::docstring;
+
 namespace os = lyx::support::os;
 namespace fs = boost::filesystem;
 
@@ -82,7 +84,7 @@ extern BufferList bufferlist;
 
 namespace {
 
-string runMessage(unsigned int count)
+docstring runMessage(unsigned int count)
 {
        return bformat(_("Waiting for LaTeX run number %1$d"), count);
 }
@@ -269,12 +271,17 @@ int LaTeX::run(TeXErrors & terr)
        // the .aux file is checked for signs of bibtex. Bibtex is then run
        // if needed.
 
+       // memoir (at least) writes an empty *idx file in the first place.
+       // A second latex run is needed.
+       rerun = fs::exists(changeExtension(file, ".idx"))
+               && fs::is_empty(changeExtension(file, ".idx"));
+
        // run makeindex
        if (head.haschanged(onlyFilename(changeExtension(file, ".idx")))) {
                // no checks for now
                lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
                message(_("Running MakeIndex."));
-               rerun = runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams);
+               rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams);
        }
 
        // run bibtex
@@ -331,7 +338,7 @@ int LaTeX::run(TeXErrors & terr)
 
        // 1.5
        // The inclusion of files generated by external programs like
-       // makeindex or bibtex might have done changes to pagenumbereing,
+       // 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.
        // Also there should be no need to run the external programs any
@@ -751,10 +758,17 @@ void LaTeX::deplog(DepTable & head)
        static regex reg3("No file ([^ ]+)\\..*");
        static regex reg4("\\\\openout[0-9]+.*=.*`([^ ]+)'\\..*");
        // If an index should be created, MikTex does not write a line like
-       //    \openout# = 'sample,idx'.
-       // but intstead only a line like this into the log:
+       //    \openout# = 'sample.idx'.
+       // but instead only a line like this into the log:
        //   Writing index file sample.idx
        static regex reg5("Writing index file ([^ ]+).*");
+       // If a toc should be created, MikTex does not write a line like
+       //    \openout# = `sample.toc'.
+       // but only a line like this into the log:
+       //    \tf@toc=\write#
+       // This line is also written by tetex.
+       // This line is not present if no toc should be created.
+       static regex miktexTocReg("\\\\tf@toc=\\\\write.*");
 
        ifstream ifs(logfile.c_str());
        while (ifs) {
@@ -788,15 +802,16 @@ void LaTeX::deplog(DepTable & head)
                                first = what[0].second;
                                handleFoundFile(what.str(1), head);
                        }
-               } else if (regex_match(token, sub, reg2)) {
+               } else if (regex_match(token, sub, reg2))
                        handleFoundFile(sub.str(1), head);
-               } else if (regex_match(token, sub, reg3)) {
+               else if (regex_match(token, sub, reg3))
                        handleFoundFile(sub.str(1), head);
-               } else if (regex_match(token, sub, reg4)) {
+               else if (regex_match(token, sub, reg4))
                        handleFoundFile(sub.str(1), head);
-               } else if (regex_match(token, sub, reg5)) {
+               else if (regex_match(token, sub, reg5))
                        handleFoundFile(sub.str(1), head);
-               }
+               else if (regex_match(token, sub, miktexTocReg))
+                       handleFoundFile(changeExtension(file, ".toc"), head);
        }
 
        // Make sure that the main .tex file is in the dependancy file.