Both tex and pdflatex have an option -file-line-error that produces error 
messages in a style that isn't known to LyX so far and thus isn't parsed 
correctly.* It seems that some distributions have turned that option on by 
default. As a consequence, LyX doesn't report any error messages when using 
such a distribution.

Such a case is documented in bug 4222:
http://bugzilla.lyx.org/show_bug.cgi?id=4222

Attached is a patch (against branch) that attempts to check for 
file-line-error-style messages, if this style is enabled (which is indicated 
in the log file). It works for me, but as I'm not very familiar with regex in 
general, please tell me if the regex could be improved. The message style we 
are looking for is:
filename.tex:<line nr.>: <error message>

If there are no objections, I'd like to put this in branch and trunk.

Jürgen

* from the tex man page:
"-file-line-error: Print error messages in the form file:line:error which is 
similar to the way many compilers format them."
Index: src/LaTeX.cpp
===================================================================
--- src/LaTeX.cpp	(Revision 20319)
+++ src/LaTeX.cpp	(Arbeitskopie)
@@ -610,6 +610,8 @@
 	LYXERR(Debug::LATEX) << "Log file: " << tmp << endl;
 	FileName const fn = FileName(makeAbsPath(tmp));
 	ifstream ifs(fn.toFilesystemEncoding().c_str());
+	bool fle_style;
+	static regex file_line_error(".+\\.\\D+:[0-9]+: (.+)");
 
 	string token;
 	while (getline(ifs, token)) {
@@ -619,12 +621,16 @@
 		// \r's afterwards, since we need to remove them anyway.
 		token = subst(token, '\0', '\r');
 		token = subst(token, "\r", "");
+		smatch sub;
 
 		LYXERR(Debug::LATEX) << "Log line: " << token << endl;
 
 		if (token.empty())
 			continue;
 
+		if (contains(token, "file:line:error style messages enabled"))
+			fle_style = true;
+
 		if (prefixIs(token, "LaTeX Warning:") ||
 		    prefixIs(token, "! pdfTeX warning")) {
 			// Here shall we handle different
@@ -668,12 +674,17 @@
 					<< "We should rerun." << endl;
 				retval |= RERUN;
 			}
-		} else if (prefixIs(token, "! ")) {
-			// Ok, we have something that looks like a TeX Error
-			// but what do we really have.
+		} else if (prefixIs(token, "! ") ||
+			   fle_style && regex_match(token, sub, file_line_error)) {
+			   // Ok, we have something that looks like a TeX Error
+			   // but what do we really have.
 
 			// Just get the error description:
-			string desc(token, 2);
+			string desc;
+			if (prefixIs(token, "! "))
+				desc = string(token, 2);
+			else if (fle_style)
+				desc = sub.str();
 			if (contains(token, "LaTeX Error:"))
 				retval |= LATEX_ERROR;
 			// get the next line

Reply via email to