]> git.lyx.org Git - features.git/blobdiff - src/LaTeX.C
clear()->erase() ; lots of using directives for cxx
[features.git] / src / LaTeX.C
index 7018a24737796c83d195316cd4c9b222424c953d..951e5c91e0e6dba997e6533d3bf5491842408235 100644 (file)
@@ -3,9 +3,9 @@
  * 
  *           LyX, The Document Processor        
  *          Copyright 1995 Matthias Ettrich
- *           Copyright 1995-1999 The LyX Team.
+ *           Copyright 1995-2000 The LyX Team.
  *
- *           This file is Copyright 1996-1999
+ *           This file is Copyright 1996-2000
  *           Lars Gullik Bjønnes
  *
  * ====================================================== 
@@ -33,6 +33,8 @@
 #include "gettext.h"
 
 using std::ifstream;
+using std::getline;
+using std::endl;
 
 // TODO: in no particular order
 // - get rid of the extern BufferList and the call to
@@ -97,6 +99,31 @@ LaTeX::LaTeX(string const & latex, string const & f, string const & p)
 }
 
 
+void LaTeX::deleteFilesOnError() const
+{
+       // currently just a dummy function.
+
+       // What files do we have to delete?
+
+       // This will at least make latex do all the runs
+       ::unlink(depfile.c_str());
+
+       // but the reason for the error might be in a generated file...
+
+       // bibtex file
+       string bbl = ChangeExtension(file, ".bbl", true);
+       ::unlink(bbl.c_str());
+
+       // makeindex file
+       string ind = ChangeExtension(file, ".ind", true);
+       ::unlink(ind.c_str());
+       
+       // Also remove the aux file
+       string aux = ChangeExtension(file, ".aux", true);
+       ::unlink(aux.c_str());
+}
+
+
 int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
        // We know that this function will only be run if the lyx buffer
        // has been changed. We also know that a newly written .tex file
@@ -150,7 +177,11 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
                        minib->Store();
                        this->operator()();
                        scanres = scanLogFile(terr);
-                       if (scanres & LaTeX::ERRORS) return scanres; // return on error
+                       if (scanres & LaTeX::ERRORS) {
+                               deleteFilesOnError();
+                               return scanres; // return on error
+                       }
+                       
                        run_bibtex = scanAux(head);
                        if (run_bibtex)
                                lyxerr[Debug::DEPEND]
@@ -163,6 +194,7 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
                ++count;
                lyxerr[Debug::DEPEND]
                        << "Dependency file does not exist" << endl;
+               
                lyxerr[Debug::LATEX]
                        << "Run #" << count << endl;
                head.insert(file, true);
@@ -170,7 +202,11 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
                minib->Store();
                this->operator()();
                scanres = scanLogFile(terr);
-               if (scanres & LaTeX::ERRORS) return scanres; // return on error
+               if (scanres & LaTeX::ERRORS) {
+                       deleteFilesOnError();
+                       return scanres; // return on error
+               }
+               
        }
 
        // update the dependencies.
@@ -231,7 +267,11 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
                minib->Store();
                this->operator()();
                scanres = scanLogFile(terr);
-               if (scanres & LaTeX::ERRORS) return scanres; // return on error
+               if (scanres & LaTeX::ERRORS) {
+                       deleteFilesOnError();
+                       return scanres; // return on error
+               }
+               
                // update the depedencies
                deplog(head); // reads the latex log
                head.update();
@@ -277,7 +317,11 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
                minib->Store();
                this->operator()();
                scanres = scanLogFile(terr);
-               if (scanres & LaTeX::ERRORS) return scanres; // return on error
+               if (scanres & LaTeX::ERRORS) {
+                       deleteFilesOnError();
+                       return scanres; // return on error
+               }
+               
                // keep this updated
                head.update();
        }