mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Improve reporting of undefined control sequences in preamble
Fixes #11844
This commit is contained in:
parent
3f89dd0b48
commit
05c7c65d93
@ -1051,10 +1051,15 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
|
|
||||||
// get the next line
|
// get the next line
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
// We also collect intermediate lines
|
||||||
|
// This is needed for errors in preamble
|
||||||
|
string intermediate;
|
||||||
do {
|
do {
|
||||||
if (!getline(ifs, tmp))
|
if (!getline(ifs, tmp))
|
||||||
break;
|
break;
|
||||||
tmp = rtrim(tmp, "\r");
|
tmp = rtrim(tmp, "\r");
|
||||||
|
if (!prefixIs(tmp, "l."))
|
||||||
|
intermediate += tmp;
|
||||||
// 15 is somewhat arbitrarily chosen, based on practice.
|
// 15 is somewhat arbitrarily chosen, based on practice.
|
||||||
// We used 10 for 14 years and increased it to 15 when we
|
// We used 10 for 14 years and increased it to 15 when we
|
||||||
// saw one case.
|
// saw one case.
|
||||||
@ -1076,6 +1081,15 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
sscanf(tmp.c_str(), "l.%d", &line);
|
sscanf(tmp.c_str(), "l.%d", &line);
|
||||||
// get the rest of the message:
|
// get the rest of the message:
|
||||||
string errstr(tmp, tmp.find(' '));
|
string errstr(tmp, tmp.find(' '));
|
||||||
|
bool preamble_error = false;
|
||||||
|
if (suffixIs(errstr, "\\begin{document}")) {
|
||||||
|
// this is an error in preamble
|
||||||
|
// the real error is in the
|
||||||
|
// intermediate lines
|
||||||
|
errstr = intermediate;
|
||||||
|
tmp = intermediate;
|
||||||
|
preamble_error = true;
|
||||||
|
}
|
||||||
errstr += '\n';
|
errstr += '\n';
|
||||||
getline(ifs, tmp);
|
getline(ifs, tmp);
|
||||||
tmp = rtrim(tmp, "\r");
|
tmp = rtrim(tmp, "\r");
|
||||||
@ -1088,6 +1102,9 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
getline(ifs, tmp);
|
getline(ifs, tmp);
|
||||||
tmp = rtrim(tmp, "\r");
|
tmp = rtrim(tmp, "\r");
|
||||||
}
|
}
|
||||||
|
if (preamble_error)
|
||||||
|
// Add a note that the error is to be found in preamble
|
||||||
|
errstr += "\n" + to_utf8(_("(NOTE: The erroneous command is in the preamble)"));
|
||||||
LYXERR(Debug::LATEX, "line: " << line << '\n'
|
LYXERR(Debug::LATEX, "line: " << line << '\n'
|
||||||
<< "Desc: " << desc << '\n' << "Text: " << errstr);
|
<< "Desc: " << desc << '\n' << "Text: " << errstr);
|
||||||
if (line == last_line)
|
if (line == last_line)
|
||||||
|
Loading…
Reference in New Issue
Block a user