]> git.lyx.org Git - features.git/commitdiff
Fix child document regex in scanLogFile
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 9 Feb 2018 10:42:18 +0000 (11:42 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 10 Feb 2018 06:59:30 +0000 (07:59 +0100)
Several problems:
* The regex failed at names such as 1_text_2_text.tex
  (returned "2_text.tex)
* The regex failed at names such as 12_text.tex
  (returned "2_text.tex)
* Masters with digits in the name (2018_text.tex) were
  tracked as their own children

(cherry picked from commit 398e026250f6d7d1687bdf04a8a27a61946d088f)

src/LaTeX.cpp

index 10540642b1ac652f487393cac17720e219dfd7cb..753d1966e0f5ab7c03395c37b1ce5be245944d38 100644 (file)
@@ -657,7 +657,7 @@ int LaTeX::scanLogFile(TeXErrors & terr)
        ifstream ifs(fn.toFilesystemEncoding().c_str());
        bool fle_style = false;
        static regex const file_line_error(".+\\.\\D+:[0-9]+: (.+)");
-       static regex const child_file(".*([0-9]+[A-Za-z]*_.+\\.tex).*");
+       static regex const child_file("[^0-9]*([0-9]+[A-Za-z]*_.+\\.tex).*");
        // Flag for 'File ended while scanning' message.
        // We need to wait for subsequent processing.
        string wait_for_error;
@@ -692,8 +692,12 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                string const substr = token.substr(i + 1, len);
                                if (regex_match(substr, sub, child_file)) {
                                        string const name = sub.str(1);
-                                       child.push(make_pair(name, pnest));
-                                       children.push_back(name);
+                                       // Sometimes also masters have a name that matches
+                                       // (if their name starts with a number and _)
+                                       if (name != file.onlyFileName()) {
+                                               child.push(make_pair(name, pnest));
+                                               children.push_back(name);
+                                       }
                                        i += len;
                                }
                        } else if (token[i] == ')') {