]> git.lyx.org Git - lyx.git/blob - src/LaTeX.C
Make LFUN_QUOTE work for InsetText.
[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 using std::set;
41
42 // TODO: in no particular order
43 // - get rid of the extern BufferList and the call to
44 //   BufferList::updateIncludedTeXfiles, this should either
45 //   be done before calling LaTeX::funcs or in a completely
46 //   different way.
47 // - the bibtex command options should be supported.
48 // - the makeindex style files should be taken care of with
49 //   the dependency mechanism.
50 // - makeindex commandline options should be supported
51 // - somewhere support viewing of bibtex and makeindex log files.
52 // - we should perhaps also scan the bibtex log file
53 // - we should perhaps also scan the bibtex log file
54
55 extern BufferList bufferlist;
56
57 /*
58  * CLASS TEXERRORS
59  */
60
61 void TeXErrors::insertError(int line, string const & error_desc,
62                             string const & error_text)
63 {
64         Error newerr(line, error_desc, error_text);
65         errors.push_back(newerr);
66 }
67
68 /*
69  * CLASS LaTeX
70  */
71
72 LaTeX::LaTeX(string const & latex, string const & f, string const & p)
73                 : cmd(latex), file(f), path(p)
74 {
75         num_errors = 0;
76         depfile = file + ".dep";
77         if (prefixIs(cmd, "pdf")) // Do we use pdflatex ?
78                 depfile += "-pdf";
79 }
80
81
82 void LaTeX::deleteFilesOnError() const
83 {
84         // currently just a dummy function.
85
86         // What files do we have to delete?
87
88         // This will at least make latex do all the runs
89         lyx::unlink(depfile);
90
91         // but the reason for the error might be in a generated file...
92
93         string ofname = OnlyFilename(file);
94
95         // bibtex file
96         string bbl = ChangeExtension(ofname, ".bbl");
97         lyx::unlink(bbl);
98
99         // makeindex file
100         string ind = ChangeExtension(ofname, ".ind");
101         lyx::unlink(ind);
102         
103         // Also remove the aux file
104         string aux = ChangeExtension(ofname, ".aux");
105         lyx::unlink(aux);
106 }
107
108
109 int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
110         // We know that this function will only be run if the lyx buffer
111         // has been changed. We also know that a newly written .tex file
112         // is always different from the previous one because of the date
113         // in it. However it seems safe to run latex (at least) on time each
114         // time the .tex file changes.
115 {
116         int scanres = LaTeX::NO_ERRORS;
117         unsigned int count = 0; // number of times run
118         num_errors = 0; // just to make sure.
119         const unsigned int MAX_RUN = 6;
120         DepTable head; // empty head
121         bool rerun = false; // rerun requested
122         
123         // The class LaTeX does not know the temp path.
124         bufferlist.updateIncludedTeXfiles(lyx::getcwd()); //GetCWD());
125         
126         // Never write the depfile if an error was encountered.
127         
128         // 0
129         // first check if the file dependencies exist:
130         //     ->If it does exist
131         //             check if any of the files mentioned in it have
132         //             changed (done using a checksum).
133         //                 -> if changed:
134         //                        run latex once and
135         //                        remake the dependency file
136         //                 -> if not changed:
137         //                        just return there is nothing to do for us.
138         //     ->if it doesn't exist
139         //             make it and
140         //             run latex once (we need to run latex once anyway) and
141         //             remake the dependency file.
142         //
143
144         FileInfo fi(depfile);
145         bool had_depfile = fi.exist();
146         bool run_bibtex = false;
147         string aux_file = OnlyFilename(ChangeExtension(file, "aux"));
148
149         if (had_depfile) {
150                 lyxerr[Debug::DEPEND] << "Dependency file exists" << endl;
151                 // Read the dep file:
152                 head.read(depfile);
153                 // Update the checksums
154                 head.update();
155                 if (!head.sumchange()) {
156                         lyxerr[Debug::DEPEND] << "return no_change" << endl;
157                         return LaTeX::NO_CHANGE;
158                 }
159                 lyxerr[Debug::DEPEND]
160                         << "Dependency file has changed" << endl;
161
162                 if (head.extchanged(".bib") || head.extchanged(".bst"))
163                         run_bibtex = true;
164         } else
165                 lyxerr[Debug::DEPEND]
166                         << "Dependency file does not exist" << endl;
167
168         /// We scan the aux file even when had_depfile = false,
169         /// because we can run pdflatex on the file after running latex on it,
170         /// in which case we will not need to run bibtex again.
171         vector<Aux_Info> bibtex_info_old;
172         if (!run_bibtex)
173                 bibtex_info_old = scanAuxFiles(aux_file);
174
175         ++count;
176         lyxerr[Debug::LATEX] << "Run #" << count << endl; 
177         WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count));
178         this->operator()();
179         scanres = scanLogFile(terr);
180         if (scanres & LaTeX::ERROR_RERUN) {
181                 lyxerr[Debug::LATEX] << "Rerunning LaTeX" << endl;
182                 this->operator()();
183                 scanres = scanLogFile(terr);
184         }
185
186         if (scanres & LaTeX::ERRORS) {
187                 deleteFilesOnError();
188                 return scanres; // return on error
189         }
190
191         vector<Aux_Info> const bibtex_info = scanAuxFiles(aux_file);
192         if (!run_bibtex && bibtex_info_old != bibtex_info)
193                 run_bibtex = true;
194
195         // update the dependencies.
196         deplog(head); // reads the latex log
197         head.update();
198
199         // 0.5
200         // At this point we must run external programs if needed.
201         // makeindex will be run if a .idx file changed or was generated.
202         // And if there were undefined citations or changes in references
203         // the .aux file is checked for signs of bibtex. Bibtex is then run
204         // if needed.
205         
206         // run makeindex
207         if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
208                 // no checks for now
209                 lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
210                 WriteStatus(minib, _("Running MakeIndex."));
211                 rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
212         }
213
214         // run bibtex
215         if (scanres & LaTeX::UNDEF_CIT
216             || scanres & LaTeX::RERUN
217             || run_bibtex) {
218                 // Here we must scan the .aux file and look for
219                 // "\bibdata" and/or "\bibstyle". If one of those
220                 // tags is found -> run bibtex and set rerun = true;
221                 // no checks for now
222                 lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
223                 WriteStatus(minib, _("Running BibTeX."));
224                 updateBibtexDependencies(head, bibtex_info);
225                 rerun |= runBibTeX(bibtex_info);
226         } else if (!had_depfile)
227                 /// If we run pdflatex on the file after running latex on it,
228                 /// then we do not need to run bibtex, but we do need to
229                 /// insert the .bib and .bst files into the .dep-pdf file.
230                 updateBibtexDependencies(head, bibtex_info);
231         
232         // 1
233         // we know on this point that latex has been run once (or we just
234         // returned) and the question now is to decide if we need to run
235         // it any more. This is done by asking if any of the files in the
236         // dependency file has changed. (remember that the checksum for
237         // a given file is reported to have changed if it just was created)
238         //     -> if changed or rerun == true:
239         //             run latex once more and
240         //             update the dependency structure
241         //     -> if not changed:
242         //             we does nothing at this point
243         //
244         if (rerun || head.sumchange()) {
245                 rerun = false;
246                 ++count;
247                 lyxerr[Debug::DEPEND]
248                         << "Dep. file has changed or rerun requested" << endl;
249                 lyxerr[Debug::LATEX]
250                         << "Run #" << count << endl;
251                 WriteStatus(minib,
252                             string(_("LaTeX run number ")) + tostr(count));
253                 this->operator()();
254                 scanres = scanLogFile(terr);
255                 if (scanres & LaTeX::ERRORS) {
256                         deleteFilesOnError();
257                         return scanres; // return on error
258                 }
259                 
260                 // update the depedencies
261                 deplog(head); // reads the latex log
262                 head.update();
263         } else {
264                 lyxerr[Debug::DEPEND] << "Dep. file has NOT changed" << endl;
265         }
266
267         // 1.5
268         // The inclusion of files generated by external programs like
269         // makeindex or bibtex might have done changes to pagenumbereing,
270         // etc. And because of this we must run the external programs
271         // again to make sure everything is redone correctly.
272         // Also there should be no need to run the external programs any
273         // more after this.
274         
275         // run makeindex if the <file>.idx has changed or was generated.
276         if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
277                 // no checks for now
278                 lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
279                 WriteStatus(minib, _("Running MakeIndex."));
280                 rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
281         }
282         
283         // 2
284         // we will only run latex more if the log file asks for it.
285         // or if the sumchange() is true.
286         //     -> rerun asked for:
287         //             run latex and
288         //             remake the dependency file
289         //             goto 2 or return if max runs are reached.
290         //     -> rerun not asked for:
291         //             just return (fall out of bottom of func)
292         //
293         while ((head.sumchange() || rerun || (scanres & LaTeX::RERUN)) 
294                && count < MAX_RUN) {
295                 // Yes rerun until message goes away, or until
296                 // MAX_RUNS are reached.
297                 rerun = false;
298                 ++count;
299                 lyxerr[Debug::LATEX] << "Run #" << count << endl;
300                 WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count));
301                 this->operator()();
302                 scanres = scanLogFile(terr);
303                 if (scanres & LaTeX::ERRORS) {
304                         deleteFilesOnError();
305                         return scanres; // return on error
306                 }
307                 
308                 // keep this updated
309                 head.update();
310         }
311
312         // Write the dependencies to file.
313         head.write(depfile);
314         lyxerr[Debug::LATEX] << "Done." << endl;
315         return scanres;
316 }
317
318
319 int LaTeX::operator()()
320 {
321 #ifndef __EMX__
322         string tmp = cmd + ' ' + QuoteName(file) + " > /dev/null";
323 #else // cmd.exe (OS/2) causes SYS0003 error at "/dev/null"
324         string tmp = cmd + ' ' + file + " > nul";
325 #endif
326         Systemcalls one;
327         return one.startscript(Systemcalls::System, tmp);
328 }
329
330
331 bool LaTeX::runMakeIndex(string const & f)
332 {
333         lyxerr[Debug::LATEX] << "idx file has been made,"
334                 " running makeindex on file "
335                              <<  f << endl;
336
337         // It should be possible to set the switches for makeindex
338         // sorting style and such. It would also be very convenient
339         // to be able to make style files from within LyX. This has
340         // to come for a later time. (0.13 perhaps?)
341         string tmp = "makeindex -c -q ";
342         tmp += f;
343         Systemcalls one;
344         one.startscript(Systemcalls::System, tmp);
345         return true;
346 }
347
348
349 vector<Aux_Info> const
350 LaTeX::scanAuxFiles(string const & file)
351 {
352         vector<Aux_Info> result;
353         
354         result.push_back(scanAuxFile(file));
355
356         for (int i = 1; i < 1000; ++i) {
357                 string file2 = ChangeExtension(file, "") + "." + tostr(i)
358                         + ".aux";
359                 FileInfo fi(file2);
360                 if (!fi.exist())
361                         break;
362                 result.push_back(scanAuxFile(file2));
363         }
364         return result;
365 }
366
367
368 Aux_Info const LaTeX::scanAuxFile(string const & file)
369 {
370         Aux_Info result;
371         result.aux_file = file;
372         scanAuxFile(file, result);
373         return result;
374 }
375
376
377 void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info)
378 {
379         lyxerr[Debug::LATEX] << "Scanning aux file: " << file << endl;
380
381         ifstream ifs(file.c_str());
382         string token;
383         LRegex reg1("\\\\citation\\{([^}]+)\\}");
384         LRegex reg2("\\\\bibdata\\{([^}]+)\\}");
385         LRegex reg3("\\\\bibstyle\\{([^}]+)\\}");
386         LRegex reg4("\\\\@input\\{([^}]+)\\}");
387
388         while (getline(ifs, token)) {
389                 if (reg1.exact_match(token)) {
390                         LRegex::SubMatches const & sub = reg1.exec(token);
391                         string data = LSubstring(token, sub[1].first,
392                                                  sub[1].second);
393                         while (!data.empty()) {
394                                 string citation;
395                                 data = split(data, citation, ',');
396                                 lyxerr[Debug::LATEX] << "Citation: "
397                                                      << citation << endl;
398                                 aux_info.citations.insert(citation);
399                         }
400                 } else if (reg2.exact_match(token)) {
401                         LRegex::SubMatches const & sub = reg2.exec(token);
402                         string data = LSubstring(token, sub[1].first,
403                                                  sub[1].second);
404                         // data is now all the bib files separated by ','
405                         // get them one by one and pass them to the helper
406                         while (!data.empty()) {
407                                 string database;
408                                 data = split(data, database, ',');
409                                 database = ChangeExtension(database, "bib");
410                                 lyxerr[Debug::LATEX] << "Bibtex database: `"
411                                                      << database << "'" << endl;
412                                 aux_info.databases.insert(database);
413                         }
414                 } else if (reg3.exact_match(token)) {
415                         LRegex::SubMatches const & sub = reg3.exec(token);
416                         string style = LSubstring(token, sub[1].first,
417                                                   sub[1].second);
418                         // token is now the style file
419                         // pass it to the helper
420                         style = ChangeExtension(style, "bst");
421                         lyxerr[Debug::LATEX] << "Bibtex style: `"
422                                              << style << "'" << endl;
423                         aux_info.styles.insert(style);
424                 } else if (reg4.exact_match(token)) {
425                         LRegex::SubMatches const & sub = reg4.exec(token);
426                         string file2 = LSubstring(token, sub[1].first,
427                                                   sub[1].second);
428                         scanAuxFile(file2, aux_info);
429                 }
430         }
431 }
432
433
434 void LaTeX::updateBibtexDependencies(DepTable & dep,
435                                      vector<Aux_Info> const & bibtex_info)
436 {
437         // Since a run of Bibtex mandates more latex runs it is ok to
438         // remove all ".bib" and ".bst" files.
439         dep.remove_files_with_extension(".bib");
440         dep.remove_files_with_extension(".bst");
441         string aux = OnlyFilename(ChangeExtension(file, ".aux"));
442
443         for (vector<Aux_Info>::const_iterator it = bibtex_info.begin();
444              it != bibtex_info.end(); ++it) {
445                 for (set<string>::const_iterator it2 = it->databases.begin();
446                      it2 != it->databases.end(); ++it2) {
447                         string file = findtexfile(*it2, "bib");
448                         if (!file.empty())
449                                 dep.insert(file, true);
450                 }
451
452                 for (set<string>::const_iterator it2 = it->styles.begin();
453                      it2 != it->styles.end(); ++it2) {
454                         string file = findtexfile(*it2, "bst");
455                         if (!file.empty())
456                                 dep.insert(file, true);
457                 }                       
458         }
459 }
460
461
462 bool LaTeX::runBibTeX(vector<Aux_Info> const & bibtex_info)
463 {
464         bool result = false;
465         for (vector<Aux_Info>::const_iterator it = bibtex_info.begin();
466              it != bibtex_info.end(); ++it) {
467                 if (it->databases.empty())
468                         continue;
469                 result = true;
470
471                 string tmp = "bibtex ";
472                 tmp += OnlyFilename(ChangeExtension(it->aux_file, string()));
473                 Systemcalls one;
474                 one.startscript(Systemcalls::System, tmp);
475         }
476         // Return whether bibtex was run
477         return result;
478 }
479
480
481 int LaTeX::scanLogFile(TeXErrors & terr)
482 {
483         int last_line = -1;
484         int line_count = 1;
485         int retval = NO_ERRORS;
486         string tmp = OnlyFilename(ChangeExtension(file, ".log"));
487         lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
488         ifstream ifs(tmp.c_str());
489
490         string token;
491         while (getline(ifs, token)) {
492                 lyxerr[Debug::LATEX] << "Log line: " << token << endl;
493                 
494                 if (token.empty())
495                         continue;
496
497                 if (prefixIs(token, "LaTeX Warning:")) {
498                         // Here shall we handle different
499                         // types of warnings
500                         retval |= LATEX_WARNING;
501                         lyxerr[Debug::LATEX] << "LaTeX Warning." << endl;
502                         if (contains(token, "Rerun to get cross-references")) {
503                                 retval |= RERUN;
504                                 lyxerr[Debug::LATEX]
505                                         << "We should rerun." << endl;
506                         } else if (contains(token, "Citation")
507                                    && contains(token, "on page")
508                                    && contains(token, "undefined")) {
509                                 retval |= UNDEF_CIT;
510                         }
511                 } else if (prefixIs(token, "Package")) {
512                         // Package warnings
513                         retval |= PACKAGE_WARNING;
514                         if (contains(token, "natbib Warning:")) {
515                                 // Natbib warnings
516                                 if (contains(token, "Citation")
517                                     && contains(token, "on page")
518                                     && contains(token, "undefined")) {
519                                         retval |= UNDEF_CIT;
520                                 }
521                         } else if (contains(token, "run BibTeX")) {
522                                 retval |= UNDEF_CIT;
523                         } else if (contains(token, "Rerun LaTeX.")) {
524                                 // at least longtable.sty might use this.
525                                 retval |= RERUN;
526                         }
527                 } else if (prefixIs(token, "! ")) {
528                         // Ok, we have something that looks like a TeX Error
529                         // but what do we really have.
530
531                         // Just get the error description:
532                         string desc(token, 2);
533                         if (contains(token, "LaTeX Error:"))
534                                 retval |= LATEX_ERROR;
535                         // get the next line
536                         string tmp;
537                         int count = 0;
538                         do {
539                                 if (!getline(ifs, tmp))
540                                         break;
541                                 if (++count > 10)
542                                         break;
543                         } while (!prefixIs(tmp, "l."));
544                         if (prefixIs(tmp, "l.")) {
545                                 // we have a latex error
546                                 retval |=  TEX_ERROR;
547                                 if (contains(desc, "Package babel Error: You haven't defined the language"))
548                                         retval |= ERROR_RERUN;
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 }