]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
Account for old versions of Pygments
[lyx.git] / src / VCBackend.cpp
index 974fa7d9c903d88f4289b816af432c11623d6b58..a152a28d101e11f209f202243f6c0b011a91d2f3 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "VCBackend.h"
 #include "Buffer.h"
+#include "DispatchResult.h"
 #include "LyX.h"
 #include "FuncRequest.h"
 
@@ -30,6 +31,8 @@
 #include "support/TempFile.h"
 
 #include <fstream>
+#include <iomanip>
+#include <sstream>
 
 using namespace std;
 using namespace lyx::support;
@@ -168,6 +171,8 @@ void RCS::scanMaster()
        LYXERR(Debug::LYXVC, "LyXVC::RCS: scanMaster: " << master_);
 
        ifstream ifs(master_.toFilesystemEncoding().c_str());
+       // limit the size of strings we read to avoid memory problems
+       ifs >> setw(65636);
 
        string token;
        bool read_enough = false;
@@ -282,7 +287,7 @@ LyXVC::CommandResult RCS::checkIn(string const & msg, string & log)
 
 bool RCS::checkInEnabled()
 {
-       return owner_ && !owner_->isReadonly();
+       return owner_ && !owner_->hasReadonlyFlag();
 }
 
 
@@ -324,7 +329,7 @@ string RCS::checkOut()
 
 bool RCS::checkOutEnabled()
 {
-       return owner_ && owner_->isReadonly();
+       return owner_ && owner_->hasReadonlyFlag();
 }
 
 
@@ -494,6 +499,7 @@ bool RCS::prepareFileRevision(string const &revis, string & f)
                      + quoteName(onlyFileName(owner_->absFileName()))
                      + " > " + quoteName(tmpf.toFilesystemEncoding()),
                FileName(owner_->filePath()));
+       tmpf.refresh();
        if (tmpf.isFileEmpty())
                return false;
 
@@ -563,8 +569,10 @@ void CVS::scanMaster()
                if (contains(line, tmpf)) {
                        // Ok extract the fields.
                        smatch sm;
-
-                       regex_match(line, sm, reg);
+                       if (!regex_match(line, sm, reg)) {
+                               LYXERR(Debug::LYXVC, "\t  Cannot parse line. Skipping.");
+                               continue;
+                       }
 
                        //sm[0]; // whole matched string
                        //sm[1]; // filename
@@ -1118,6 +1126,7 @@ bool CVS::prepareFileRevision(string const & revis, string & f)
        doVCCommandWithOutput("cvs update -p -r" + rev + ' '
                + getTarget(File),
                FileName(owner_->filePath()), tmpf);
+       tmpf.refresh();
        if (tmpf.isFileEmpty())
                return false;
 
@@ -1429,7 +1438,7 @@ bool SVN::fileLock(bool lock, FileName const & tmpf, string &status)
                    + " > " + quoteName(tmpf.toFilesystemEncoding()),
                    FileName(owner_->filePath()));
 
-       // Lock error messages go unfortunately on stderr and are unreachible this way.
+       // Lock error messages go unfortunately on stderr and are unreachable this way.
        ifstream ifs(tmpf.toFilesystemEncoding().c_str());
        string line;
        while (ifs) {
@@ -1783,6 +1792,7 @@ bool SVN::prepareFileRevision(string const & revis, string & f)
                      + quoteName(onlyFileName(owner_->absFileName()))
                      + " > " + quoteName(tmpf.toFilesystemEncoding()),
                FileName(owner_->filePath()));
+       tmpf.refresh();
        if (tmpf.isFileEmpty())
                return false;
 
@@ -1842,6 +1852,7 @@ FileName const GIT::findFile(FileName const & file)
                        quoteName(fname) + " > " +
                        quoteName(tmpf.toFilesystemEncoding()),
                        file.onlyPath());
+       tmpf.refresh();
        bool found = !tmpf.isFileEmpty();
        LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled"));
        return found ? file : FileName();
@@ -2232,6 +2243,7 @@ bool GIT::prepareFileRevision(string const & revis, string & f)
                      + quoteName(onlyFileName(owner_->absFileName()))
                      + " > " + quoteName(tmpf.toFilesystemEncoding()),
                FileName(owner_->filePath()));
+       tmpf.refresh();
        if (tmpf.isFileEmpty())
                return false;
 
@@ -2248,7 +2260,7 @@ bool GIT::prepareFileRevisionEnabled()
 
 bool GIT::toggleReadOnlyEnabled()
 {
-       return false;
+       return true;
 }