]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
Check return value of regex_match instead of looking at first match
[lyx.git] / src / VCBackend.cpp
index 6350766dac7e57ef324c31f055182bd244b9239b..e4104bd0b0a9f0a8365f0c4cd13c97be0c6eaa9d 100644 (file)
@@ -31,6 +31,8 @@
 #include "support/TempFile.h"
 
 #include <fstream>
+#include <iomanip>
+#include <sstream>
 
 using namespace std;
 using namespace lyx::support;
@@ -169,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;
@@ -283,7 +287,7 @@ LyXVC::CommandResult RCS::checkIn(string const & msg, string & log)
 
 bool RCS::checkInEnabled()
 {
-       return owner_ && !owner_->isReadonly();
+       return owner_ && !owner_->hasReadonlyFlag();
 }
 
 
@@ -325,7 +329,7 @@ string RCS::checkOut()
 
 bool RCS::checkOutEnabled()
 {
-       return owner_ && owner_->isReadonly();
+       return owner_ && owner_->hasReadonlyFlag();
 }
 
 
@@ -566,6 +570,8 @@ void CVS::scanMaster()
                        // Ok extract the fields.
                        smatch sm;
 
+                       // false positive from coverity
+                       // coverity[CHECKED_RETURN]
                        regex_match(line, sm, reg);
 
                        //sm[0]; // whole matched string
@@ -1432,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) {
@@ -2254,7 +2260,7 @@ bool GIT::prepareFileRevisionEnabled()
 
 bool GIT::toggleReadOnlyEnabled()
 {
-       return false;
+       return true;
 }