]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeX.cpp
Added Liviu Andronic, and modified generate_contributions.py to match what was in...
[lyx.git] / src / LaTeX.cpp
index 7c9d8e077862c9d1eb5386ebff63f73b34101ec5..1910b1dc7a7c317f77f9549bad4d5109b86ad10c 100644 (file)
 
 #include "BufferList.h"
 #include "LaTeX.h"
-#include "gettext.h"
 #include "LyXRC.h"
-#include "debug.h"
 #include "DepTable.h"
 
-#include "support/filetools.h"
+#include "support/debug.h"
 #include "support/convert.h"
+#include "support/FileName.h"
+#include "support/filetools.h"
+#include "support/gettext.h"
 #include "support/lstrings.h"
-#include "support/lyxlib.h"
 #include "support/Systemcall.h"
 #include "support/os.h"
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
 #include <boost/regex.hpp>
 
 #include <fstream>
 using boost::regex;
 using boost::smatch;
 
-#ifndef CXX_GLOBAL_CSTD
-using std::sscanf;
-#endif
-
-using std::endl;
-using std::getline;
-using std::string;
-using std::ifstream;
-using std::set;
-using std::vector;
-
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
-using support::absolutePath;
-using support::bformat;
-using support::changeExtension;
-using support::contains;
-using support::FileName;
-using support::findtexfile;
-using support::getcwd;
-using support::makeAbsPath;
-using support::onlyFilename;
-using support::prefixIs;
-using support::quoteName;
-using support::removeExtension;
-using support::rtrim;
-using support::rsplit;
-using support::split;
-using support::subst;
-using support::suffixIs;
-using support::Systemcall;
-using support::unlink;
-using support::trim;
-
 namespace os = support::os;
-namespace fs = boost::filesystem;
 
 // TODO: in no particular order
 // - get rid of the call to
@@ -151,29 +118,29 @@ void LaTeX::deleteFilesOnError() const
        // What files do we have to delete?
 
        // This will at least make latex do all the runs
-       unlink(depfile);
+       depfile.removeFile();
 
        // but the reason for the error might be in a generated file...
 
        // bibtex file
        FileName const bbl(changeExtension(file.absFilename(), ".bbl"));
-       unlink(bbl);
+       bbl.removeFile();
 
        // makeindex file
        FileName const ind(changeExtension(file.absFilename(), ".ind"));
-       unlink(ind);
+       ind.removeFile();
 
        // nomencl file
        FileName const nls(changeExtension(file.absFilename(), ".nls"));
-       unlink(nls);
+       nls.removeFile();
 
        // nomencl file (old version of the package)
        FileName const gls(changeExtension(file.absFilename(), ".gls"));
-       unlink(gls);
+       gls.removeFile();
 
        // Also remove the aux file
        FileName const aux(changeExtension(file.absFilename(), ".aux"));
-       unlink(aux);
+       aux.removeFile();
 }
 
 
@@ -192,7 +159,7 @@ int LaTeX::run(TeXErrors & terr)
        bool rerun = false; // rerun requested
 
        // The class LaTeX does not know the temp path.
-       theBufferList().updateIncludedTeXfiles(getcwd().absFilename(),
+       theBufferList().updateIncludedTeXfiles(FileName::getcwd().absFilename(),
                runparams);
 
        // Never write the depfile if an error was encountered.
@@ -288,7 +255,7 @@ int LaTeX::run(TeXErrors & terr)
        // memoir (at least) writes an empty *idx file in the first place.
        // A second latex run is needed.
        FileName const idxfile(changeExtension(file.absFilename(), ".idx"));
-       rerun = idxfile.exists() && fs::is_empty(idxfile.toFilesystemEncoding());
+       rerun = idxfile.exists() && idxfile.isFileEmpty();
 
        // run makeindex
        if (head.haschanged(idxfile)) {
@@ -627,6 +594,12 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                        if (contains(token, "Rerun to get cross-references")) {
                                retval |= RERUN;
                                LYXERR(Debug::LATEX, "We should rerun.");
+                       // package clefval needs 2 latex runs before bibtex
+                       } else if (contains(token, "Value of")
+                                  && contains(token, "on page")
+                                  && contains(token, "undefined")) {
+                               retval |= ERROR_RERUN;
+                               LYXERR(Debug::LATEX, "Force rerun.");
                        } else if (contains(token, "Citation")
                                   && contains(token, "on page")
                                   && contains(token, "undefined")) {
@@ -778,12 +751,12 @@ bool handleFoundFile(string const & ff, DepTable & head)
        // (1) foundfile is an
        //     absolute path and should
        //     be inserted.
-       if (absolutePath(foundfile)) {
+       FileName absname(foundfile);
+       if (absname.isAbsolute()) {
                LYXERR(Debug::DEPEND, "AbsolutePath file: " << foundfile);
                // On initial insert we want to do the update at once
                // since this file cannot be a file generated by
                // the latex run.
-               FileName absname(foundfile);
                if (!insertIfExists(absname, head)) {
                        // check for spaces
                        string strippedfile = foundfile;
@@ -806,7 +779,7 @@ bool handleFoundFile(string const & ff, DepTable & head)
        }
 
        string onlyfile = onlyFilename(foundfile);
-       FileName absname(makeAbsPath(onlyfile));
+       absname = makeAbsPath(onlyfile);
 
        // check for spaces
        while (contains(foundfile, ' ')) {