]> git.lyx.org Git - features.git/blobdiff - src/LaTeX.cpp
Remove an outdated comment
[features.git] / src / LaTeX.cpp
index 22a3a97d465022849fc0568923f635344a4b57d0..22e32d35c33569fe20d647cefb6e55350b9eedf9 100644 (file)
@@ -110,8 +110,6 @@ LaTeX::LaTeX(string const & latex, OutputParams const & rp,
 
 void LaTeX::deleteFilesOnError() const
 {
-       // currently just a dummy function.
-
        // What files do we have to delete?
 
        // This will at least make latex do all the runs
@@ -142,6 +140,9 @@ void LaTeX::deleteFilesOnError() const
        // Also remove the aux file
        FileName const aux(changeExtension(file.absFileName(), ".aux"));
        aux.removeFile();
+
+       // Remove the output file, which is often generated even if error
+       output_file.removeFile();
 }
 
 
@@ -268,7 +269,12 @@ int LaTeX::run(TeXErrors & terr)
                                runparams);
        }
        FileName const nlofile(changeExtension(file.absFileName(), ".nlo"));
-       if (head.haschanged(nlofile))
+       // 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()))
                rerun |= runMakeIndexNomencl(file, ".nlo", ".nls");
        FileName const glofile(changeExtension(file.absFileName(), ".glo"));
        if (head.haschanged(glofile))
@@ -416,6 +422,15 @@ int LaTeX::run(TeXErrors & terr)
 
        // Write the dependencies to file.
        head.write(depfile);
+       if (scanres & NO_OUTPUT) {
+               // A previous run could have left a PDF and since
+               // no PDF is created if NO_OUTPUT, we remove any
+               // existing PDF and temporary files so that an
+               // incorrect PDF is not displayed, which could otherwise
+               // happen if View is run again because the checksum will
+               // be the same so any lingering PDF will be viewed.
+               deleteFilesOnError();
+       }
        LYXERR(Debug::LATEX, "Done.");
        return scanres;
 }
@@ -629,8 +644,8 @@ int LaTeX::scanLogFile(TeXErrors & terr)
        FileName const fn = FileName(makeAbsPath(tmp));
        ifstream ifs(fn.toFilesystemEncoding().c_str());
        bool fle_style = false;
-       static regex file_line_error(".+\\.\\D+:[0-9]+: (.+)");
-       static regex child_file(".*([0-9]+[A-Za-z]*_.+\\.tex).*");
+       static regex const file_line_error(".+\\.\\D+:[0-9]+: (.+)");
+       static regex const child_file(".*([0-9]+[A-Za-z]*_.+\\.tex).*");
        // Flag for 'File ended while scanning' message.
        // We need to wait for subsequent processing.
        string wait_for_error;
@@ -661,8 +676,8 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                size_t len = j == string::npos
                                                ? token.substr(i + 1).length()
                                                : j - i - 1;
-                               if (regex_match(token.substr(i + 1, len),
-                                                       sub, child_file)) {
+                               string const substr = token.substr(i + 1, len);
+                               if (regex_match(substr, sub, child_file)) {
                                        string const name = sub.str(1);
                                        child.push(make_pair(name, pnest));
                                        i += len;
@@ -811,9 +826,11 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                // we have a latex error
                                retval |=  TEX_ERROR;
                                if (contains(desc,
-                                   "Package babel Error: You haven't defined the language") ||
-                                   contains(desc,
-                                   "Package babel Error: You haven't loaded the option"))
+                                       "Package babel Error: You haven't defined the language")
+                                   || contains(desc,
+                                       "Package babel Error: You haven't loaded the option")
+                                   || contains(desc,
+                                       "Package babel Error: Unknown language"))
                                        retval |= ERROR_RERUN;
                                // get the line number:
                                int line = 0;
@@ -1008,7 +1025,7 @@ bool completeFilename(string const & ff, DepTable & head)
 }
 
 
-int iterateLine(string const token, regex const reg, string const & closing,
+int iterateLine(string const & token, regex const & reg, string const & closing,
                int fragment_pos, DepTable & head)
 {
        smatch what;
@@ -1208,7 +1225,7 @@ void LaTeX::deplog(DepTable & head)
                // (and in addition to those above)
                if (regex_match(token, sub, reg5)) {
                        // search for strings in <...>
-                       static regex reg5_1("<([^>]+)(.)");
+                       static regex const reg5_1("<([^>]+)(.)");
                        fragment_pos = iterateLine(token, reg5_1, ">",
                                                   fragment_pos, head);
                        fragment = (fragment_pos != -1);
@@ -1221,7 +1238,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 const reg6_1("\\(([^()]+)(.)");
                        fragment_pos = iterateLine(token, reg6_1, ")",
                                                   fragment_pos, head);
                        fragment = (fragment_pos != -1);