Angus Leeming <[EMAIL PROTECTED]> writes:

> > I'll try to come up with a patch to the LaTeX::deplog() function in
> > src/LaTeX.C.
> 
> Way to go!

;-)

Here is the patch. Please test, it works for me. The only drawback which
I can foresee is that a file *may* be passed two times to handleFoundFile()
but I think it is better than before, when a file could be missed.

-- 
Enrico


--- src/LaTeX.C.orig    2006-03-14 05:04:34.000000000 +0100
+++ src/LaTeX.C 2006-03-16 19:29:24.000000000 +0100
@@ -688,7 +688,7 @@
                // On initial insert we want to do the update at once
                // since this file can not be a file generated by
                // the latex run.
-               if (fs::exists(foundfile))
+               if (fs::exists(foundfile) && !fs::is_directory(foundfile))
                        head.insert(foundfile, true);
 
                return;
@@ -750,20 +750,30 @@
        static regex reg5("Writing index file ([^ ]+).*");
 
        ifstream ifs(logfile.c_str());
+       string line1, line2 = "";
        while (ifs) {
                // Ok, the scanning of files here is not sufficient.
                // Sometimes files are named by "File: xxx" only
                // So I think we should use some regexps to find files instead.
                // "(\([^ ]+\)"   should match the "(file " variant, note
                // that we can have several of these on one line.
-               // "File: \([^ ]+\)" should match the "File: file" variant
-
-               string token;
-               getline(ifs, token);
-               token = rtrim(token, "\r");
-               if (token.empty())
+               // "File: \([^ ]+\)" should match the "File: file" variant.
+               // As a path name may be split across lines, we use a sliding
+               // window comprising two lines at a time while scanning files.
+
+               line1 = line2;
+               getline(ifs, line2);
+               line2 = rtrim(line2, "\r");
+               const int len = line2.length();
+               const char endchar = len ? line2[len - 1] : 0;
+               if (line1.empty()
+                   || line2.substr(0,8) == "Package:"
+                   || line2.substr(0,5) == "File:"
+                   || line2.substr(0,9) == "Language:"
+                   || endchar == '\\' || endchar == '/' || endchar == ')')
                        continue;
 
+               string token = line1 + line2;
                smatch sub;
 
                if (regex_match(token, sub, reg1)) {


Reply via email to