mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
Support log parsing for multi-line warnings wrt undefined references
This commit is contained in:
parent
037b1e1478
commit
bb277747d2
@ -807,6 +807,7 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
terr.clearRefs();
|
terr.clearRefs();
|
||||||
|
|
||||||
string token;
|
string token;
|
||||||
|
string ml_token;
|
||||||
while (getline(ifs, token)) {
|
while (getline(ifs, token)) {
|
||||||
// MikTeX sometimes inserts \0 in the log file. They can't be
|
// MikTeX sometimes inserts \0 in the log file. They can't be
|
||||||
// removed directly with the existing string utility
|
// removed directly with the existing string utility
|
||||||
@ -821,6 +822,9 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
if (token.empty())
|
if (token.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!ml_token.empty())
|
||||||
|
ml_token += token;
|
||||||
|
|
||||||
// Track child documents
|
// Track child documents
|
||||||
for (size_t i = 0; i < token.length(); ++i) {
|
for (size_t i = 0; i < token.length(); ++i) {
|
||||||
if (token[i] == '(') {
|
if (token[i] == '(') {
|
||||||
@ -862,8 +866,10 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
prefixIs(token, "Package biblatex Warning: The following entry could not be found")))
|
prefixIs(token, "Package biblatex Warning: The following entry could not be found")))
|
||||||
retval |= UNDEF_CIT;
|
retval |= UNDEF_CIT;
|
||||||
|
|
||||||
if (prefixIs(token, "LaTeX Warning:") ||
|
if (prefixIs(token, "LaTeX Warning:")
|
||||||
prefixIs(token, "! pdfTeX warning")) {
|
|| prefixIs(token, "! pdfTeX warning")
|
||||||
|
|| prefixIs(ml_token, "LaTeX Warning:")
|
||||||
|
|| prefixIs(ml_token, "! pdfTeX warning")) {
|
||||||
// Here shall we handle different
|
// Here shall we handle different
|
||||||
// types of warnings
|
// types of warnings
|
||||||
retval |= LATEX_WARNING;
|
retval |= LATEX_WARNING;
|
||||||
@ -893,8 +899,37 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
terr.insertRef(getLineNumber(token), from_ascii("Citation undefined"),
|
terr.insertRef(getLineNumber(token), from_ascii("Citation undefined"),
|
||||||
from_utf8(token), child_name);
|
from_utf8(token), child_name);
|
||||||
//"Reference `X' on page Y undefined on input line Z."
|
//"Reference `X' on page Y undefined on input line Z."
|
||||||
} else if (contains(token, "Reference")
|
// This warning might be broken accross multiple lines with long labels.
|
||||||
//&& contains(token, "on input line")) //often split to new line
|
// Thus we check that
|
||||||
|
} else if (contains(token, "Reference `") && !contains(token, "on input line")) {
|
||||||
|
// Rest of warning in next line(s)
|
||||||
|
// Save to ml_token
|
||||||
|
ml_token = token;
|
||||||
|
} else if (!ml_token.empty() && contains(ml_token, "Reference `")
|
||||||
|
&& !contains(ml_token, "on input line")) {
|
||||||
|
// not finished yet. Continue with next line.
|
||||||
|
continue;
|
||||||
|
} else if (!ml_token.empty() && contains(ml_token, "Reference `")
|
||||||
|
&& contains(ml_token, "on input line")) {
|
||||||
|
// We have collected the whole warning now.
|
||||||
|
if (!contains(ml_token, "undefined")) {
|
||||||
|
// Not the warning we are looking for
|
||||||
|
ml_token.clear();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (regex_match(ml_token, sub, undef_ref)) {
|
||||||
|
string const ref = sub.str(1);
|
||||||
|
Buffer const * buf = theBufferList().getBufferFromTmp(file.absFileName());
|
||||||
|
if (!buf || !buf->masterBuffer()->activeLabel(from_utf8(ref))) {
|
||||||
|
terr.insertRef(getLineNumber(ml_token), from_ascii("Reference undefined"),
|
||||||
|
from_utf8(ml_token), child_name);
|
||||||
|
retval |= UNDEF_UNKNOWN_REF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ml_token.clear();
|
||||||
|
retval |= UNDEF_REF;
|
||||||
|
} else if (contains(token, "Reference `")
|
||||||
|
&& contains(token, "on input line")
|
||||||
&& contains(token, "undefined")) {
|
&& contains(token, "undefined")) {
|
||||||
if (regex_match(token, sub, undef_ref)) {
|
if (regex_match(token, sub, undef_ref)) {
|
||||||
string const ref = sub.str(1);
|
string const ref = sub.str(1);
|
||||||
@ -906,9 +941,8 @@ int LaTeX::scanLogFile(TeXErrors & terr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
retval |= UNDEF_REF;
|
retval |= UNDEF_REF;
|
||||||
|
// In case the above checks fail we catch at least this generic statement
|
||||||
//If label is too long pdlaftex log line splitting will make the above fail
|
// occuring for both CIT & REF.
|
||||||
//so we catch at least this generic statement occuring for both CIT & REF.
|
|
||||||
} else if (!runparams.includeall && contains(token, "There were undefined references.")) {
|
} else if (!runparams.includeall && contains(token, "There were undefined references.")) {
|
||||||
if (!(retval & UNDEF_CIT)) //if not handled already
|
if (!(retval & UNDEF_CIT)) //if not handled already
|
||||||
retval |= UNDEF_REF;
|
retval |= UNDEF_REF;
|
||||||
|
Loading…
Reference in New Issue
Block a user