From 5819201c684d2208a66046df30a463d037776b58 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Fri, 22 Apr 2016 18:27:02 -0700 Subject: [PATCH] GCC 6's new 'misleading indentation' warning showed up a few times in OST, so this commit squashes all the current examples of that. Also adds Fedora 24 alpha 7 (x64) + gcc 6.0.0 to the list of tested platforms. --- ReadMe-2.4.3 | 1 + src/fco/fcodatasourceiterimpl.cpp | 2 +- src/fco/signature.cpp | 28 ++++---- src/fs/fspropset.cpp | 20 ++++-- src/siggen/siggenmain.cpp | 112 ++++++++++++++---------------- src/tripwire/policyupdate.cpp | 50 ++++++------- src/tw/fcoreport.cpp | 28 ++++---- src/tw/textreportviewer.cpp | 14 ++-- src/twcrypto/cryptoarchive.cpp | 10 +-- src/twparser/genreparseinfo.cpp | 14 ++-- src/twparser/parserobjects.cpp | 86 +++++++++++------------ src/util/fileutil.cpp | 93 +++++++++++++------------ 12 files changed, 232 insertions(+), 226 deletions(-) diff --git a/ReadMe-2.4.3 b/ReadMe-2.4.3 index 501bb1a..6db0662 100644 --- a/ReadMe-2.4.3 +++ b/ReadMe-2.4.3 @@ -39,6 +39,7 @@ Linuxes - Raspbian 7 (wheezy) (armv6l) + gcc 4.6.3 - openSuSE Tumbleweed (20160408) (i586) + gcc 5.3.1 - RHEL 6.0 (powerpc64) + gcc 4.4.4 +- Fedora 24 Alpha 7 (amd64) + gcc 6.0.0 OSX - Mac OS X 10.11 + LLVM 7.0.2 / clang-700.1.81 diff --git a/src/fco/fcodatasourceiterimpl.cpp b/src/fco/fcodatasourceiterimpl.cpp index 7c8b9ec..84b241a 100644 --- a/src/fco/fcodatasourceiterimpl.cpp +++ b/src/fco/fcodatasourceiterimpl.cpp @@ -400,7 +400,7 @@ bool cFCODataSourceIterImpl::InsertIntoPeers( iFCO* pFCO ) else mPeers.push_back( pFCO ); - return true; + return true; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/fco/signature.cpp b/src/fco/signature.cpp index 79f2922..87dfc38 100755 --- a/src/fco/signature.cpp +++ b/src/fco/signature.cpp @@ -413,32 +413,32 @@ TSTRING cCRC32Signature::AsString() const if (cArchiveSigGen::Hex()) return AsStringHex(); - TSTRING ret; - char *ps_signature; - char buf[100]; - uint32 local = mCRCInfo.crc; + TSTRING ret; + char *ps_signature; + char buf[100]; + uint32 local = mCRCInfo.crc; - ps_signature = pltob64(&local, buf, 1); - //ps_signature holds base64 representation of mCRCInfo.crc + ps_signature = pltob64(&local, buf, 1); + //ps_signature holds base64 representation of mCRCInfo.crc #ifdef _UNICODE - ret.resize(strlen(ps_signature)); - mbstowcs((TCHAR*)ret.data(), ps_signature, strlen(ps_signature)); + ret.resize(strlen(ps_signature)); + mbstowcs((TCHAR*)ret.data(), ps_signature, strlen(ps_signature)); #else - ret.append(ps_signature); + ret.append(ps_signature); #endif - return ret; + return ret; } TSTRING cCRC32Signature::AsStringHex() const { - TOSTRINGSTREAM ss; + TOSTRINGSTREAM ss; ss.imbue( std::locale::classic() ); - ss.setf( ios::hex, ios::basefield ); + ss.setf( ios::hex, ios::basefield ); - ss << (size_t)mCRCInfo.crc; + ss << (size_t)mCRCInfo.crc; - return ss.str(); + return ss.str(); } bool cCRC32Signature::IsEqual(const iSignature& rhs) const diff --git a/src/fs/fspropset.cpp b/src/fs/fspropset.cpp index 4104706..a1afcd9 100755 --- a/src/fs/fspropset.cpp +++ b/src/fs/fspropset.cpp @@ -207,19 +207,25 @@ cFSPropSet::cFSPropSet(const cFSPropSet& rhs) : iFCOPropSet(), mValidProps(cFSPropSet::PROP_NUMITEMS) { - *this = rhs; + *this = rhs; } const cFSPropSet& cFSPropSet::operator=(const cFSPropSet& rhs) { - mValidProps = rhs.GetValidVector(); + mValidProps = rhs.GetValidVector(); mUndefinedProps = rhs.mUndefinedProps; - for(int i=0; i < PROP_NUMITEMS; i++) - if (mValidProps.ContainsItem(i) && !mUndefinedProps.ContainsItem(i)) - GetPropAt(i)->Copy( ((cFSPropSet&)rhs).GetPropAt(i) ); // call non-const GetPropAt for rhs - // don't want it to assert ContainsItem - return *this; + for (int i=0; i < PROP_NUMITEMS; i++) + { + if (mValidProps.ContainsItem(i) && !mUndefinedProps.ContainsItem(i)) + { + GetPropAt(i)->Copy( ((cFSPropSet&)rhs).GetPropAt(i) ); + // call non-const GetPropAt for rhs + // don't want it to assert ContainsItem + } + } + + return *this; } const cFCOPropVector& cFSPropSet::GetValidVector() const diff --git a/src/siggen/siggenmain.cpp b/src/siggen/siggenmain.cpp index 7d70845..c7eeac2 100644 --- a/src/siggen/siggenmain.cpp +++ b/src/siggen/siggenmain.cpp @@ -78,32 +78,30 @@ void tw_unexpected_handler() static void SiggenInit() { - TSS_Dependency( cSiggen ); + TSS_Dependency( cSiggen ); - static cUserNotifyStdout unStdout; - static cErrorTracer et; - static cErrorReporter er; + static cUserNotifyStdout unStdout; + static cErrorTracer et; + static cErrorReporter er; - // - // initialize iUserNotify - // - iUserNotify::SetInstance( &unStdout ); - iUserNotify::GetInstance()->SetVerboseLevel(iUserNotify::V_NORMAL); + // + // initialize iUserNotify + // + iUserNotify::SetInstance( &unStdout ); + iUserNotify::GetInstance()->SetVerboseLevel(iUserNotify::V_NORMAL); - // - // set up the file system services - // + // + // set up the file system services + // #if IS_UNIX static cUnixFSServices fss; #endif - iFSServices::SetInstance( &fss ); - - - // - // set up an error bucket that will spit things to stderr - // - et.SetChild( &er ); + iFSServices::SetInstance( &fss ); + // + // set up an error bucket that will spit things to stderr + // + et.SetChild( &er ); } int __cdecl _tmain(int argc, const TCHAR** argv) @@ -113,8 +111,8 @@ int __cdecl _tmain(int argc, const TCHAR** argv) if (TimeBombExploded()) return 1; - try - { + try + { // set unexpected and terminate handlers // Note: we do this before Init() in case it attempts to call these handlers // TODO: move this into the Init() routine @@ -122,12 +120,12 @@ int __cdecl _tmain(int argc, const TCHAR** argv) EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler); //cTWInit twInit( argv[0] ); - SiggenInit(); + SiggenInit(); cDebug::SetDebugLevel(cDebug::D_DETAIL); - cSiggenCmdLine siggen; + cSiggenCmdLine siggen; - // first, process the command line + // first, process the command line if (argc < 2) { TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl; @@ -136,66 +134,64 @@ int __cdecl _tmain(int argc, const TCHAR** argv) ret = 1; goto exit; - } + } - // - // Display the version info... - // this is quick and dirty ... just the way I like it :-) -- mdb - // - if (_tcscmp(argv[1], _T("--version")) == 0) - { + // + // Display the version info... + // this is quick and dirty ... just the way I like it :-) -- mdb + // + if (_tcscmp(argv[1], _T("--version")) == 0) + { TCOUT << TSS_GetString( cTW, tw::STR_VERSION_LONG) << std::endl; - ret=0; - goto exit; - } + ret=0; + goto exit; + } - cCmdLineParser cmdLine; - siggen.InitCmdLineParser(cmdLine); - try - { - cmdLine.Parse(argc, argv); - } - catch( eError& e ) - { - cTWUtil::PrintErrorMsg(e); + cCmdLineParser cmdLine; + siggen.InitCmdLineParser(cmdLine); + try + { + cmdLine.Parse(argc, argv); + } + catch( eError& e ) + { + cTWUtil::PrintErrorMsg(e); TCERR << TSS_GetString( cTW, tw::STR_GET_HELP) << std::endl; ret = 1; goto exit; - } + } - cCmdLineIter iter(cmdLine); + cCmdLineIter iter(cmdLine); if (iter.SeekToArg(cSiggenCmdLine::HELP)) { TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl; TCOUT << TSS_GetString( cTW, tw::STR_VERSION) << std::endl; TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_USAGE) << std::endl; - ret = 1; + ret = 1; goto exit; } - if(! siggen.Init(cmdLine)) - { - TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl; + if(! siggen.Init(cmdLine)) + { + TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl; TCOUT << TSS_GetString( cTW, tw::STR_VERSION) << std::endl; TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_USAGE) << std::endl; - ret = 1; + ret = 1; goto exit; - } - ret = siggen.Execute(); + } + ret = siggen.Execute(); - }//end try block - - catch (eError& error) + } //end try block + catch (eError& error) { - cErrorReporter::PrintErrorMsg(error); + cErrorReporter::PrintErrorMsg(error); ASSERT(false); } exit: - - return ret; + return ret; }//end MAIN diff --git a/src/tripwire/policyupdate.cpp b/src/tripwire/policyupdate.cpp index 9b86853..7e4d093 100644 --- a/src/tripwire/policyupdate.cpp +++ b/src/tripwire/policyupdate.cpp @@ -269,41 +269,43 @@ bool cPolicyUpdate::Execute( uint32 flags ) // throw (eError) mpBucket->AddError( e ); bResult = false; } - } - // - // now, we will update the database with everything in the report... - // TODO -- don't do this if the anal flag was passed in - // - TW_NOTIFY_NORMAL( TSS_GetString( cTripwire, tripwire::STR_PU_UPDATE_DB ).c_str() ); - // - cUpdateDb update( mDb, report, mpBucket ); + } + // + // now, we will update the database with everything in the report... + // TODO -- don't do this if the anal flag was passed in + // + TW_NOTIFY_NORMAL( TSS_GetString( cTripwire, tripwire::STR_PU_UPDATE_DB ).c_str() ); + // + cUpdateDb update( mDb, report, mpBucket ); uint32 updateDBFlags = cUpdateDb::FLAG_REPLACE_PROPS; if( flags & FLAG_ERASE_FOOTPRINTS_PU ) + { updateDBFlags |= cUpdateDb::FLAG_ERASE_FOOTPRINTS_UD; + } - update.Execute( updateDBFlags ); - + update.Execute( updateDBFlags ); - // the last thing that we have to do is to remove everything that is still - // in the database that does not belong in the new database (ie -- does not fall under any - // new rules) - // - // TODO -- is there any way to do this that does not involve iterating over the entire database? - // TODO -- I should probably write a general-purpose database iterator class to do this... - // + // the last thing that we have to do is to remove everything that is still + // in the database that does not belong in the new database (ie -- does not fall under any + // new rules) + // + // TODO -- is there any way to do this that does not involve iterating over the entire database? + // TODO -- I should probably write a general-purpose database iterator class to do this... + // - TW_NOTIFY_NORMAL( TSS_GetString( cTripwire, tripwire::STR_PU_PRUNING ).c_str() ); - // - cDbDataSourceIter i( &mDb ); + TW_NOTIFY_NORMAL( TSS_GetString( cTripwire, tripwire::STR_PU_PRUNING ).c_str() ); + // + cDbDataSourceIter i( &mDb ); i.SetErrorBucket(mpBucket); if( flags & FLAG_ERASE_FOOTPRINTS_PU ) + { i.SetIterFlags( iFCODataSourceIter::DO_NOT_MODIFY_OBJECTS ); + } + const cFCOSpecListCanonicalIter newPolIter( mNewPolicy ); + util_PruneExtraObjects( i, newPolIter ); - const cFCOSpecListCanonicalIter newPolIter( mNewPolicy ); - util_PruneExtraObjects( i, newPolIter ); - - return bResult; + return bResult; } diff --git a/src/tw/fcoreport.cpp b/src/tw/fcoreport.cpp index 0d1a1d4..c219b84 100644 --- a/src/tw/fcoreport.cpp +++ b/src/tw/fcoreport.cpp @@ -177,18 +177,18 @@ cFCOReport_i::cNode::cNode(const cFCOReport_i::cNode& rhs) if (mpSpec) mpSpec->AddRef(); - mpSpecAttr = rhs.mpSpecAttr; + mpSpecAttr = rhs.mpSpecAttr; if (mpSpecAttr) mpSpecAttr->AddRef(); - mChanged = rhs.mChanged; - mErrorQueue = rhs.mErrorQueue; + mChanged = rhs.mChanged; + mErrorQueue = rhs.mErrorQueue; mnObjectsScanned = rhs.mnObjectsScanned; } cFCOReport_i::cNode::~cNode() { - Clear(); + Clear(); } void cFCOReport_i::cNode::Clear() @@ -376,8 +376,8 @@ cFCOReportSpecIter::~cFCOReportSpecIter() cFCOReportSpecIter::cFCOReportSpecIter(const cFCOReportSpecIter& rhs) { - mpData = new cFCOReportSpecIter_i(); - *this = rhs; + mpData = new cFCOReportSpecIter_i(); + *this = rhs; } void cFCOReportSpecIter::operator=(const cFCOReportSpecIter& rhs) @@ -385,13 +385,13 @@ void cFCOReportSpecIter::operator=(const cFCOReportSpecIter& rhs) if (mpData == 0) mpData = new cFCOReportSpecIter_i(); - mpData->mpList = rhs.mpData->mpList; - mpData->mIter = rhs.mpData->mIter; + mpData->mpList = rhs.mpData->mpList; + mpData->mIter = rhs.mpData->mIter; } -int cFCOReportSpecIter::GetNumChanged() const +int cFCOReportSpecIter::GetNumChanged() const { - ASSERT(! Done()); + ASSERT(! Done()); return mpData ? mpData->mIter->mChanged.size() : 0; } @@ -406,15 +406,15 @@ void cFCOReportSpecIter::SetObjectsScanned( int nObjectsScanned ) int cFCOReportSpecIter::GetObjectsScanned() const { - ASSERT(! Done()); + ASSERT(! Done()); return mpData ? mpData->mIter->mnObjectsScanned : 0; } void cFCOReportSpecIter::Remove() { - ASSERT(! Done()); - mpData->mIter->Clear(); - mpData->mIter = mpData->mpList->erase(mpData->mIter); + ASSERT(! Done()); + mpData->mIter->Clear(); + mpData->mIter = mpData->mpList->erase(mpData->mIter); } ///////////////////////// diff --git a/src/tw/textreportviewer.cpp b/src/tw/textreportviewer.cpp index 5414045..63397cb 100644 --- a/src/tw/textreportviewer.cpp +++ b/src/tw/textreportviewer.cpp @@ -1115,17 +1115,17 @@ void cTextReportViewer::RemoveFCOsFromReport() //throw (eTextReportViewer) for( ; iter != mFCOsRemoveFromReport.end(); iter++ ) nFCOsToRemove += iter->second->size(); - if( nFCOsToRemove != nFCOsRemoved ) - { - // TODO -- maybe have a different enumeration for this? - throw eTextReportViewerReportCorrupt(); - } + if( nFCOsToRemove != nFCOsRemoved ) + { + // TODO -- maybe have a different enumeration for this? + throw eTextReportViewerReportCorrupt(); + } } void cTextReportViewer::OutputReportHeader() { - if (!WantOutputReportHeader()) - return; + if (!WantOutputReportHeader()) + return; const int headerColumnWidth = 30; diff --git a/src/twcrypto/cryptoarchive.cpp b/src/twcrypto/cryptoarchive.cpp index 493b224..cd250cf 100644 --- a/src/twcrypto/cryptoarchive.cpp +++ b/src/twcrypto/cryptoarchive.cpp @@ -407,16 +407,16 @@ unsigned int cCryptoSource::Pump(unsigned int size) unsigned long cCryptoSource::PumpAll() { - unsigned long total=0; - unsigned int l; + unsigned long total=0; + unsigned int l; if (mBufferLen == 0) mBufferLen = mpCipher->GetBlockSizePlain(); - while ((l=Pump(mBufferLen)) != 0) - total += l; + while ((l=Pump(mBufferLen)) != 0) + total += l; - return total; + return total; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/twparser/genreparseinfo.cpp b/src/twparser/genreparseinfo.cpp index 5b9a968..120006f 100644 --- a/src/twparser/genreparseinfo.cpp +++ b/src/twparser/genreparseinfo.cpp @@ -84,7 +84,7 @@ cGenreParseInfo::cGenreParseInfo() void cGenreParseInfo::AddStopPoint( const cFCOName& name ) { - mStopList.push_back( name ); + mStopList.push_back( name ); } /////////////////////////////////////////////////////////////////////////////// @@ -96,7 +96,7 @@ cGenreParseInfo::AddStopPoint( const cFCOName& name ) void cGenreParseInfo::AddRule(const cParseRule *pnode) { - mRuleList.push_back(pnode); + mRuleList.push_back(pnode); } /////////////////////////////////////////////////////////////////////////////// @@ -255,7 +255,7 @@ bool cGenreParseInfo::InsertVariable( const TSTRING& var, const TSTRING& val ) / if( mLocalPredefVarTable.Lookup(var, dummy) ) throw eParserRedefineVar( var ); - return mLocalVarTable.Insert( var, val ); + return mLocalVarTable.Insert( var, val ); } /////////////////////////////////////////////////////////////////////////////// @@ -265,8 +265,8 @@ bool cGenreParseInfo::InsertVariable( const TSTRING& var, const TSTRING& val ) / /////////////////////////////////////////////////////////////////////////////// bool cGenreParseInfo::LookupVariable( const TSTRING& var, TSTRING& val ) { - if( mLocalPredefVarTable.Lookup( var, val ) || mLocalVarTable.Lookup( var, val ) ) - return true; - else - return ( cParserHelper::GetGlobalVarTable().Lookup( var, val ) ); + if( mLocalPredefVarTable.Lookup( var, val ) || mLocalVarTable.Lookup( var, val ) ) + return true; + else + return ( cParserHelper::GetGlobalVarTable().Lookup( var, val ) ); } diff --git a/src/twparser/parserobjects.cpp b/src/twparser/parserobjects.cpp index cdd82f2..7d71d65 100644 --- a/src/twparser/parserobjects.cpp +++ b/src/twparser/parserobjects.cpp @@ -57,24 +57,24 @@ cParseRule::~cParseRule() const cFCOName& cParseRule::GetName() const { - return mName; + return mName; } void cParseRule::SetName( const cFCOName& name ) { - mName = name; + mName = name; } cParseNamedAttrList * cParseRule::GetAttrList() const { - return mpAttrList; + return mpAttrList; } void cParseRule::SetAttrList(cParseNamedAttrList *pattr) { - mpAttrList = pattr; + mpAttrList = pattr; } /////////////////////////////////////////////////////////////////////////////// @@ -84,7 +84,7 @@ cParseRule::SetAttrList(cParseNamedAttrList *pattr) void cParseRule::SetSpecMaskList(cParseSpecMaskList *pmasks) { - mpSpecMaskList = pmasks; + mpSpecMaskList = pmasks; } @@ -95,11 +95,11 @@ cParseRule::SetSpecMaskList(cParseSpecMaskList *pmasks) int cParseRule::GetNumSpecMasks() const { - // empty list? - if (mpSpecMaskList == NULL) - return 0; + // empty list? + if (mpSpecMaskList == NULL) + return 0; - return mpSpecMaskList->mList.size(); + return mpSpecMaskList->mList.size(); } /////////////////////////////////////////////////////////////////////////////// @@ -109,11 +109,11 @@ cParseRule::GetNumSpecMasks() const int cParseRule::GetNumNamedAttrs() const { - // empty list? - if (mpAttrList == NULL) - return 0; + // empty list? + if (mpAttrList == NULL) + return 0; - return mpAttrList->mList.size(); + return mpAttrList->mList.size(); } /////////////////////////////////////////////////////////////////////////////// @@ -124,19 +124,19 @@ cParseRule::GetNumNamedAttrs() const void cParseRule::Dump() { - cDebug d("\tcParseRule::Dump()"); + cDebug d("\tcParseRule::Dump()"); - d.TraceDebug("name=%s\n", mName.AsString().c_str()); - d.TraceDebug("defspecmask.prop_vector=%s\n", mDefSpecMask.GetPropVectorString().c_str() ); - d.TraceDebug("defspecmask.condition=%s\n", mDefSpecMask.GetCondition().c_str() ); + d.TraceDebug("name=%s\n", mName.AsString().c_str()); + d.TraceDebug("defspecmask.prop_vector=%s\n", mDefSpecMask.GetPropVectorString().c_str() ); + d.TraceDebug("defspecmask.condition=%s\n", mDefSpecMask.GetCondition().c_str() ); - // specmasks - d.TraceDebug(" numspecmasks=%d\n", GetNumSpecMasks()); + // specmasks + d.TraceDebug(" numspecmasks=%d\n", GetNumSpecMasks()); if( mpSpecMaskList ) mpSpecMaskList->Dump(d); - // named attributes - d.TraceDebug(" numattrs=%d\n", GetNumNamedAttrs()); + // named attributes + d.TraceDebug(" numattrs=%d\n", GetNumNamedAttrs()); if( mpAttrList ) mpAttrList->Dump(d); } @@ -160,47 +160,47 @@ cParseSpecMask::~cParseSpecMask() int cParseSpecMask::GetNumAttrs() const { - if (mpAttrList == NULL) - return 0; + if (mpAttrList == NULL) + return 0; - return mpAttrList->mList.size(); + return mpAttrList->mList.size(); } void cParseSpecMask::SetAttrList(cParseNamedAttrList *pattr) { - mpAttrList = pattr; + mpAttrList = pattr; } cParseNamedAttrList * cParseSpecMask::GetAttrList() const { - return mpAttrList; + return mpAttrList; } const TSTRING& cParseSpecMask::GetPropVectorString() const { - return msPV; + return msPV; } const cFCOPropVector& cParseSpecMask::GetPropVector() const { - return mPropVector; + return mPropVector; } const TSTRING& cParseSpecMask::GetCondition() const { - return msCondition; + return msCondition; } void cParseSpecMask::Dump(cDebug &d) const { - d.TraceDebug(" condition=(%s), propvector=:\n", msCondition.c_str(), msPV.c_str() ); + d.TraceDebug(" condition=(%s), propvector=:\n", msCondition.c_str(), msPV.c_str() ); - // dump list of attributes - if (mpAttrList) - mpAttrList->Dump(d); + // dump list of attributes + if (mpAttrList) + mpAttrList->Dump(d); } // @@ -210,10 +210,10 @@ cParseSpecMask::Dump(cDebug &d) const void cParseSpecMaskList::Dump(cDebug &d) const { - std::list::const_iterator ispec; - for (ispec = mList.begin(); ispec != mList.end(); ispec++) { - (*ispec)->Dump(d); - } + std::list::const_iterator ispec; + for (ispec = mList.begin(); ispec != mList.end(); ispec++) { + (*ispec)->Dump(d); + } } // @@ -237,7 +237,7 @@ cParseNamedAttr* cParseNamedAttr::Clone() const void cParseNamedAttr::Dump(cDebug &d) const { - d.TraceDebug(" name=(%s), value=(%s)\n", mstrName.c_str(), mstrValue.c_str()); + d.TraceDebug(" name=(%s), value=(%s)\n", mstrName.c_str(), mstrValue.c_str()); } void cParseNamedAttr::Validate() const @@ -305,11 +305,11 @@ void cParseNamedAttrList::Clear() void cParseNamedAttrList::Dump(cDebug &d) const { - // dump out each named attribute - std::list::const_iterator iattr; - for (iattr = mList.begin(); iattr != mList.end(); iattr++) { - (*iattr)->Dump(d); - } + // dump out each named attribute + std::list::const_iterator iattr; + for (iattr = mList.begin(); iattr != mList.end(); iattr++) { + (*iattr)->Dump(d); + } } diff --git a/src/util/fileutil.cpp b/src/util/fileutil.cpp index 2f01ce0..d6409fa 100644 --- a/src/util/fileutil.cpp +++ b/src/util/fileutil.cpp @@ -61,14 +61,14 @@ void cFileUtil::TestFileExists(const TSTRING& fileName) { if(! cFileUtil::FileExists(fileName)) - { + { TSTRING filenameText = TSS_GetString( cCore, core::STR_ERROR_FILENAME ); filenameText.append(fileName); filenameText.append(1, _T('\n')); filenameText.append(iFSServices::GetInstance()->GetErrString()); throw eOpen(filenameText); - } + } } /////////////////////////////////////////////////////////////////////////////// @@ -76,15 +76,15 @@ void cFileUtil::TestFileExists(const TSTRING& fileName) /////////////////////////////////////////////////////////////////////////////// void cFileUtil::TestFileWritable(const TSTRING& fileName) { - if(! cFileUtil::FileWritable(fileName)) - { + if(! cFileUtil::FileWritable(fileName)) + { TSTRING filenameText = TSS_GetString( cCore, core::STR_ERROR_FILENAME); filenameText.append(fileName); filenameText.append(1, _T('\n')); filenameText.append(iFSServices::GetInstance()->GetErrString()); throw eOpenWrite(filenameText); - } + } } /////////////////////////////////////////////////////////////////////////////// @@ -92,15 +92,15 @@ void cFileUtil::TestFileWritable(const TSTRING& fileName) /////////////////////////////////////////////////////////////////////////////// void cFileUtil::TestFileReadable(const TSTRING& fileName) { - if(! cFileUtil::FileReadable(fileName)) - { + if(! cFileUtil::FileReadable(fileName)) + { TSTRING filenameText = TSS_GetString( cCore, core::STR_ERROR_FILENAME); filenameText.append(fileName); filenameText.append(1, _T('\n')); filenameText.append(iFSServices::GetInstance()->GetErrString()); throw eOpenRead(filenameText); - } + } } /////////////////////////////////////////////////////////////////////////////// @@ -123,16 +123,16 @@ bool cFileUtil::IsDir( const TSTRING& fileName ) bool cFileUtil::IsRegularFile( const TSTRING& fileName ) { - cFSStatArgs s; - try - { - iFSServices::GetInstance()->Stat( fileName, s); - } - catch( eFSServices ) - { - return false; - } - return (s.mFileType == cFSStatArgs::TY_FILE ); + cFSStatArgs s; + try + { + iFSServices::GetInstance()->Stat( fileName, s); + } + catch( eFSServices ) + { + return false; + } + return (s.mFileType == cFSStatArgs::TY_FILE ); } /////////////////////////////////////////////////////////////////////////////// @@ -196,9 +196,9 @@ bool cFileUtil::BackupFile(const TSTRING& filename, bool printWarningOnFailure) if (!cFileUtil::FileExists(filename)) return true; - // if the file is not a regular file, it is not appropriate to back it up - if (!cFileUtil::IsRegularFile(filename)) - return true; + // if the file is not a regular file, it is not appropriate to back it up + if (!cFileUtil::IsRegularFile(filename)) + return true; // if it is not writeable, throw error if (!cFileUtil::FileWritable(filename)) @@ -216,8 +216,9 @@ bool cFileUtil::BackupFile(const TSTRING& filename, bool printWarningOnFailure) // _tunlink(), problems removing the file will be caught by _trename(). _tunlink(backup_filename.c_str()); - // back up the file, preserving permissions and ownership, if possible - if (cFileUtil::Copy(filename.c_str(), backup_filename.c_str()) == false) + // back up the file, preserving permissions and ownership, if possible + if (cFileUtil::Copy(filename.c_str(), backup_filename.c_str()) == false) + { if (printWarningOnFailure && iUserNotify::GetInstance()->GetVerboseLevel() >= iUserNotify::V_NORMAL) { @@ -230,7 +231,7 @@ bool cFileUtil::BackupFile(const TSTRING& filename, bool printWarningOnFailure) cErrorReporter::PrintErrorMsg(eFileUtilBackup(estr, eError::NON_FATAL|eError::SUPRESS_THIRD_MSG)); } - + } return true; } @@ -238,37 +239,37 @@ bool cFileUtil::Copy(const TSTRING& src_path, const TSTRING& dest_path) { #if IS_UNIX - enum { BUF_SIZE = 4096 }; - int8 buf[BUF_SIZE]; - int nBytesRead; + enum { BUF_SIZE = 4096 }; + int8 buf[BUF_SIZE]; + int nBytesRead; - cFile srcFile, destFile; + cFile srcFile, destFile; - srcFile.Open(src_path.c_str()); - // Create destination file. We'll fix the permissions later. - destFile.Open(dest_path.c_str(), cFile::OPEN_WRITE|cFile::OPEN_CREATE); + srcFile.Open(src_path.c_str()); + // Create destination file. We'll fix the permissions later. + destFile.Open(dest_path.c_str(), cFile::OPEN_WRITE|cFile::OPEN_CREATE); - for (int i = srcFile.GetSize(); i > 0; ) - { - nBytesRead = srcFile.Read(buf, BUF_SIZE); - destFile.Write(buf, nBytesRead); - i -= nBytesRead; - } + for (int i = srcFile.GetSize(); i > 0; ) + { + nBytesRead = srcFile.Read(buf, BUF_SIZE); + destFile.Write(buf, nBytesRead); + i -= nBytesRead; + } - struct stat srcStat; - stat(src_path.c_str(), &srcStat); + struct stat srcStat; + stat(src_path.c_str(), &srcStat); - // restore permissions and ownership - // don't worry if it fails. it's not mission-critical. - chmod( dest_path.c_str(), srcStat.st_mode ); - chown( dest_path.c_str(), srcStat.st_uid, srcStat.st_gid ); + // restore permissions and ownership + // don't worry if it fails. it's not mission-critical. + chmod( dest_path.c_str(), srcStat.st_mode ); + chown( dest_path.c_str(), srcStat.st_uid, srcStat.st_gid ); - srcFile.Close(); - destFile.Close(); + srcFile.Close(); + destFile.Close(); #endif - return true; + return true; }