From a0aabe4ed94320f51dbeaa867d72554d5b3ece6d Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Wed, 17 Mar 2010 13:56:59 +0000 Subject: [PATCH] Fix bug 6445: Incorrect TEX code causes misleading "File does not exist" error on "View PDF" git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33789 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LaTeX.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp index 375d5fb985..7abe021106 100644 --- a/src/LaTeX.cpp +++ b/src/LaTeX.cpp @@ -598,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)) { @@ -684,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; -- 2.39.2