Hello,

Here are 2 patches that help towards being able to run GIFT on a modern
machine.
(Debian 11, g++ 10.2.1)

- modern-cpp.patch allows for compilation
- fix-undefined-behavior-when-writing-errors.patch stops undefined behavior
when GIFT wants to write error messages. It was writing "\n" to console on
an infinite loop for me.

Please consider applying them.

Thanks,
Sarah
commit 92801a7c550977b877d576047981be584a6313a6
Author: Sarah Kate <[email protected]>
Date:   Thu Oct 6 21:33:22 2022 -0400

    Get it to build with modern C++ compiler

diff --git a/libGIFTAcDistanceMatrix/include/CPersistentMatrix.h b/libGIFTAcDistanceMatrix/include/CPersistentMatrix.h
index 67cdefa..047712e 100644
--- a/libGIFTAcDistanceMatrix/include/CPersistentMatrix.h
+++ b/libGIFTAcDistanceMatrix/include/CPersistentMatrix.h
@@ -75,7 +75,7 @@ CPersistentMatrix<T>::CPersistentMatrix(long inXSize,
 
 template<class T>
 bool CPersistentMatrix<T>::create(char const* inFileName)const{
-  fstream* lFile=new fstream(inFileName,fstream::out+fstream::in);
+  fstream* lFile=new fstream(inFileName,fstream::out | fstream::in);
   CPersistentVector<T> lLine(mXSize);
   if(lFile){
     for(long i=0;
@@ -202,7 +202,7 @@ bool CPersistentMatrix<T>::setValue(long inX,
 
   mContent->flush();
 
-  return (*mContent);
+  return !!(*mContent);
 }
 
 ///
diff --git a/libGIFTAcDistanceMatrix/include/CPersistentVector.h b/libGIFTAcDistanceMatrix/include/CPersistentVector.h
index ba2bfa6..1fb0bdc 100644
--- a/libGIFTAcDistanceMatrix/include/CPersistentVector.h
+++ b/libGIFTAcDistanceMatrix/include/CPersistentVector.h
@@ -110,10 +110,10 @@ bool CPersistentVector<T>::read(istream& inStream,
 
     assert(lToBeRead>=0 && lToBeRead<=1);
 
-    push_back(lToBeRead);
+    vector<T>::push_back(lToBeRead);
   }
   mLength=inLength;
-  return inStream;
+  return !!inStream;
 }
 
 template<class T>
@@ -125,7 +125,7 @@ bool CPersistentVector<T>::write(ostream& outStream)const{
 		  *i);
   }
   outStream << flush;
-  return outStream;
+  return !!outStream;
 }
 
 #endif
diff --git a/libGIFTAcInvertedFile/cc/CAcIFFileSystem.cc b/libGIFTAcInvertedFile/cc/CAcIFFileSystem.cc
index 4c8d5e5..a7ded18 100644
--- a/libGIFTAcInvertedFile/cc/CAcIFFileSystem.cc
+++ b/libGIFTAcInvertedFile/cc/CAcIFFileSystem.cc
@@ -601,7 +601,7 @@ bool CAcIFFileSystem::newGenerateInvertedFile(){
   ifstream lInAuxiliaryFile(lLastFileUsed.c_str());
 
   cout << "Opening sorted stream for reading. State (should be '1'): "
-       << lInAuxiliaryFile
+       << !!lInAuxiliaryFile
        << endl;
   
   if(lInAuxiliaryFile){
diff --git a/libGIFTAcInvertedFile/cc/CAdditionalDocumentInformation.cc b/libGIFTAcInvertedFile/cc/CAdditionalDocumentInformation.cc
index 3a0336e..2a3d8a3 100644
--- a/libGIFTAcInvertedFile/cc/CAdditionalDocumentInformation.cc
+++ b/libGIFTAcInvertedFile/cc/CAdditionalDocumentInformation.cc
@@ -267,7 +267,7 @@ bool CAdditionalDocumentInformation::output(ostream& outStream)const{
 	    << mDFSquareSum
 	    << " " 
 	    << mSquareDFLogICFSum;
- return outStream;
+ return !!outStream;
 };
 
 
@@ -299,7 +299,7 @@ bool CAdditionalDocumentInformation::input(istream& inStream){
        << flush 
        << endl;
 #endif
-  return inStream;
+  return !!inStream;
 };
 
 
diff --git a/libGIFTAcInvertedFile/cc/CDocumentFrequencyElement.cc b/libGIFTAcInvertedFile/cc/CDocumentFrequencyElement.cc
index 84f13db..84569c8 100644
--- a/libGIFTAcInvertedFile/cc/CDocumentFrequencyElement.cc
+++ b/libGIFTAcInvertedFile/cc/CDocumentFrequencyElement.cc
@@ -66,7 +66,7 @@ static unsigned const int sFREQ_MAX=(FREQ_MAX);
 bool CDocumentFrequencyElement::input(istream& inStream){
   inStream >> mContent.mID 
 	   >> mContent.mDocumentFrequency;
-  return inStream;
+  return !!inStream;
 };
 
 
@@ -87,7 +87,7 @@ bool CDocumentFrequencyElement::output(ostream& outStream)const{
 	    << " " 
 	    << mContent.mDocumentFrequency
 	    << endl;
-  return outStream;
+  return !!outStream;
 };
 
 
@@ -124,7 +124,7 @@ bool CDocumentFrequencyElement::writeBinary(ostream& outStream)const{
   outStream.write((char*)this,
 		  sizeof(*this));
 #endif
-  return outStream;
+  return !!outStream;
 };
 
 
diff --git a/libGIFTAcURL2FTS/cc/CAcURL2FTS.cc b/libGIFTAcURL2FTS/cc/CAcURL2FTS.cc
index fd1cbd5..5d247e0 100644
--- a/libGIFTAcURL2FTS/cc/CAcURL2FTS.cc
+++ b/libGIFTAcURL2FTS/cc/CAcURL2FTS.cc
@@ -120,7 +120,7 @@ CAcURL2FTS::CAcURL2FTS(const CXMLElement& inCollectionElement):
     cout << " ...success." 
 	 << endl;
   
-  mWellConstructed=mURLToFeatureFile;
+  mWellConstructed=!!mURLToFeatureFile;
   
   mURLToFFN.clear();
   mURLToID.clear();
diff --git a/libMRML/cc/CAccessorImplementation.cc b/libMRML/cc/CAccessorImplementation.cc
index 0247098..abb6e30 100644
--- a/libMRML/cc/CAccessorImplementation.cc
+++ b/libMRML/cc/CAccessorImplementation.cc
@@ -310,7 +310,8 @@ pair<bool,TID> CAccessorImplementation::URLToID(const string& inURL)const
   
   if(lI!=mURLToID.end())
     {
-      return make_pair<bool,TID>(true,(*lI).second);
+      auto value = (*lI).second;
+      return make_pair<bool,TID>(true,move(value));
     }
   else
     {
commit fe82a91f19aa16be7fb1e3c019014f889e47436d
Author: Sarah Kate <[email protected]>
Date:   Fri Oct 7 15:28:48 2022 -0400

    Exception operator<<'s need to return the ostream
    
    This may have worked before, but it was undefined behavior.

diff --git a/libMRML/cc/GIFTExceptions.cc b/libMRML/cc/GIFTExceptions.cc
index d2225b6..1d54778 100644
--- a/libMRML/cc/GIFTExceptions.cc
+++ b/libMRML/cc/GIFTExceptions.cc
@@ -48,6 +48,7 @@ ostream& operator<<(ostream& outStream,const GIFTException& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 
 void GIFTException::dummy(){//needed for RTTI/exception catching
@@ -67,6 +68,7 @@ ostream& operator<<(ostream& outStream,const VEProgrammingMistake& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 
 VENotFound::VENotFound(const char* inMessage):
@@ -78,6 +80,7 @@ ostream& operator<<(ostream& outStream,const VENotFound& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 
 VEBaseUnknown::VEBaseUnknown(const char* inMessage):
@@ -89,6 +92,7 @@ ostream& operator<<(ostream& outStream,const VEBaseUnknown& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 
 
@@ -101,6 +105,7 @@ ostream& operator<<(ostream& outStream,const VEDoubleInsert& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 
 
@@ -113,6 +118,7 @@ ostream& operator<<(ostream& outStream,const VEWrongAccessor& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 
 
@@ -125,6 +131,7 @@ ostream& operator<<(ostream& outStream,const VEWrongAlgorithm& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 VEWrongBaseType::VEWrongBaseType(const char* inMessage):
     GIFTException(inMessage){
@@ -135,6 +142,7 @@ ostream& operator<<(ostream& outStream,const VEWrongBaseType& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 VEConfigurationError::VEConfigurationError(const char* inMessage):
     GIFTException(inMessage){
@@ -145,6 +153,7 @@ ostream& operator<<(ostream& outStream,const VEConfigurationError& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 
 
@@ -157,5 +166,6 @@ ostream& operator<<(ostream& outStream,const VEUnknownSession& inException){
 	      << inException.mMessage
 	      << flush
 	      << endl;
+    return outStream;
 }
 
_______________________________________________
help-GIFT mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-gift

Reply via email to