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
This commit is contained in:
Pavel Sanda 2010-03-17 13:56:59 +00:00
parent 1fc1652f10
commit a0aabe4ed9

View File

@ -598,6 +598,9 @@ int LaTeX::scanLogFile(TeXErrors & terr)
ifstream ifs(fn.toFilesystemEncoding().c_str()); ifstream ifs(fn.toFilesystemEncoding().c_str());
bool fle_style = false; bool fle_style = false;
static regex file_line_error(".+\\.\\D+:[0-9]+: (.+)"); 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; string token;
while (getline(ifs, token)) { while (getline(ifs, token)) {
@ -684,6 +687,30 @@ int LaTeX::scanLogFile(TeXErrors & terr)
desc = sub.str(); desc = sub.str();
if (contains(token, "LaTeX Error:")) if (contains(token, "LaTeX Error:"))
retval |= 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 // get the next line
string tmp; string tmp;
int count = 0; int count = 0;