The following patch (against 1.3.5cvs, but 1.4.0cvs should be similar
enough) fixes LaTeX::deplog in the following ways:

- when a file is found on a line, the rest of the line is parsed
nevertheless: useful for a line like
(file1.tex (file2.tex)

- when checking whether a file exists do not strip its path (why has
this ever been done?). This was breaking having files in different
directories

I am willing to commit that to 1.3 eventually, but of course I'd rather
have people comment on it. I will adapt it to HEAD.

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1021.2.31
diff -u -r1.1021.2.31 ChangeLog
--- src/ChangeLog       18 Apr 2004 15:35:59 -0000      1.1021.2.31
+++ src/ChangeLog       18 Apr 2004 21:00:54 -0000
@@ -1,3 +1,11 @@
+2004-04-18  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+       * LaTeX.C (deplog): when a regexp is triggered, do not junk the
+       rest of the line, but try to parse it in next round; this is
+       useful for lines like "(file1.tex) (file2.tex)", where file2.tex
+       would previously not be detected. Moreover, do not ignore the
+       path to files when testing for them.
+
 2003-02-12  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
        * buffer.C (makeLaTeXFile): if the main latex file that is
Index: src/LaTeX.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeX.C,v
retrieving revision 1.74.2.2
diff -u -r1.74.2.2 LaTeX.C
--- src/LaTeX.C 18 Apr 2004 11:21:21 -0000      1.74.2.2
+++ src/LaTeX.C 18 Apr 2004 21:00:55 -0000
@@ -684,54 +684,51 @@
 
        string const logfile = OnlyFilename(ChangeExtension(file, ".log"));
 
-       regex reg1("\\)* *\\(([^ )]+).*");
-       regex reg2("File: ([^ ]+).*");
-       regex reg3("No file ([^ ]+)\\..*");
-       regex reg4("\\\\openout[0-9]+.*=.*`([^ ]+)'\\..*");
-       // If an index should be created, MikTex does not write a line like
-       //    \openout# = 'sample,idx'.
-       // but intstead only a line like this into the log:
-       //   Writing index file sample.idx
-       regex reg5("Writing index file ([^ ]+).*");
+       // "(foo " or "(foo)"
+       regex reg1("\\)* *\\(([^ )]+)(.*)");
+       // "File: foo."
+       regex reg2("File: ([^ ]+)(.*)");
+       // "No file foo."
+       regex reg3("No file ([^ ]+)\\.(.*)");
+       // "openout0=`foo'."
+       regex reg4("\\\\openout[0-9]+.*=.*`([^ ]+)'\\.(.*)");
+       // "Writing index file foo" (for MikTeX)
+       regex reg5("Writing index file ([^ ]+)(.*)");
+       
        regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
 
        ifstream ifs(logfile.c_str());
-       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
-               // "File: \([^ ]+\)" should match the "File: file" variant
+       string token;
+       while (!token.empty() || ifs) {
                string foundfile;
-               string token;
-               getline(ifs, token);
-               token = rtrim(token, "\r");
-               if (token.empty()) continue;
-
+               if (token.empty()) {
+                       getline(ifs, token);
+                       token = rtrim(token, "\r");
+                       if (token.empty()) continue;
+               }
+               
 #ifndef USE_INCLUDED_STRING
                smatch sub;
 #else
                cmatch sub;
 #endif
-               if (regex_match(STRCONV(token), sub, reg1)) {
-                       foundfile = STRCONV(sub.str(1));
-               } else if (regex_match(STRCONV(token), sub, reg2)) {
-                       foundfile = STRCONV(sub.str(1));
-               } else if (regex_match(STRCONV(token), sub, reg3)) {
-                       foundfile = STRCONV(sub.str(1));
-               } else if (regex_match(STRCONV(token), sub, reg4)) {
-                       foundfile = STRCONV(sub.str(1));
-               } else if (regex_match(STRCONV(token), sub, reg5)) {
-                       foundfile = STRCONV(sub.str(1));
-               } else {
+               if (!regex_match(STRCONV(token), sub, reg1)
+                   && !regex_match(STRCONV(token), sub, reg2)
+                   && !regex_match(STRCONV(token), sub, reg3)
+                   && !regex_match(STRCONV(token), sub, reg4)
+                   && !regex_match(STRCONV(token), sub, reg5)) {
+                       token.erase();
                        continue;
                }
 
+               foundfile = STRCONV(sub.str(1));
+               token = STRCONV(sub.str(2));
+               
                // convert from native os path to unix path
                foundfile = os::internal_path(foundfile);
 
-               lyxerr[Debug::DEPEND] << "Found file: "
-                                     << foundfile << endl;
+               lyxerr[Debug::DEPEND] << "Found file: `"
+                                     << foundfile << '\'' << endl;
 
                // Ok now we found a file.
                // Now we should make sure that this is a file that we can
@@ -754,11 +751,11 @@
 
                // (2) foundfile is in the tmpdir
                //     insert it into head
-               else if (FileInfo(OnlyFilename(foundfile)).exist()) {
+               else if (FileInfo(foundfile).exist()) {
                        if (regex_match(STRCONV(foundfile), unwanted)) {
                                lyxerr[Debug::DEPEND]
                                        << "We don't want "
-                                       << OnlyFilename(foundfile)
+                                       << foundfile
                                        << " in the dep file"
                                        << endl;
                        } else if (suffixIs(foundfile, ".tex")) {
@@ -767,15 +764,15 @@
                                // during its runs.
                                lyxerr[Debug::DEPEND]
                                        << "Tmpdir TeX file: "
-                                       << OnlyFilename(foundfile)
+                                       << foundfile
                                        << endl;
                                head.insert(foundfile, true);
                        } else {
                                lyxerr[Debug::DEPEND]
                                        << "In tmpdir file:"
-                                       << OnlyFilename(foundfile)
+                                       << foundfile
                                        << endl;
-                               head.insert(OnlyFilename(foundfile));
+                               head.insert(foundfile);
                        }
                } else
                        lyxerr[Debug::DEPEND]
@@ -783,6 +780,6 @@
                                << endl;
        }
 
-       // Make sure that the main .tex file is in the dependancy file.
+       // Make sure that the main .tex file is in the dependency file.
        head.insert(OnlyFilename(file), true);
 }

Reply via email to