]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeX.cpp
adjust
[lyx.git] / src / LaTeX.cpp
index cb922cc5a46e0fa5a7981cc3692d464f8cb3784d..d326630c6dac154c8a08536c5084b1beadecb93b 100644 (file)
@@ -26,7 +26,7 @@
 #include "support/convert.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
-#include "support/systemcall.h"
+#include "support/Systemcall.h"
 #include "support/os.h"
 
 #include <boost/filesystem/operations.hpp>
 
 #include <fstream>
 
+using boost::regex;
+using boost::smatch;
+
+#ifndef CXX_GLOBAL_CSTD
+using std::sscanf;
+#endif
+
+using std::endl;
+using std::getline;
+using std::string;
+using std::ifstream;
+using std::set;
+using std::vector;
+
 
 namespace lyx {
 
@@ -62,21 +76,6 @@ using support::trim;
 namespace os = support::os;
 namespace fs = boost::filesystem;
 
-using boost::regex;
-using boost::smatch;
-
-
-#ifndef CXX_GLOBAL_CSTD
-using std::sscanf;
-#endif
-
-using std::endl;
-using std::getline;
-using std::string;
-using std::ifstream;
-using std::set;
-using std::vector;
-
 // TODO: in no particular order
 // - get rid of the call to
 //   BufferList::updateIncludedTeXfiles, this should either
@@ -229,7 +228,7 @@ int LaTeX::run(TeXErrors & terr)
                head.update();
                // Can't just check if anything has changed because it might
                // have aborted on error last time... in which cas we need
-               // to re-run latex and collect the error messages 
+               // to re-run latex and collect the error messages
                // (even if they are the same).
                if (!fs::exists(output_file.toFilesystemEncoding())) {
                        LYXERR(Debug::DEPEND)
@@ -293,7 +292,7 @@ int LaTeX::run(TeXErrors & terr)
        // A second latex run is needed.
        FileName const idxfile(changeExtension(file.absFilename(), ".idx"));
        rerun = fs::exists(idxfile.toFilesystemEncoding()) &&
-               fs::is_empty(idxfile.toFilesystemEncoding());
+               fs::is_empty(idxfile.toFilesystemEncoding());
 
        // run makeindex
        if (head.haschanged(idxfile)) {
@@ -438,13 +437,13 @@ int LaTeX::startscript()
 
 
 bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams,
-                         string const & params)
+                        string const & params)
 {
        LYXERR(Debug::LATEX)
                << "idx file has been made, running makeindex on file "
                << f << endl;
        string tmp = lyxrc.index_command + ' ';
-       
+
        tmp = subst(tmp, "$$lang", runparams.document_language);
        tmp += quoteName(f);
        tmp += params;
@@ -611,6 +610,8 @@ int LaTeX::scanLogFile(TeXErrors & terr)
        LYXERR(Debug::LATEX) << "Log file: " << tmp << endl;
        FileName const fn = FileName(makeAbsPath(tmp));
        ifstream ifs(fn.toFilesystemEncoding().c_str());
+       bool fle_style = false;
+       static regex file_line_error(".+\\.\\D+:[0-9]+: (.+)");
 
        string token;
        while (getline(ifs, token)) {
@@ -620,12 +621,16 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                // \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
@@ -669,12 +674,17 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                        << "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
@@ -690,7 +700,9 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                // we have a latex error
                                retval |=  TEX_ERROR;
                                if (contains(desc,
-                                   "Package babel Error: You haven't defined the language"))
+                                   "Package babel Error: You haven't defined the language") ||
+                                   contains(desc,
+                                   "Package babel Error: You haven't loaded the option"))
                                        retval |= ERROR_RERUN;
                                // get the line number:
                                int line = 0;
@@ -965,7 +977,7 @@ void LaTeX::deplog(DepTable & head)
 
                // Sometimes, filenames are broken across lines.
                // We care for that and save suspicious lines.
-               // Here we exclude some cases where we are sure 
+               // Here we exclude some cases where we are sure
                // that there is no continued filename
                if (!lastline.empty()) {
                        static regex package_info("Package \\w+ Info: .*");
@@ -1035,7 +1047,7 @@ void LaTeX::deplog(DepTable & head)
                                found_file = false;
                // (6) "Writing nomenclature file file.ext"
                } else if (regex_match(token, sub, regnomencl) ||
-                          regex_match(token, sub, regoldnomencl))
+                          regex_match(token, sub, regoldnomencl))
                        // check for dot
                        found_file = checkLineBreak(sub.str(1), head);
                // (7) "\tf@toc=\write<nr>" (for MikTeX)