]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeX.cpp
A little more lv cleanup.
[lyx.git] / src / LaTeX.cpp
index b8a3d1a7833eb22609e0cb93ac47ae93e5839373..7abe021106b96067ebd450886216217655a7ac3a 100644 (file)
@@ -50,7 +50,6 @@ namespace os = support::os;
 //   different way.
 // - the makeindex style files should be taken care of with
 //   the dependency mechanism.
-// - somewhere support viewing of bibtex and makeindex log files.
 // - we should perhaps also scan the bibtex log file
 
 namespace {
@@ -147,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;
@@ -599,6 +598,9 @@ int LaTeX::scanLogFile(TeXErrors & terr)
        ifstream ifs(fn.toFilesystemEncoding().c_str());
        bool fle_style = false;
        static regex file_line_error(".+\\.\\D+:[0-9]+: (.+)");
+       // Flag for 'File ended while scanning' message.
+       // We need to wait for subsequent processing.
+       string wait_for_error;
 
        string token;
        while (getline(ifs, token)) {
@@ -671,7 +673,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.
 
@@ -683,6 +687,30 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                desc = sub.str();
                        if (contains(token, "LaTeX Error:"))
                                retval |= LATEX_ERROR;
+
+                       // bug 6445. At this point its not clear we finish with error.
+                       if (prefixIs(token, "! File ended while scanning")){
+                               wait_for_error = desc;
+                               continue;
+                       }
+                       if (!wait_for_error.empty() && prefixIs(token, "! Emergency stop.")){
+                               retval |= LATEX_ERROR;
+                               string errstr;
+                               int count = 0;
+                               errstr = wait_for_error;
+                               do {
+                                       if (!getline(ifs, tmp))
+                                               break;
+                                       errstr += "\n" + tmp;
+                                       if (++count > 5)
+                                               break;
+                               } while (!contains(tmp, "(job aborted"));
+
+                               terr.insertError(0,
+                                                from_local8bit("Emergency stop"),
+                                                from_local8bit(errstr));
+                       }
+
                        // get the next line
                        string tmp;
                        int count = 0;
@@ -754,6 +782,13 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                        } else if (contains(token, "That makes 100 errors")) {
                                // More than 100 errors were reprted
                                retval |= TOO_MANY_ERRORS;
+                       } else if (prefixIs(token, "!pdfTeX error:")){
+                               // otherwise we dont catch e.g.:
+                               // !pdfTeX error: pdflatex (file feyn10): Font feyn10 at 600 not found
+                               retval |= ERRORS;
+                                       terr.insertError(0,
+                                                        from_local8bit("pdfTeX Error"),
+                                                        from_local8bit(token));
                        }
                }
        }