]> git.lyx.org Git - lyx.git/blob - src/LaTeX.C
Fix cursor bug with math greek mode.
[lyx.git] / src / LaTeX.C
1 /* This file is part of
2  * ====================================================== 
3  * 
4  *           LyX, The Document Processor         
5  *           Copyright 1995 Matthias Ettrich
6  *           Copyright 1995-2000 The LyX Team.
7  *
8  *           This file is Copyright 1996-2000
9  *           Lars Gullik Bjønnes
10  *
11  * ====================================================== 
12  */
13
14 #include <config.h>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19 #include <fstream>
20
21 #include "support/filetools.h"
22 #include "LaTeX.h"
23 #include "support/FileInfo.h"
24 #include "debug.h"
25 #include "support/lyxlib.h"
26 #include "support/syscall.h"
27 #include "support/syscontr.h"
28 #include "support/path.h"
29 #include "support/LRegex.h"
30 #include "support/LSubstring.h"
31 #include "bufferlist.h"
32 #include "minibuffer.h"
33 #include "gettext.h"
34 #include "lyx_gui_misc.h"
35
36 using std::ifstream;
37 using std::getline;
38 using std::endl;
39 using std::vector;
40
41 // TODO: in no particular order
42 // - get rid of the extern BufferList and the call to
43 //   BufferList::updateIncludedTeXfiles, this should either
44 //   be done before calling LaTeX::funcs or in a completely
45 //   different way.
46 // - the bibtex command options should be supported.
47 // - the makeindex style files should be taken care of with
48 //   the dependency mechanism.
49 // - makeindex commandline options should be supported
50 // - somewhere support viewing of bibtex and makeindex log files.
51 // - we should perhaps also scan the bibtex log file
52 // - we should perhaps also scan the bibtex log file
53
54 extern BufferList bufferlist;
55
56 /*
57  * CLASS TEXERRORS
58  */
59
60 void TeXErrors::insertError(int line, string const & error_desc,
61                             string const & error_text)
62 {
63         Error newerr(line, error_desc, error_text);
64         errors.push_back(newerr);
65 }
66
67 /*
68  * CLASS LaTeX
69  */
70
71 LaTeX::LaTeX(string const & latex, string const & f, string const & p)
72                 : cmd(latex), file(f), path(p)
73 {
74         num_errors = 0;
75         depfile = file + ".dep";
76         if (prefixIs(cmd, "pdf")) // Do we use pdflatex ?
77                 depfile += "-pdf";
78 }
79
80
81 void LaTeX::deleteFilesOnError() const
82 {
83         // currently just a dummy function.
84
85         // What files do we have to delete?
86
87         // This will at least make latex do all the runs
88         lyx::unlink(depfile);
89
90         // but the reason for the error might be in a generated file...
91
92         string ofname = OnlyFilename(file);
93
94         // bibtex file
95         string bbl = ChangeExtension(ofname, ".bbl");
96         lyx::unlink(bbl);
97
98         // makeindex file
99         string ind = ChangeExtension(ofname, ".ind");
100         lyx::unlink(ind);
101         
102         // Also remove the aux file
103         string aux = ChangeExtension(ofname, ".aux");
104         lyx::unlink(aux);
105 }
106
107
108 int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
109         // We know that this function will only be run if the lyx buffer
110         // has been changed. We also know that a newly written .tex file
111         // is always different from the previous one because of the date
112         // in it. However it seems safe to run latex (at least) on time each
113         // time the .tex file changes.
114 {
115         int scanres = LaTeX::NO_ERRORS;
116         unsigned int count = 0; // number of times run
117         num_errors = 0; // just to make sure.
118         const unsigned int MAX_RUN = 6;
119         DepTable head; // empty head
120         bool rerun = false; // rerun requested
121         
122         // The class LaTeX does not know the temp path.
123         bufferlist.updateIncludedTeXfiles(lyx::getcwd()); //GetCWD());
124         
125         // Never write the depfile if an error was encountered.
126         
127         // 0
128         // first check if the file dependencies exist:
129         //     ->If it does exist
130         //             check if any of the files mentioned in it have
131         //             changed (done using a checksum).
132         //                 -> if changed:
133         //                        run latex once and
134         //                        remake the dependency file
135         //                 -> if not changed:
136         //                        just return there is nothing to do for us.
137         //     ->if it doesn't exist
138         //             make it and
139         //             run latex once (we need to run latex once anyway) and
140         //             remake the dependency file.
141         //
142         FileInfo fi(depfile);
143         bool run_bibtex = false;
144         if (fi.exist()) {
145                 // Read the dep file:
146                 head.read(depfile);
147                 // Update the checksums
148                 head.update();
149                 
150                 lyxerr[Debug::DEPEND] << "Dependency file exists" << endl;
151                 if (head.sumchange()) {
152                         ++count;
153                         lyxerr[Debug::DEPEND]
154                                 << "Dependency file has changed" << endl;
155                         lyxerr[Debug::LATEX]
156                                 << "Run #" << count << endl; 
157                         WriteStatus(minib,
158                                     string(_("LaTeX run number ")) + tostr(count));
159                         this->operator()();
160                         scanres = scanLogFile(terr);
161                         if (scanres & LaTeX::ERRORS) {
162                                 deleteFilesOnError();
163                                 return scanres; // return on error
164                         }
165                         run_bibtex = scanAux(head);
166                         if (run_bibtex)
167                                 lyxerr[Debug::DEPEND]
168                                         << "Bibtex demands rerun" << endl;
169                 } else {
170                         lyxerr[Debug::DEPEND] << "return no_change" << endl;
171                         return LaTeX::NO_CHANGE;
172                 }
173         } else {
174                 ++count;
175                 lyxerr[Debug::DEPEND]
176                         << "Dependency file does not exist" << endl;
177                 
178                 lyxerr[Debug::LATEX]
179                         << "Run #" << count << endl;
180                 head.insert(file, true);
181                 WriteStatus(minib,
182                             string(_("LaTeX run number ")) + tostr(count));
183                 this->operator()();
184                 scanres = scanLogFile(terr);
185                 if (scanres & LaTeX::ERRORS) {
186                         deleteFilesOnError();
187                         return scanres; // return on error
188                 }
189                 
190         }
191
192         // update the dependencies.
193         deplog(head); // reads the latex log
194         head.update();
195
196         // 0.5
197         // At this point we must run external programs if needed.
198         // makeindex will be run if a .idx file changed or was generated.
199         // And if there were undefined citations or changes in references
200         // the .aux file is checked for signs of bibtex. Bibtex is then run
201         // if needed.
202         
203         // run makeindex
204         if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
205                 // no checks for now
206                 lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
207                 WriteStatus(minib, _("Running MakeIndex."));
208                 rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
209         }
210
211         // run bibtex
212         if (scanres & LaTeX::UNDEF_CIT
213             || scanres & LaTeX::RERUN
214             || run_bibtex) {
215                 // Here we must scan the .aux file and look for
216                 // "\bibdata" and/or "\bibstyle". If one of those
217                 // tags is found -> run bibtex and set rerun = true;
218                 // no checks for now
219                 lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
220                 WriteStatus(minib, _("Running BibTeX."));
221                 rerun = runBibTeX(head);
222         }
223         
224         // 1
225         // we know on this point that latex has been run once (or we just
226         // returned) and the question now is to decide if we need to run
227         // it any more. This is done by asking if any of the files in the
228         // dependency file has changed. (remember that the checksum for
229         // a given file is reported to have changed if it just was created)
230         //     -> if changed or rerun == true:
231         //             run latex once more and
232         //             update the dependency structure
233         //     -> if not changed:
234         //             we does nothing at this point
235         //
236         if (rerun || head.sumchange()) {
237                 rerun = false;
238                 ++count;
239                 lyxerr[Debug::DEPEND]
240                         << "Dep. file has changed or rerun requested" << endl;
241                 lyxerr[Debug::LATEX]
242                         << "Run #" << count << endl;
243                 WriteStatus(minib,
244                             string(_("LaTeX run number ")) + tostr(count));
245                 this->operator()();
246                 scanres = scanLogFile(terr);
247                 if (scanres & LaTeX::ERRORS) {
248                         deleteFilesOnError();
249                         return scanres; // return on error
250                 }
251                 
252                 // update the depedencies
253                 deplog(head); // reads the latex log
254                 head.update();
255         } else {
256                 lyxerr[Debug::DEPEND] << "Dep. file has NOT changed" << endl;
257         }
258
259         // 1.5
260         // The inclusion of files generated by external programs like
261         // makeindex or bibtex might have done changes to pagenumbereing,
262         // etc. And because of this we must run the external programs
263         // again to make sure everything is redone correctly.
264         // Also there should be no need to run the external programs any
265         // more after this.
266         
267         // run makeindex if the <file>.idx has changed or was generated.
268         if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
269                 // no checks for now
270                 lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
271                 WriteStatus(minib, _("Running MakeIndex."));
272                 rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
273         }
274         
275         // 2
276         // we will only run latex more if the log file asks for it.
277         // or if the sumchange() is true.
278         //     -> rerun asked for:
279         //             run latex and
280         //             remake the dependency file
281         //             goto 2 or return if max runs are reached.
282         //     -> rerun not asked for:
283         //             just return (fall out of bottom of func)
284         //
285         while ((head.sumchange() || rerun || (scanres & LaTeX::RERUN)) 
286                && count < MAX_RUN) {
287                 // Yes rerun until message goes away, or until
288                 // MAX_RUNS are reached.
289                 rerun = false;
290                 ++count;
291                 lyxerr[Debug::LATEX] << "Run #" << count << endl;
292                 WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count));
293                 this->operator()();
294                 scanres = scanLogFile(terr);
295                 if (scanres & LaTeX::ERRORS) {
296                         deleteFilesOnError();
297                         return scanres; // return on error
298                 }
299                 
300                 // keep this updated
301                 head.update();
302         }
303
304         // Write the dependencies to file.
305         head.write(depfile);
306         lyxerr[Debug::LATEX] << "Done." << endl;
307         return scanres;
308 }
309
310
311 int LaTeX::operator()()
312 {
313 #ifndef __EMX__
314         string tmp = cmd + ' ' + QuoteName(file) + " > /dev/null";
315 #else // cmd.exe (OS/2) causes SYS0003 error at "/dev/null"
316         string tmp = cmd + ' ' + file + " > nul";
317 #endif
318         Systemcalls one;
319         return one.startscript(Systemcalls::System, tmp);
320 }
321
322
323 bool LaTeX::runMakeIndex(string const & f)
324 {
325         lyxerr[Debug::LATEX] << "idx file has been made,"
326                 " running makeindex on file "
327                              <<  f << endl;
328
329         // It should be possible to set the switches for makeindex
330         // sorting style and such. It would also be very convenient
331         // to be able to make style files from within LyX. This has
332         // to come for a later time. (0.13 perhaps?)
333         string tmp = "makeindex -c -q ";
334         tmp += f;
335         Systemcalls one;
336         one.startscript(Systemcalls::System, tmp);
337         return true;
338 }
339
340 // scanAux may return a wrong result if there are more than two bibliographies,
341 // and after LaTeX-ing the file, the user changes the order of the bibliography 
342 // and run LaTeX again. However, in this case, bibtopic prints a warning message which
343 // is caught by scanLogFile.
344 bool LaTeX::scanAux(DepTable & dep)
345 {
346         // if any of the bib file has changed we don't have to
347         // check the .aux file.
348         if (dep.extchanged(".bib")
349             || dep.extchanged(".bst")) return true;
350         
351         string aux = OnlyFilename(ChangeExtension(file, ".aux"));
352         return !scanAuxFiles(aux, dep, false).empty();
353 }
354
355 vector<string> const
356 LaTeX::scanAuxFiles(string const & file, DepTable & dep, bool insert)
357 {
358         vector<string> result;
359         if (scanAuxFile(file, dep, insert)) {
360                 result.push_back(file);
361                 if (!insert)
362                         return result;
363         }
364
365         for (int i = 1; i < 1000; ++i) {
366                 string file2 = ChangeExtension(file, "") + "." + tostr(i)
367                         + ".aux";
368                 FileInfo fi(file2);
369                 if (!fi.exist())
370                         return result;
371                 if (scanAuxFile(file2, dep, insert)) {
372                         result.push_back(file2);
373                         if (!insert)
374                                 return result;
375                 }
376         }
377         return result;
378 }
379
380
381 // If insert = true, then scanAuxFile returns true iff the aux file contains
382 // a bibtex database (i.e. a \bibdata command), or it inputs another auxfile which
383 // contains a bibtex database.
384 // Also the dep is updated for all bibtex databases and bibtex styles in the aux
385 // file.
386 // Ideally, scanAuxFile should return true iff one of the bibtex database/styles has
387 // changes from previous run, or a new bibtex database/styles was added to the aux file.
388 // However, it is probably not worth the effort.
389 //
390 // If insert = false, then scanAuxFile returns true iff the aux file contains a
391 // bibtex database or a bibtex style that do not appear in dep.
392 // 
393 bool LaTeX::scanAuxFile(string const & file, DepTable & dep, bool insert)
394 {
395         lyxerr[Debug::LATEX] << "Scanning aux file: " << file << endl;
396
397         ifstream ifs(file.c_str());
398         string token;
399         LRegex reg1("\\\\bibdata\\{([^}]+)\\}");
400         LRegex reg2("\\\\bibstyle\\{([^}]+)\\}");
401         LRegex reg3("\\\\@input\\{([^}]+)\\}");
402         bool result = false;
403         while (getline(ifs, token)) {
404                 if (reg1.exact_match(token)) {
405                         if (insert)
406                                 result = true;
407                         LRegex::SubMatches const & sub = reg1.exec(token);
408                         string data = LSubstring(token, sub[1].first,
409                                                  sub[1].second);
410                         // data is now all the bib files separated by ','
411                         // get them one by one and pass them to the helper
412                         while (!data.empty()) {
413                                 string l;
414                                 data = split(data, l, ',');
415                                 string full_l = 
416                                         findtexfile(ChangeExtension(l, "bib"),
417                                                     "bib");
418                                 lyxerr[Debug::LATEX] << "Bibtex database: `"
419                                                      << full_l << "'" << endl;
420                                 if (!full_l.empty()) {
421                                         if (insert)
422                                                 // add full_l to the dep file.
423                                                 dep.insert(full_l, true);
424                                         else
425                                                 if (!dep.exist(full_l))
426                                                         return true;
427                                 }
428                         }
429                 } else if (reg2.exact_match(token)) {
430                         LRegex::SubMatches const & sub = reg2.exec(token);
431                         string style = LSubstring(token, sub[1].first,
432                                                   sub[1].second);
433                         // token is now the style file
434                         // pass it to the helper
435                         string full_l = 
436                                 findtexfile(ChangeExtension(style, "bst"),
437                                             "bst");
438                         lyxerr[Debug::LATEX] << "Bibtex style: `"
439                                              << full_l << "'" << endl;
440                         if (!full_l.empty()) {
441                                 if (insert)
442                                         // add full_l to the dep file.
443                                         dep.insert(full_l, true);
444                                 else
445                                         if (!dep.exist(full_l))
446                                                 return true;    
447                         }
448                 } else if (reg3.exact_match(token)) {
449                         LRegex::SubMatches const & sub = reg3.exec(token);
450                         string file2 = LSubstring(token, sub[1].first,
451                                                   sub[1].second);
452                         result |=  scanAuxFile(file2, dep, insert);
453                         if (result && !insert)
454                                 return true;
455                 }
456         }
457         return result;
458 }
459
460
461 bool LaTeX::runBibTeX(DepTable & dep)
462 {
463         // Since a run of Bibtex mandates more latex runs it is ok to
464         // remove all ".bib" and ".bst" files, it is also required to
465         // discover style and database changes.
466         dep.remove_files_with_extension(".bib");
467         dep.remove_files_with_extension(".bst");
468         string aux = OnlyFilename(ChangeExtension(file, ".aux"));
469         vector<string> const aux_files = scanAuxFiles(aux, dep, true);
470         // Run bibtex on each of the aux files in 
471         for (vector<string>::const_iterator it = aux_files.begin();
472              it != aux_files.end(); ++it) {
473                 string tmp = "bibtex ";
474                 tmp += OnlyFilename(ChangeExtension(*it, string()));
475                 Systemcalls one;
476                 one.startscript(Systemcalls::System, tmp);
477         }
478         // Return whether bibtex was run
479         return !aux_files.empty();
480 }
481
482
483 int LaTeX::scanLogFile(TeXErrors & terr)
484 {
485         int last_line = -1;
486         int line_count = 1;
487         int retval = NO_ERRORS;
488         string tmp = OnlyFilename(ChangeExtension(file, ".log"));
489         lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
490         ifstream ifs(tmp.c_str());
491
492         string token;
493         while (getline(ifs, token)) {
494                 lyxerr[Debug::LATEX] << "Log line: " << token << endl;
495                 
496                 if (token.empty())
497                         continue;
498
499                 if (prefixIs(token, "LaTeX Warning:")) {
500                         // Here shall we handle different
501                         // types of warnings
502                         retval |= LATEX_WARNING;
503                         lyxerr[Debug::LATEX] << "LaTeX Warning." << endl;
504                         if (contains(token, "Rerun to get cross-references")) {
505                                 retval |= RERUN;
506                                 lyxerr[Debug::LATEX]
507                                         << "We should rerun." << endl;
508                         } else if (contains(token, "Citation")
509                                    && contains(token, "on page")
510                                    && contains(token, "undefined")) {
511                                 retval |= UNDEF_CIT;
512                         }
513                 } else if (prefixIs(token, "Package")) {
514                         // Package warnings
515                         retval |= PACKAGE_WARNING;
516                         if (contains(token, "natbib Warning:")) {
517                                 // Natbib warnings
518                                 if (contains(token, "Citation")
519                                     && contains(token, "on page")
520                                     && contains(token, "undefined")) {
521                                         retval |= UNDEF_CIT;
522                                 }
523                         } else if (contains(token, "run BibTeX")) {
524                                 retval |= UNDEF_CIT;
525                         } else if (contains(token, "Rerun LaTeX.")) {
526                                 // at least longtable.sty might use this.
527                                 retval |= RERUN;
528                         }
529                 } else if (prefixIs(token, "! ")) {
530                         // Ok, we have something that looks like a TeX Error
531                         // but what do we really have.
532
533                         // Just get the error description:
534                         string desc(token, 2);
535                         if (contains(token, "LaTeX Error:"))
536                                 retval |= LATEX_ERROR;
537                         // get the next line
538                         string tmp;
539                         int count = 0;
540                         do {
541                                 if (!getline(ifs, tmp))
542                                         break;
543                                 if (++count > 10)
544                                         break;
545                         } while (!prefixIs(tmp, "l."));
546                         if (prefixIs(tmp, "l.")) {
547                                 // we have a latex error
548                                 retval |=  TEX_ERROR;
549                                 // get the line number:
550                                 int line = 0;
551                                 sscanf(tmp.c_str(), "l.%d", &line);
552                                 // get the rest of the message:
553                                 string errstr(tmp, tmp.find(' '));
554                                 errstr += '\n';
555                                 getline(ifs, tmp);
556                                 while (!contains(errstr, "l.")
557                                        && !tmp.empty()
558                                        && !prefixIs(tmp, "! ")
559                                        && !contains(tmp, "(job aborted")) {
560                                         errstr += tmp;
561                                         errstr += "\n";
562                                         getline(ifs, tmp);
563                                 }
564                                 lyxerr[Debug::LATEX]
565                                         << "line: " << line << '\n'
566                                         << "Desc: " << desc << '\n'
567                                         << "Text: " << errstr << endl;
568                                 if (line == last_line)
569                                         ++line_count;
570                                 else {
571                                         line_count = 1;
572                                         last_line = line;
573                                 }
574                                 if (line_count <= 5) {
575                                         terr.insertError(line, desc, errstr);
576                                         ++num_errors;
577                                 }
578                         }
579                 } else {
580                         // information messages, TeX warnings and other
581                         // warnings we have not caught earlier.
582                         if (prefixIs(token, "Overfull ")) {
583                                 retval |= TEX_WARNING;
584                         } else if (prefixIs(token, "Underfull ")) {
585                                 retval |= TEX_WARNING;
586                         } else if (contains(token, "Rerun to get citations")) {
587                                 // Natbib seems to use this.
588                                 retval |= RERUN;
589                         } else if (contains(token, "No pages of output")) {
590                                 // A dvi file was not created
591                                 retval |= NO_OUTPUT;
592                         } else if (contains(token, "That makes 100 errors")) {
593                                 // More than 100 errors were reprted
594                                 retval |= TOO_MANY_ERRORS;
595                         }
596                 }
597         }
598         lyxerr[Debug::LATEX] << "Log line: " << token << endl;
599         return retval;
600 }
601
602
603 void LaTeX::deplog(DepTable & head)
604 {
605         // This function reads the LaTeX log file end extracts all the external
606         // files used by the LaTeX run. The files are then entered into the
607         // dependency file.
608
609         string logfile = OnlyFilename(ChangeExtension(file, ".log"));
610
611         LRegex reg1(")* *\\(([^ \\)]+).*");
612         LRegex reg2("File: ([^ ]+).*");
613         LRegex reg3("No file ([^ ]+)\\..*");
614         LRegex reg4("\\\\openout[0-9]+.*=.*`([^ ]+)'\\..*");
615         LRegex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
616         
617         ifstream ifs(logfile.c_str());
618         while (ifs) {
619                 // Ok, the scanning of files here is not sufficient.
620                 // Sometimes files are named by "File: xxx" only
621                 // So I think we should use some regexps to find files instead.
622                 // "(\([^ ]+\)"   should match the "(file " variant
623                 // "File: \([^ ]+\)" should match the "File: file" variant
624                 string foundfile;
625                 string token;
626                 getline(ifs, token);
627                 if (token.empty()) continue;
628                 
629                 if (reg1.exact_match(token)) {
630                         LRegex::SubMatches const & sub = reg1.exec(token);
631                         foundfile = LSubstring(token, sub[1].first,
632                                                sub[1].second);
633                 } else if (reg2.exact_match(token)) {
634                         LRegex::SubMatches const & sub = reg2.exec(token);
635                         foundfile = LSubstring(token, sub[1].first,
636                                                sub[1].second);
637                 } else if (reg3.exact_match(token)) {
638                         LRegex::SubMatches const & sub = reg3.exec(token);
639                         foundfile = LSubstring(token, sub[1].first,
640                                                sub[1].second);
641                 } else if (reg4.exact_match(token)) {
642                         LRegex::SubMatches const & sub = reg4.exec(token);
643                         foundfile = LSubstring(token, sub[1].first,
644                                                sub[1].second);
645                 } else {
646                         continue;
647                 }
648
649                 lyxerr[Debug::DEPEND] << "Found file: " 
650                                       << foundfile << endl;
651                 
652                 // Ok now we found a file.
653                 // Now we should make sure that this is a file that we can
654                 // access through the normal paths.
655                 // We will not try any fancy search methods to
656                 // find the file.
657                 
658                 // (1) foundfile is an
659                 //     absolute path and should
660                 //     be inserted.
661                 if (AbsolutePath(foundfile)) {
662                         lyxerr[Debug::DEPEND] << "AbsolutePath file: " 
663                                               << foundfile << endl;
664                         // On initial insert we want to do the update at once
665                         // since this file can not be a file generated by
666                         // the latex run.
667                         head.insert(foundfile, true);
668                         continue;
669                 }
670
671                 // (2) foundfile is in the tmpdir
672                 //     insert it into head
673                 if (FileInfo(OnlyFilename(foundfile)).exist()) {
674                         if (unwanted.exact_match(foundfile)) {
675                                 lyxerr[Debug::DEPEND]
676                                         << "We don't want "
677                                         << OnlyFilename(foundfile)
678                                         << " in the dep file"
679                                         << endl;
680                         } else if (suffixIs(foundfile, ".tex")) {
681                                 // This is a tex file generated by LyX
682                                 // and latex is not likely to change this
683                                 // during its runs.
684                                 lyxerr[Debug::DEPEND]
685                                         << "Tmpdir TeX file: "
686                                         << OnlyFilename(foundfile)
687                                         << endl;
688                                 head.insert(foundfile, true);
689                         } else {
690                                 lyxerr[Debug::DEPEND]
691                                         << "In tmpdir file:"
692                                         << OnlyFilename(foundfile)
693                                         << endl;
694                                 head.insert(OnlyFilename(foundfile));
695                         }
696                         continue;
697                 }
698                 lyxerr[Debug::DEPEND]
699                         << "Not a file or we are unable to find it."
700                         << endl;
701         }
702 }