]> git.lyx.org Git - lyx.git/blob - src/LaTeX.C
fix compilation pb ; update eu.po
[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 "gettext.h"
33 #include "lyx_gui_misc.h"
34 #include "lyxfunc.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, LyXFunc * lfun)
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 = 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 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         lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run number") + ' ' + tostr(count));
178         
179         //WriteStatus(lfun, string(_("LaTeX run number ")) + tostr(count));
180         this->operator()();
181         scanres = scanLogFile(terr);
182         if (scanres & ERROR_RERUN) {
183                 lyxerr[Debug::LATEX] << "Rerunning LaTeX" << endl;
184                 this->operator()();
185                 scanres = scanLogFile(terr);
186         }
187
188         if (scanres & ERRORS) {
189                 deleteFilesOnError();
190                 return scanres; // return on error
191         }
192
193         vector<Aux_Info> const bibtex_info = scanAuxFiles(aux_file);
194         if (!run_bibtex && bibtex_info_old != bibtex_info)
195                 run_bibtex = true;
196
197         // update the dependencies.
198         deplog(head); // reads the latex log
199         head.update();
200
201         // 0.5
202         // At this point we must run external programs if needed.
203         // makeindex will be run if a .idx file changed or was generated.
204         // And if there were undefined citations or changes in references
205         // the .aux file is checked for signs of bibtex. Bibtex is then run
206         // if needed.
207         
208         // run makeindex
209         if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
210                 // no checks for now
211                 lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
212                 lfun->Dispatch(LFUN_MESSAGE, _("Running MakeIndex."));
213 //              WriteStatus(minib, _("Running MakeIndex."));
214                 rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
215         }
216
217         // run bibtex
218         // if (scanres & UNDEF_CIT || scanres & RERUN || run_bibtex)
219         if (scanres & UNDEF_CIT || run_bibtex) {
220                 // Here we must scan the .aux file and look for
221                 // "\bibdata" and/or "\bibstyle". If one of those
222                 // tags is found -> run bibtex and set rerun = true;
223                 // no checks for now
224                 lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
225                 lfun->Dispatch(LFUN_MESSAGE, _("Running BibTeX."));
226                 //WriteStatus(minib, _("Running BibTeX."));
227                 updateBibtexDependencies(head, bibtex_info);
228                 rerun |= runBibTeX(bibtex_info);
229         } else if (!had_depfile)
230                 /// If we run pdflatex on the file after running latex on it,
231                 /// then we do not need to run bibtex, but we do need to
232                 /// insert the .bib and .bst files into the .dep-pdf file.
233                 updateBibtexDependencies(head, bibtex_info);
234         
235         // 1
236         // we know on this point that latex has been run once (or we just
237         // returned) and the question now is to decide if we need to run
238         // it any more. This is done by asking if any of the files in the
239         // dependency file has changed. (remember that the checksum for
240         // a given file is reported to have changed if it just was created)
241         //     -> if changed or rerun == true:
242         //             run latex once more and
243         //             update the dependency structure
244         //     -> if not changed:
245         //             we does nothing at this point
246         //
247         if (rerun || head.sumchange()) {
248                 rerun = false;
249                 ++count;
250                 lyxerr[Debug::DEPEND]
251                         << "Dep. file has changed or rerun requested" << endl;
252                 lyxerr[Debug::LATEX]
253                         << "Run #" << count << endl;
254                 lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run number") + ' ' + tostr(count));
255 //              WriteStatus(minib,
256 //                          string(_("LaTeX run number ")) + tostr(count));
257                 this->operator()();
258                 scanres = scanLogFile(terr);
259                 if (scanres & ERRORS) {
260                         deleteFilesOnError();
261                         return scanres; // return on error
262                 }
263                 
264                 // update the depedencies
265                 deplog(head); // reads the latex log
266                 head.update();
267         } else {
268                 lyxerr[Debug::DEPEND] << "Dep. file has NOT changed" << endl;
269         }
270
271         // 1.5
272         // The inclusion of files generated by external programs like
273         // makeindex or bibtex might have done changes to pagenumbereing,
274         // etc. And because of this we must run the external programs
275         // again to make sure everything is redone correctly.
276         // Also there should be no need to run the external programs any
277         // more after this.
278         
279         // run makeindex if the <file>.idx has changed or was generated.
280         if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
281                 // no checks for now
282                 lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
283                 lfun->Dispatch(LFUN_MESSAGE, _("Running MakeIndex."));
284                 //WriteStatus(minib, _("Running MakeIndex."));
285                 rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
286         }
287         
288         // 2
289         // we will only run latex more if the log file asks for it.
290         // or if the sumchange() is true.
291         //     -> rerun asked for:
292         //             run latex and
293         //             remake the dependency file
294         //             goto 2 or return if max runs are reached.
295         //     -> rerun not asked for:
296         //             just return (fall out of bottom of func)
297         //
298         while ((head.sumchange() || rerun || (scanres & RERUN)) 
299                && count < MAX_RUN) {
300                 // Yes rerun until message goes away, or until
301                 // MAX_RUNS are reached.
302                 rerun = false;
303                 ++count;
304                 lyxerr[Debug::LATEX] << "Run #" << count << endl;
305                 lfun->Dispatch(LFUN_MESSAGE, _("LaTeX run numger") + ' ' + tostr(count));
306 //              WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count));
307                 this->operator()();
308                 scanres = scanLogFile(terr);
309                 if (scanres & ERRORS) {
310                         deleteFilesOnError();
311                         return scanres; // return on error
312                 }
313                 
314                 // keep this updated
315                 head.update();
316         }
317
318         // Write the dependencies to file.
319         head.write(depfile);
320         lyxerr[Debug::LATEX] << "Done." << endl;
321         return scanres;
322 }
323
324
325 int LaTeX::operator()()
326 {
327 #ifndef __EMX__
328         string tmp = cmd + ' ' + QuoteName(file) + " > /dev/null";
329 #else // cmd.exe (OS/2) causes SYS0003 error at "/dev/null"
330         string tmp = cmd + ' ' + file + " > nul";
331 #endif
332         Systemcalls one;
333         return one.startscript(Systemcalls::System, tmp);
334 }
335
336
337 bool LaTeX::runMakeIndex(string const & f)
338 {
339         lyxerr[Debug::LATEX] << "idx file has been made,"
340                 " running makeindex on file "
341                              <<  f << endl;
342
343         // It should be possible to set the switches for makeindex
344         // sorting style and such. It would also be very convenient
345         // to be able to make style files from within LyX. This has
346         // to come for a later time. (0.13 perhaps?)
347         string tmp = "makeindex -c -q ";
348         tmp += f;
349         Systemcalls one;
350         one.startscript(Systemcalls::System, tmp);
351         return true;
352 }
353
354
355 vector<Aux_Info> const
356 LaTeX::scanAuxFiles(string const & file)
357 {
358         vector<Aux_Info> result;
359         
360         result.push_back(scanAuxFile(file));
361
362         for (int i = 1; i < 1000; ++i) {
363                 string file2 = ChangeExtension(file, "") + "." + tostr(i)
364                         + ".aux";
365                 FileInfo fi(file2);
366                 if (!fi.exist())
367                         break;
368                 result.push_back(scanAuxFile(file2));
369         }
370         return result;
371 }
372
373
374 Aux_Info const LaTeX::scanAuxFile(string const & file)
375 {
376         Aux_Info result;
377         result.aux_file = file;
378         scanAuxFile(file, result);
379         return result;
380 }
381
382
383 void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info)
384 {
385         lyxerr[Debug::LATEX] << "Scanning aux file: " << file << endl;
386
387         ifstream ifs(file.c_str());
388         string token;
389         LRegex reg1("\\\\citation\\{([^}]+)\\}");
390         LRegex reg2("\\\\bibdata\\{([^}]+)\\}");
391         LRegex reg3("\\\\bibstyle\\{([^}]+)\\}");
392         LRegex reg4("\\\\@input\\{([^}]+)\\}");
393
394         while (getline(ifs, token)) {
395                 if (reg1.exact_match(token)) {
396                         LRegex::SubMatches const & sub = reg1.exec(token);
397                         string data = LSubstring(token, sub[1].first,
398                                                  sub[1].second);
399                         while (!data.empty()) {
400                                 string citation;
401                                 data = split(data, citation, ',');
402                                 lyxerr[Debug::LATEX] << "Citation: "
403                                                      << citation << endl;
404                                 aux_info.citations.insert(citation);
405                         }
406                 } else if (reg2.exact_match(token)) {
407                         LRegex::SubMatches const & sub = reg2.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 database;
414                                 data = split(data, database, ',');
415                                 database = ChangeExtension(database, "bib");
416                                 lyxerr[Debug::LATEX] << "Bibtex database: `"
417                                                      << database << "'" << endl;
418                                 aux_info.databases.insert(database);
419                         }
420                 } else if (reg3.exact_match(token)) {
421                         LRegex::SubMatches const & sub = reg3.exec(token);
422                         string style = LSubstring(token, sub[1].first,
423                                                   sub[1].second);
424                         // token is now the style file
425                         // pass it to the helper
426                         style = ChangeExtension(style, "bst");
427                         lyxerr[Debug::LATEX] << "Bibtex style: `"
428                                              << style << "'" << endl;
429                         aux_info.styles.insert(style);
430                 } else if (reg4.exact_match(token)) {
431                         LRegex::SubMatches const & sub = reg4.exec(token);
432                         string file2 = LSubstring(token, sub[1].first,
433                                                   sub[1].second);
434                         scanAuxFile(file2, aux_info);
435                 }
436         }
437 }
438
439
440 void LaTeX::updateBibtexDependencies(DepTable & dep,
441                                      vector<Aux_Info> const & bibtex_info)
442 {
443         // Since a run of Bibtex mandates more latex runs it is ok to
444         // remove all ".bib" and ".bst" files.
445         dep.remove_files_with_extension(".bib");
446         dep.remove_files_with_extension(".bst");
447         string aux = OnlyFilename(ChangeExtension(file, ".aux"));
448
449         for (vector<Aux_Info>::const_iterator it = bibtex_info.begin();
450              it != bibtex_info.end(); ++it) {
451                 for (set<string>::const_iterator it2 = it->databases.begin();
452                      it2 != it->databases.end(); ++it2) {
453                         string file = findtexfile(*it2, "bib");
454                         if (!file.empty())
455                                 dep.insert(file, true);
456                 }
457
458                 for (set<string>::const_iterator it2 = it->styles.begin();
459                      it2 != it->styles.end(); ++it2) {
460                         string file = findtexfile(*it2, "bst");
461                         if (!file.empty())
462                                 dep.insert(file, true);
463                 }                       
464         }
465 }
466
467
468 bool LaTeX::runBibTeX(vector<Aux_Info> const & bibtex_info)
469 {
470         bool result = false;
471         for (vector<Aux_Info>::const_iterator it = bibtex_info.begin();
472              it != bibtex_info.end(); ++it) {
473                 if (it->databases.empty())
474                         continue;
475                 result = true;
476
477                 string tmp = "bibtex ";
478                 tmp += OnlyFilename(ChangeExtension(it->aux_file, string()));
479                 Systemcalls one;
480                 one.startscript(Systemcalls::System, tmp);
481         }
482         // Return whether bibtex was run
483         return result;
484 }
485
486
487 int LaTeX::scanLogFile(TeXErrors & terr)
488 {
489         int last_line = -1;
490         int line_count = 1;
491         int retval = NO_ERRORS;
492         string tmp = OnlyFilename(ChangeExtension(file, ".log"));
493         lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
494         ifstream ifs(tmp.c_str());
495
496         string token;
497         while (getline(ifs, token)) {
498                 lyxerr[Debug::LATEX] << "Log line: " << token << endl;
499                 
500                 if (token.empty())
501                         continue;
502
503                 if (prefixIs(token, "LaTeX Warning:")) {
504                         // Here shall we handle different
505                         // types of warnings
506                         retval |= LATEX_WARNING;
507                         lyxerr[Debug::LATEX] << "LaTeX Warning." << endl;
508                         if (contains(token, "Rerun to get cross-references")) {
509                                 retval |= RERUN;
510                                 lyxerr[Debug::LATEX]
511                                         << "We should rerun." << endl;
512                         } else if (contains(token, "Citation")
513                                    && contains(token, "on page")
514                                    && contains(token, "undefined")) {
515                                 retval |= UNDEF_CIT;
516                         }
517                 } else if (prefixIs(token, "Package")) {
518                         // Package warnings
519                         retval |= PACKAGE_WARNING;
520                         if (contains(token, "natbib Warning:")) {
521                                 // Natbib warnings
522                                 if (contains(token, "Citation")
523                                     && contains(token, "on page")
524                                     && contains(token, "undefined")) {
525                                         retval |= UNDEF_CIT;
526                                 }
527                         } else if (contains(token, "run BibTeX")) {
528                                 retval |= UNDEF_CIT;
529                         } else if (contains(token, "Rerun LaTeX.")) {
530                                 // at least longtable.sty might use this.
531                                 retval |= RERUN;
532                         }
533                 } else if (prefixIs(token, "! ")) {
534                         // Ok, we have something that looks like a TeX Error
535                         // but what do we really have.
536
537                         // Just get the error description:
538                         string desc(token, 2);
539                         if (contains(token, "LaTeX Error:"))
540                                 retval |= LATEX_ERROR;
541                         // get the next line
542                         string tmp;
543                         int count = 0;
544                         do {
545                                 if (!getline(ifs, tmp))
546                                         break;
547                                 if (++count > 10)
548                                         break;
549                         } while (!prefixIs(tmp, "l."));
550                         if (prefixIs(tmp, "l.")) {
551                                 // we have a latex error
552                                 retval |=  TEX_ERROR;
553                                 if (contains(desc, "Package babel Error: You haven't defined the language"))
554                                         retval |= ERROR_RERUN;
555                                 // get the line number:
556                                 int line = 0;
557                                 sscanf(tmp.c_str(), "l.%d", &line);
558                                 // get the rest of the message:
559                                 string errstr(tmp, tmp.find(' '));
560                                 errstr += '\n';
561                                 getline(ifs, tmp);
562                                 while (!contains(errstr, "l.")
563                                        && !tmp.empty()
564                                        && !prefixIs(tmp, "! ")
565                                        && !contains(tmp, "(job aborted")) {
566                                         errstr += tmp;
567                                         errstr += "\n";
568                                         getline(ifs, tmp);
569                                 }
570                                 lyxerr[Debug::LATEX]
571                                         << "line: " << line << '\n'
572                                         << "Desc: " << desc << '\n'
573                                         << "Text: " << errstr << endl;
574                                 if (line == last_line)
575                                         ++line_count;
576                                 else {
577                                         line_count = 1;
578                                         last_line = line;
579                                 }
580                                 if (line_count <= 5) {
581                                         terr.insertError(line, desc, errstr);
582                                         ++num_errors;
583                                 }
584                         }
585                 } else {
586                         // information messages, TeX warnings and other
587                         // warnings we have not caught earlier.
588                         if (prefixIs(token, "Overfull ")) {
589                                 retval |= TEX_WARNING;
590                         } else if (prefixIs(token, "Underfull ")) {
591                                 retval |= TEX_WARNING;
592                         } else if (contains(token, "Rerun to get citations")) {
593                                 // Natbib seems to use this.
594                                 retval |= UNDEF_CIT;
595                         } else if (contains(token, "No pages of output")) {
596                                 // A dvi file was not created
597                                 retval |= NO_OUTPUT;
598                         } else if (contains(token, "That makes 100 errors")) {
599                                 // More than 100 errors were reprted
600                                 retval |= TOO_MANY_ERRORS;
601                         }
602                 }
603         }
604         lyxerr[Debug::LATEX] << "Log line: " << token << endl;
605         return retval;
606 }
607
608
609 void LaTeX::deplog(DepTable & head)
610 {
611         // This function reads the LaTeX log file end extracts all the external
612         // files used by the LaTeX run. The files are then entered into the
613         // dependency file.
614
615         string const logfile = OnlyFilename(ChangeExtension(file, ".log"));
616
617         LRegex reg1(")* *\\(([^ \\)]+).*");
618         LRegex reg2("File: ([^ ]+).*");
619         LRegex reg3("No file ([^ ]+)\\..*");
620         LRegex reg4("\\\\openout[0-9]+.*=.*`([^ ]+)'\\..*");
621         LRegex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
622         
623         ifstream ifs(logfile.c_str());
624         while (ifs) {
625                 // Ok, the scanning of files here is not sufficient.
626                 // Sometimes files are named by "File: xxx" only
627                 // So I think we should use some regexps to find files instead.
628                 // "(\([^ ]+\)"   should match the "(file " variant
629                 // "File: \([^ ]+\)" should match the "File: file" variant
630                 string foundfile;
631                 string token;
632                 getline(ifs, token);
633                 if (token.empty()) continue;
634                 
635                 if (reg1.exact_match(token)) {
636                         LRegex::SubMatches const & sub = reg1.exec(token);
637                         foundfile = LSubstring(token, sub[1].first,
638                                                sub[1].second);
639                 } else if (reg2.exact_match(token)) {
640                         LRegex::SubMatches const & sub = reg2.exec(token);
641                         foundfile = LSubstring(token, sub[1].first,
642                                                sub[1].second);
643                 } else if (reg3.exact_match(token)) {
644                         LRegex::SubMatches const & sub = reg3.exec(token);
645                         foundfile = LSubstring(token, sub[1].first,
646                                                sub[1].second);
647                 } else if (reg4.exact_match(token)) {
648                         LRegex::SubMatches const & sub = reg4.exec(token);
649                         foundfile = LSubstring(token, sub[1].first,
650                                                sub[1].second);
651                 } else {
652                         continue;
653                 }
654
655                 lyxerr[Debug::DEPEND] << "Found file: " 
656                                       << foundfile << endl;
657                 
658                 // Ok now we found a file.
659                 // Now we should make sure that this is a file that we can
660                 // access through the normal paths.
661                 // We will not try any fancy search methods to
662                 // find the file.
663                 
664                 // (1) foundfile is an
665                 //     absolute path and should
666                 //     be inserted.
667                 if (AbsolutePath(foundfile)) {
668                         lyxerr[Debug::DEPEND] << "AbsolutePath file: " 
669                                               << foundfile << endl;
670                         // On initial insert we want to do the update at once
671                         // since this file can not be a file generated by
672                         // the latex run.
673                         if (FileInfo(foundfile).exist())
674                                 head.insert(foundfile, true);
675                 }
676
677                 // (2) foundfile is in the tmpdir
678                 //     insert it into head
679                 else if (FileInfo(OnlyFilename(foundfile)).exist()) {
680                         if (unwanted.exact_match(foundfile)) {
681                                 lyxerr[Debug::DEPEND]
682                                         << "We don't want "
683                                         << OnlyFilename(foundfile)
684                                         << " in the dep file"
685                                         << endl;
686                         } else if (suffixIs(foundfile, ".tex")) {
687                                 // This is a tex file generated by LyX
688                                 // and latex is not likely to change this
689                                 // during its runs.
690                                 lyxerr[Debug::DEPEND]
691                                         << "Tmpdir TeX file: "
692                                         << OnlyFilename(foundfile)
693                                         << endl;
694                                 head.insert(foundfile, true);
695                         } else {
696                                 lyxerr[Debug::DEPEND]
697                                         << "In tmpdir file:"
698                                         << OnlyFilename(foundfile)
699                                         << endl;
700                                 head.insert(OnlyFilename(foundfile));
701                         }
702                 } else
703                         lyxerr[Debug::DEPEND]
704                                 << "Not a file or we are unable to find it."
705                                 << endl;
706         }
707 }