diff --git a/src/Converter.cpp b/src/Converter.cpp index 77aef9ef72..cb98b44194 100644 --- a/src/Converter.cpp +++ b/src/Converter.cpp @@ -875,7 +875,7 @@ Converters::RetVal Converters::runLaTeX(Buffer const & buffer, string const & co if (result & LaTeX::ERRORS) buffer.bufferErrors(terr, errorList); - if ((result & LaTeX::UNDEF_CIT) || (result & LaTeX::UNDEF_REF)) { + if ((result & LaTeX::UNDEF_CIT) || (result & LaTeX::UNDEF_UNKNOWN_REF)) { buffer.bufferRefs(terr, errorList); if (errorList.empty()) errorList.push_back(ErrorItem(_("Undefined reference"), @@ -913,7 +913,7 @@ Converters::RetVal Converters::runLaTeX(Buffer const & buffer, string const & co LaTeX::NO_LOGFILE | LaTeX::ERRORS | LaTeX::UNDEF_CIT | - LaTeX::UNDEF_REF | + LaTeX::UNDEF_UNKNOWN_REF | LaTeX::NO_OUTPUT; return (result & ERROR_MASK) == 0 ? SUCCESS : FAILURE; diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp index a7b39037fb..0401e64ca5 100644 --- a/src/LaTeX.cpp +++ b/src/LaTeX.cpp @@ -795,6 +795,7 @@ int LaTeX::scanLogFile(TeXErrors & terr) bool fle_style = false; static regex const file_line_error(".+\\.\\D+:[0-9]+: (.+)"); static regex const child_file("[^0-9]*([0-9]+[A-Za-z]*_.+\\.tex).*"); + static regex const undef_ref(".*Reference `(\\w+)\\' on page.*"); // Flag for 'File ended while scanning' message. // We need to wait for subsequent processing. string wait_for_error; @@ -895,15 +896,29 @@ int LaTeX::scanLogFile(TeXErrors & terr) } else if (contains(token, "Reference") //&& contains(token, "on input line")) //often split to new line && contains(token, "undefined")) { + if (regex_match(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(token), from_ascii("Reference undefined"), + from_utf8(token), child_name); + retval |= UNDEF_UNKNOWN_REF; + } + } retval |= UNDEF_REF; - terr.insertRef(getLineNumber(token), from_ascii("Reference undefined"), - from_utf8(token), child_name); //If label is too long pdlaftex log line splitting will make the above fail //so we catch at least this generic statement occuring for both CIT & REF. } else if (!runparams.includeall && contains(token, "There were undefined references.")) { - if (!(retval & UNDEF_CIT)) //if not handled already - retval |= UNDEF_REF; + if (!(retval & UNDEF_CIT)) { //if not handled already + if (regex_match(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))) + retval |= UNDEF_UNKNOWN_REF; + } + retval |= UNDEF_REF; + } } } else if (prefixIs(token, "Package")) { diff --git a/src/LaTeX.h b/src/LaTeX.h index 4899cd6bd8..b76ec1fd42 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -155,6 +155,8 @@ public: /// INDEX_ERROR = 65536, /// + UNDEF_UNKNOWN_REF = 131072, + /// ERRORS = TEX_ERROR + LATEX_ERROR + NONZERO_ERROR + BIBTEX_ERROR + INDEX_ERROR, /// WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING