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.

This commit is contained in:
Brian Cox 2016-04-22 18:27:02 -07:00
parent a488e1bfec
commit 5819201c68
12 changed files with 232 additions and 226 deletions

View File

@ -39,6 +39,7 @@ Linuxes
- Raspbian 7 (wheezy) (armv6l) + gcc 4.6.3 - Raspbian 7 (wheezy) (armv6l) + gcc 4.6.3
- openSuSE Tumbleweed (20160408) (i586) + gcc 5.3.1 - openSuSE Tumbleweed (20160408) (i586) + gcc 5.3.1
- RHEL 6.0 (powerpc64) + gcc 4.4.4 - RHEL 6.0 (powerpc64) + gcc 4.4.4
- Fedora 24 Alpha 7 (amd64) + gcc 6.0.0
OSX OSX
- Mac OS X 10.11 + LLVM 7.0.2 / clang-700.1.81 - Mac OS X 10.11 + LLVM 7.0.2 / clang-700.1.81

View File

@ -400,7 +400,7 @@ bool cFCODataSourceIterImpl::InsertIntoPeers( iFCO* pFCO )
else else
mPeers.push_back( pFCO ); mPeers.push_back( pFCO );
return true; return true;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -413,32 +413,32 @@ TSTRING cCRC32Signature::AsString() const
if (cArchiveSigGen::Hex()) if (cArchiveSigGen::Hex())
return AsStringHex(); return AsStringHex();
TSTRING ret; TSTRING ret;
char *ps_signature; char *ps_signature;
char buf[100]; char buf[100];
uint32 local = mCRCInfo.crc; uint32 local = mCRCInfo.crc;
ps_signature = pltob64(&local, buf, 1); ps_signature = pltob64(&local, buf, 1);
//ps_signature holds base64 representation of mCRCInfo.crc //ps_signature holds base64 representation of mCRCInfo.crc
#ifdef _UNICODE #ifdef _UNICODE
ret.resize(strlen(ps_signature)); ret.resize(strlen(ps_signature));
mbstowcs((TCHAR*)ret.data(), ps_signature, strlen(ps_signature)); mbstowcs((TCHAR*)ret.data(), ps_signature, strlen(ps_signature));
#else #else
ret.append(ps_signature); ret.append(ps_signature);
#endif #endif
return ret; return ret;
} }
TSTRING cCRC32Signature::AsStringHex() const TSTRING cCRC32Signature::AsStringHex() const
{ {
TOSTRINGSTREAM ss; TOSTRINGSTREAM ss;
ss.imbue( std::locale::classic() ); 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 bool cCRC32Signature::IsEqual(const iSignature& rhs) const

View File

@ -207,19 +207,25 @@ cFSPropSet::cFSPropSet(const cFSPropSet& rhs) :
iFCOPropSet(), iFCOPropSet(),
mValidProps(cFSPropSet::PROP_NUMITEMS) mValidProps(cFSPropSet::PROP_NUMITEMS)
{ {
*this = rhs; *this = rhs;
} }
const cFSPropSet& cFSPropSet::operator=(const cFSPropSet& rhs) const cFSPropSet& cFSPropSet::operator=(const cFSPropSet& rhs)
{ {
mValidProps = rhs.GetValidVector(); mValidProps = rhs.GetValidVector();
mUndefinedProps = rhs.mUndefinedProps; mUndefinedProps = rhs.mUndefinedProps;
for(int i=0; i < PROP_NUMITEMS; i++) 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 if (mValidProps.ContainsItem(i) && !mUndefinedProps.ContainsItem(i))
// don't want it to assert ContainsItem {
return *this; 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 const cFCOPropVector& cFSPropSet::GetValidVector() const

View File

@ -78,32 +78,30 @@ void tw_unexpected_handler()
static void SiggenInit() static void SiggenInit()
{ {
TSS_Dependency( cSiggen ); TSS_Dependency( cSiggen );
static cUserNotifyStdout unStdout; static cUserNotifyStdout unStdout;
static cErrorTracer et; static cErrorTracer et;
static cErrorReporter er; static cErrorReporter er;
// //
// initialize iUserNotify // initialize iUserNotify
// //
iUserNotify::SetInstance( &unStdout ); iUserNotify::SetInstance( &unStdout );
iUserNotify::GetInstance()->SetVerboseLevel(iUserNotify::V_NORMAL); iUserNotify::GetInstance()->SetVerboseLevel(iUserNotify::V_NORMAL);
// //
// set up the file system services // set up the file system services
// //
#if IS_UNIX #if IS_UNIX
static cUnixFSServices fss; static cUnixFSServices fss;
#endif #endif
iFSServices::SetInstance( &fss ); iFSServices::SetInstance( &fss );
//
// set up an error bucket that will spit things to stderr
//
et.SetChild( &er );
//
// set up an error bucket that will spit things to stderr
//
et.SetChild( &er );
} }
int __cdecl _tmain(int argc, const TCHAR** argv) int __cdecl _tmain(int argc, const TCHAR** argv)
@ -113,8 +111,8 @@ int __cdecl _tmain(int argc, const TCHAR** argv)
if (TimeBombExploded()) if (TimeBombExploded())
return 1; return 1;
try try
{ {
// set unexpected and terminate handlers // set unexpected and terminate handlers
// Note: we do this before Init() in case it attempts to call these handlers // Note: we do this before Init() in case it attempts to call these handlers
// TODO: move this into the Init() routine // 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); EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
//cTWInit twInit( argv[0] ); //cTWInit twInit( argv[0] );
SiggenInit(); SiggenInit();
cDebug::SetDebugLevel(cDebug::D_DETAIL); cDebug::SetDebugLevel(cDebug::D_DETAIL);
cSiggenCmdLine siggen; cSiggenCmdLine siggen;
// first, process the command line // first, process the command line
if (argc < 2) if (argc < 2)
{ {
TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl; TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl;
@ -136,66 +134,64 @@ int __cdecl _tmain(int argc, const TCHAR** argv)
ret = 1; ret = 1;
goto exit; goto exit;
} }
// //
// Display the version info... // Display the version info...
// this is quick and dirty ... just the way I like it :-) -- mdb // this is quick and dirty ... just the way I like it :-) -- mdb
// //
if (_tcscmp(argv[1], _T("--version")) == 0) if (_tcscmp(argv[1], _T("--version")) == 0)
{ {
TCOUT << TSS_GetString( cTW, tw::STR_VERSION_LONG) << std::endl; TCOUT << TSS_GetString( cTW, tw::STR_VERSION_LONG) << std::endl;
ret=0; ret=0;
goto exit; goto exit;
} }
cCmdLineParser cmdLine; cCmdLineParser cmdLine;
siggen.InitCmdLineParser(cmdLine); siggen.InitCmdLineParser(cmdLine);
try try
{ {
cmdLine.Parse(argc, argv); cmdLine.Parse(argc, argv);
} }
catch( eError& e ) catch( eError& e )
{ {
cTWUtil::PrintErrorMsg(e); cTWUtil::PrintErrorMsg(e);
TCERR << TSS_GetString( cTW, tw::STR_GET_HELP) << std::endl; TCERR << TSS_GetString( cTW, tw::STR_GET_HELP) << std::endl;
ret = 1; ret = 1;
goto exit; goto exit;
} }
cCmdLineIter iter(cmdLine); cCmdLineIter iter(cmdLine);
if (iter.SeekToArg(cSiggenCmdLine::HELP)) if (iter.SeekToArg(cSiggenCmdLine::HELP))
{ {
TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl; TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl;
TCOUT << TSS_GetString( cTW, tw::STR_VERSION) << std::endl; TCOUT << TSS_GetString( cTW, tw::STR_VERSION) << std::endl;
TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_USAGE) << std::endl; TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_USAGE) << std::endl;
ret = 1; ret = 1;
goto exit; goto exit;
} }
if(! siggen.Init(cmdLine)) if(! siggen.Init(cmdLine))
{ {
TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl; TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_VERSION) << std::endl;
TCOUT << TSS_GetString( cTW, tw::STR_VERSION) << std::endl; TCOUT << TSS_GetString( cTW, tw::STR_VERSION) << std::endl;
TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_USAGE) << std::endl; TCOUT << TSS_GetString( cSiggen, siggen::STR_SIGGEN_USAGE) << std::endl;
ret = 1; ret = 1;
goto exit; goto exit;
} }
ret = siggen.Execute(); ret = siggen.Execute();
}//end try block } //end try block
catch (eError& error)
catch (eError& error)
{ {
cErrorReporter::PrintErrorMsg(error); cErrorReporter::PrintErrorMsg(error);
ASSERT(false); ASSERT(false);
} }
exit: exit:
return ret;
return ret;
}//end MAIN }//end MAIN

View File

@ -269,41 +269,43 @@ bool cPolicyUpdate::Execute( uint32 flags ) // throw (eError)
mpBucket->AddError( e ); mpBucket->AddError( e );
bResult = false; bResult = false;
} }
} }
// //
// now, we will update the database with everything in the report... // now, we will update the database with everything in the report...
// TODO -- don't do this if the anal flag was passed in // 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() ); TW_NOTIFY_NORMAL( TSS_GetString( cTripwire, tripwire::STR_PU_UPDATE_DB ).c_str() );
// //
cUpdateDb update( mDb, report, mpBucket ); cUpdateDb update( mDb, report, mpBucket );
uint32 updateDBFlags = cUpdateDb::FLAG_REPLACE_PROPS; uint32 updateDBFlags = cUpdateDb::FLAG_REPLACE_PROPS;
if( flags & FLAG_ERASE_FOOTPRINTS_PU ) if( flags & FLAG_ERASE_FOOTPRINTS_PU )
{
updateDBFlags |= cUpdateDb::FLAG_ERASE_FOOTPRINTS_UD; 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 // 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 // in the database that does not belong in the new database (ie -- does not fall under any
// new rules) // new rules)
// //
// TODO -- is there any way to do this that does not involve iterating over the entire database? // 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... // 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() ); TW_NOTIFY_NORMAL( TSS_GetString( cTripwire, tripwire::STR_PU_PRUNING ).c_str() );
// //
cDbDataSourceIter i( &mDb ); cDbDataSourceIter i( &mDb );
i.SetErrorBucket(mpBucket); i.SetErrorBucket(mpBucket);
if( flags & FLAG_ERASE_FOOTPRINTS_PU ) if( flags & FLAG_ERASE_FOOTPRINTS_PU )
{
i.SetIterFlags( iFCODataSourceIter::DO_NOT_MODIFY_OBJECTS ); i.SetIterFlags( iFCODataSourceIter::DO_NOT_MODIFY_OBJECTS );
}
const cFCOSpecListCanonicalIter newPolIter( mNewPolicy );
util_PruneExtraObjects( i, newPolIter );
const cFCOSpecListCanonicalIter newPolIter( mNewPolicy ); return bResult;
util_PruneExtraObjects( i, newPolIter );
return bResult;
} }

View File

@ -177,18 +177,18 @@ cFCOReport_i::cNode::cNode(const cFCOReport_i::cNode& rhs)
if (mpSpec) if (mpSpec)
mpSpec->AddRef(); mpSpec->AddRef();
mpSpecAttr = rhs.mpSpecAttr; mpSpecAttr = rhs.mpSpecAttr;
if (mpSpecAttr) if (mpSpecAttr)
mpSpecAttr->AddRef(); mpSpecAttr->AddRef();
mChanged = rhs.mChanged; mChanged = rhs.mChanged;
mErrorQueue = rhs.mErrorQueue; mErrorQueue = rhs.mErrorQueue;
mnObjectsScanned = rhs.mnObjectsScanned; mnObjectsScanned = rhs.mnObjectsScanned;
} }
cFCOReport_i::cNode::~cNode() cFCOReport_i::cNode::~cNode()
{ {
Clear(); Clear();
} }
void cFCOReport_i::cNode::Clear() void cFCOReport_i::cNode::Clear()
@ -376,8 +376,8 @@ cFCOReportSpecIter::~cFCOReportSpecIter()
cFCOReportSpecIter::cFCOReportSpecIter(const cFCOReportSpecIter& rhs) cFCOReportSpecIter::cFCOReportSpecIter(const cFCOReportSpecIter& rhs)
{ {
mpData = new cFCOReportSpecIter_i(); mpData = new cFCOReportSpecIter_i();
*this = rhs; *this = rhs;
} }
void cFCOReportSpecIter::operator=(const cFCOReportSpecIter& rhs) void cFCOReportSpecIter::operator=(const cFCOReportSpecIter& rhs)
@ -385,13 +385,13 @@ void cFCOReportSpecIter::operator=(const cFCOReportSpecIter& rhs)
if (mpData == 0) if (mpData == 0)
mpData = new cFCOReportSpecIter_i(); mpData = new cFCOReportSpecIter_i();
mpData->mpList = rhs.mpData->mpList; mpData->mpList = rhs.mpData->mpList;
mpData->mIter = rhs.mpData->mIter; mpData->mIter = rhs.mpData->mIter;
} }
int cFCOReportSpecIter::GetNumChanged() const int cFCOReportSpecIter::GetNumChanged() const
{ {
ASSERT(! Done()); ASSERT(! Done());
return mpData ? mpData->mIter->mChanged.size() : 0; return mpData ? mpData->mIter->mChanged.size() : 0;
} }
@ -406,15 +406,15 @@ void cFCOReportSpecIter::SetObjectsScanned( int nObjectsScanned )
int cFCOReportSpecIter::GetObjectsScanned() const int cFCOReportSpecIter::GetObjectsScanned() const
{ {
ASSERT(! Done()); ASSERT(! Done());
return mpData ? mpData->mIter->mnObjectsScanned : 0; return mpData ? mpData->mIter->mnObjectsScanned : 0;
} }
void cFCOReportSpecIter::Remove() void cFCOReportSpecIter::Remove()
{ {
ASSERT(! Done()); ASSERT(! Done());
mpData->mIter->Clear(); mpData->mIter->Clear();
mpData->mIter = mpData->mpList->erase(mpData->mIter); mpData->mIter = mpData->mpList->erase(mpData->mIter);
} }
///////////////////////// /////////////////////////

View File

@ -1115,17 +1115,17 @@ void cTextReportViewer::RemoveFCOsFromReport() //throw (eTextReportViewer)
for( ; iter != mFCOsRemoveFromReport.end(); iter++ ) for( ; iter != mFCOsRemoveFromReport.end(); iter++ )
nFCOsToRemove += iter->second->size(); nFCOsToRemove += iter->second->size();
if( nFCOsToRemove != nFCOsRemoved ) if( nFCOsToRemove != nFCOsRemoved )
{ {
// TODO -- maybe have a different enumeration for this? // TODO -- maybe have a different enumeration for this?
throw eTextReportViewerReportCorrupt(); throw eTextReportViewerReportCorrupt();
} }
} }
void cTextReportViewer::OutputReportHeader() void cTextReportViewer::OutputReportHeader()
{ {
if (!WantOutputReportHeader()) if (!WantOutputReportHeader())
return; return;
const int headerColumnWidth = 30; const int headerColumnWidth = 30;

View File

@ -407,16 +407,16 @@ unsigned int cCryptoSource::Pump(unsigned int size)
unsigned long cCryptoSource::PumpAll() unsigned long cCryptoSource::PumpAll()
{ {
unsigned long total=0; unsigned long total=0;
unsigned int l; unsigned int l;
if (mBufferLen == 0) if (mBufferLen == 0)
mBufferLen = mpCipher->GetBlockSizePlain(); mBufferLen = mpCipher->GetBlockSizePlain();
while ((l=Pump(mBufferLen)) != 0) while ((l=Pump(mBufferLen)) != 0)
total += l; total += l;
return total; return total;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -84,7 +84,7 @@ cGenreParseInfo::cGenreParseInfo()
void void
cGenreParseInfo::AddStopPoint( const cFCOName& name ) cGenreParseInfo::AddStopPoint( const cFCOName& name )
{ {
mStopList.push_back( name ); mStopList.push_back( name );
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -96,7 +96,7 @@ cGenreParseInfo::AddStopPoint( const cFCOName& name )
void void
cGenreParseInfo::AddRule(const cParseRule *pnode) 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) ) if( mLocalPredefVarTable.Lookup(var, dummy) )
throw eParserRedefineVar( var ); 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 ) bool cGenreParseInfo::LookupVariable( const TSTRING& var, TSTRING& val )
{ {
if( mLocalPredefVarTable.Lookup( var, val ) || mLocalVarTable.Lookup( var, val ) ) if( mLocalPredefVarTable.Lookup( var, val ) || mLocalVarTable.Lookup( var, val ) )
return true; return true;
else else
return ( cParserHelper::GetGlobalVarTable().Lookup( var, val ) ); return ( cParserHelper::GetGlobalVarTable().Lookup( var, val ) );
} }

View File

@ -57,24 +57,24 @@ cParseRule::~cParseRule()
const cFCOName& cParseRule::GetName() const const cFCOName& cParseRule::GetName() const
{ {
return mName; return mName;
} }
void cParseRule::SetName( const cFCOName& name ) void cParseRule::SetName( const cFCOName& name )
{ {
mName = name; mName = name;
} }
cParseNamedAttrList * cParseNamedAttrList *
cParseRule::GetAttrList() const cParseRule::GetAttrList() const
{ {
return mpAttrList; return mpAttrList;
} }
void void
cParseRule::SetAttrList(cParseNamedAttrList *pattr) cParseRule::SetAttrList(cParseNamedAttrList *pattr)
{ {
mpAttrList = pattr; mpAttrList = pattr;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -84,7 +84,7 @@ cParseRule::SetAttrList(cParseNamedAttrList *pattr)
void void
cParseRule::SetSpecMaskList(cParseSpecMaskList *pmasks) cParseRule::SetSpecMaskList(cParseSpecMaskList *pmasks)
{ {
mpSpecMaskList = pmasks; mpSpecMaskList = pmasks;
} }
@ -95,11 +95,11 @@ cParseRule::SetSpecMaskList(cParseSpecMaskList *pmasks)
int int
cParseRule::GetNumSpecMasks() const cParseRule::GetNumSpecMasks() const
{ {
// empty list? // empty list?
if (mpSpecMaskList == NULL) if (mpSpecMaskList == NULL)
return 0; return 0;
return mpSpecMaskList->mList.size(); return mpSpecMaskList->mList.size();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -109,11 +109,11 @@ cParseRule::GetNumSpecMasks() const
int int
cParseRule::GetNumNamedAttrs() const cParseRule::GetNumNamedAttrs() const
{ {
// empty list? // empty list?
if (mpAttrList == NULL) if (mpAttrList == NULL)
return 0; return 0;
return mpAttrList->mList.size(); return mpAttrList->mList.size();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -124,19 +124,19 @@ cParseRule::GetNumNamedAttrs() const
void void
cParseRule::Dump() cParseRule::Dump()
{ {
cDebug d("\tcParseRule::Dump()"); cDebug d("\tcParseRule::Dump()");
d.TraceDebug("name=%s\n", mName.AsString().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.prop_vector=%s\n", mDefSpecMask.GetPropVectorString().c_str() );
d.TraceDebug("defspecmask.condition=%s\n", mDefSpecMask.GetCondition().c_str() ); d.TraceDebug("defspecmask.condition=%s\n", mDefSpecMask.GetCondition().c_str() );
// specmasks // specmasks
d.TraceDebug(" numspecmasks=%d\n", GetNumSpecMasks()); d.TraceDebug(" numspecmasks=%d\n", GetNumSpecMasks());
if( mpSpecMaskList ) if( mpSpecMaskList )
mpSpecMaskList->Dump(d); mpSpecMaskList->Dump(d);
// named attributes // named attributes
d.TraceDebug(" numattrs=%d\n", GetNumNamedAttrs()); d.TraceDebug(" numattrs=%d\n", GetNumNamedAttrs());
if( mpAttrList ) if( mpAttrList )
mpAttrList->Dump(d); mpAttrList->Dump(d);
} }
@ -160,47 +160,47 @@ cParseSpecMask::~cParseSpecMask()
int int
cParseSpecMask::GetNumAttrs() const cParseSpecMask::GetNumAttrs() const
{ {
if (mpAttrList == NULL) if (mpAttrList == NULL)
return 0; return 0;
return mpAttrList->mList.size(); return mpAttrList->mList.size();
} }
void void
cParseSpecMask::SetAttrList(cParseNamedAttrList *pattr) cParseSpecMask::SetAttrList(cParseNamedAttrList *pattr)
{ {
mpAttrList = pattr; mpAttrList = pattr;
} }
cParseNamedAttrList * cParseNamedAttrList *
cParseSpecMask::GetAttrList() const cParseSpecMask::GetAttrList() const
{ {
return mpAttrList; return mpAttrList;
} }
const TSTRING& cParseSpecMask::GetPropVectorString() const const TSTRING& cParseSpecMask::GetPropVectorString() const
{ {
return msPV; return msPV;
} }
const cFCOPropVector& cParseSpecMask::GetPropVector() const const cFCOPropVector& cParseSpecMask::GetPropVector() const
{ {
return mPropVector; return mPropVector;
} }
const TSTRING& cParseSpecMask::GetCondition() const const TSTRING& cParseSpecMask::GetCondition() const
{ {
return msCondition; return msCondition;
} }
void void
cParseSpecMask::Dump(cDebug &d) const 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 // dump list of attributes
if (mpAttrList) if (mpAttrList)
mpAttrList->Dump(d); mpAttrList->Dump(d);
} }
// //
@ -210,10 +210,10 @@ cParseSpecMask::Dump(cDebug &d) const
void void
cParseSpecMaskList::Dump(cDebug &d) const cParseSpecMaskList::Dump(cDebug &d) const
{ {
std::list<cParseSpecMask *>::const_iterator ispec; std::list<cParseSpecMask *>::const_iterator ispec;
for (ispec = mList.begin(); ispec != mList.end(); ispec++) { for (ispec = mList.begin(); ispec != mList.end(); ispec++) {
(*ispec)->Dump(d); (*ispec)->Dump(d);
} }
} }
// //
@ -237,7 +237,7 @@ cParseNamedAttr* cParseNamedAttr::Clone() const
void cParseNamedAttr::Dump(cDebug &d) 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 void cParseNamedAttr::Validate() const
@ -305,11 +305,11 @@ void cParseNamedAttrList::Clear()
void void
cParseNamedAttrList::Dump(cDebug &d) const cParseNamedAttrList::Dump(cDebug &d) const
{ {
// dump out each named attribute // dump out each named attribute
std::list<cParseNamedAttr *>::const_iterator iattr; std::list<cParseNamedAttr *>::const_iterator iattr;
for (iattr = mList.begin(); iattr != mList.end(); iattr++) { for (iattr = mList.begin(); iattr != mList.end(); iattr++) {
(*iattr)->Dump(d); (*iattr)->Dump(d);
} }
} }

View File

@ -61,14 +61,14 @@
void cFileUtil::TestFileExists(const TSTRING& fileName) void cFileUtil::TestFileExists(const TSTRING& fileName)
{ {
if(! cFileUtil::FileExists(fileName)) if(! cFileUtil::FileExists(fileName))
{ {
TSTRING filenameText = TSS_GetString( cCore, core::STR_ERROR_FILENAME ); TSTRING filenameText = TSS_GetString( cCore, core::STR_ERROR_FILENAME );
filenameText.append(fileName); filenameText.append(fileName);
filenameText.append(1, _T('\n')); filenameText.append(1, _T('\n'));
filenameText.append(iFSServices::GetInstance()->GetErrString()); filenameText.append(iFSServices::GetInstance()->GetErrString());
throw eOpen(filenameText); throw eOpen(filenameText);
} }
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -76,15 +76,15 @@ void cFileUtil::TestFileExists(const TSTRING& fileName)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void cFileUtil::TestFileWritable(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); TSTRING filenameText = TSS_GetString( cCore, core::STR_ERROR_FILENAME);
filenameText.append(fileName); filenameText.append(fileName);
filenameText.append(1, _T('\n')); filenameText.append(1, _T('\n'));
filenameText.append(iFSServices::GetInstance()->GetErrString()); filenameText.append(iFSServices::GetInstance()->GetErrString());
throw eOpenWrite(filenameText); throw eOpenWrite(filenameText);
} }
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -92,15 +92,15 @@ void cFileUtil::TestFileWritable(const TSTRING& fileName)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void cFileUtil::TestFileReadable(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); TSTRING filenameText = TSS_GetString( cCore, core::STR_ERROR_FILENAME);
filenameText.append(fileName); filenameText.append(fileName);
filenameText.append(1, _T('\n')); filenameText.append(1, _T('\n'));
filenameText.append(iFSServices::GetInstance()->GetErrString()); filenameText.append(iFSServices::GetInstance()->GetErrString());
throw eOpenRead(filenameText); throw eOpenRead(filenameText);
} }
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -123,16 +123,16 @@ bool cFileUtil::IsDir( const TSTRING& fileName )
bool cFileUtil::IsRegularFile( const TSTRING& fileName ) bool cFileUtil::IsRegularFile( const TSTRING& fileName )
{ {
cFSStatArgs s; cFSStatArgs s;
try try
{ {
iFSServices::GetInstance()->Stat( fileName, s); iFSServices::GetInstance()->Stat( fileName, s);
} }
catch( eFSServices ) catch( eFSServices )
{ {
return false; return false;
} }
return (s.mFileType == cFSStatArgs::TY_FILE ); return (s.mFileType == cFSStatArgs::TY_FILE );
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -196,9 +196,9 @@ bool cFileUtil::BackupFile(const TSTRING& filename, bool printWarningOnFailure)
if (!cFileUtil::FileExists(filename)) if (!cFileUtil::FileExists(filename))
return true; return true;
// if the file is not a regular file, it is not appropriate to back it up // if the file is not a regular file, it is not appropriate to back it up
if (!cFileUtil::IsRegularFile(filename)) if (!cFileUtil::IsRegularFile(filename))
return true; return true;
// if it is not writeable, throw error // if it is not writeable, throw error
if (!cFileUtil::FileWritable(filename)) 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(), problems removing the file will be caught by _trename().
_tunlink(backup_filename.c_str()); _tunlink(backup_filename.c_str());
// back up the file, preserving permissions and ownership, if possible // back up the file, preserving permissions and ownership, if possible
if (cFileUtil::Copy(filename.c_str(), backup_filename.c_str()) == false) if (cFileUtil::Copy(filename.c_str(), backup_filename.c_str()) == false)
{
if (printWarningOnFailure && if (printWarningOnFailure &&
iUserNotify::GetInstance()->GetVerboseLevel() >= iUserNotify::V_NORMAL) 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)); cErrorReporter::PrintErrorMsg(eFileUtilBackup(estr, eError::NON_FATAL|eError::SUPRESS_THIRD_MSG));
} }
}
return true; return true;
} }
@ -238,37 +239,37 @@ bool cFileUtil::Copy(const TSTRING& src_path, const TSTRING& dest_path)
{ {
#if IS_UNIX #if IS_UNIX
enum { BUF_SIZE = 4096 }; enum { BUF_SIZE = 4096 };
int8 buf[BUF_SIZE]; int8 buf[BUF_SIZE];
int nBytesRead; int nBytesRead;
cFile srcFile, destFile; cFile srcFile, destFile;
srcFile.Open(src_path.c_str()); srcFile.Open(src_path.c_str());
// Create destination file. We'll fix the permissions later. // Create destination file. We'll fix the permissions later.
destFile.Open(dest_path.c_str(), cFile::OPEN_WRITE|cFile::OPEN_CREATE); destFile.Open(dest_path.c_str(), cFile::OPEN_WRITE|cFile::OPEN_CREATE);
for (int i = srcFile.GetSize(); i > 0; ) for (int i = srcFile.GetSize(); i > 0; )
{ {
nBytesRead = srcFile.Read(buf, BUF_SIZE); nBytesRead = srcFile.Read(buf, BUF_SIZE);
destFile.Write(buf, nBytesRead); destFile.Write(buf, nBytesRead);
i -= nBytesRead; i -= nBytesRead;
} }
struct stat srcStat; struct stat srcStat;
stat(src_path.c_str(), &srcStat); stat(src_path.c_str(), &srcStat);
// restore permissions and ownership // restore permissions and ownership
// don't worry if it fails. it's not mission-critical. // don't worry if it fails. it's not mission-critical.
chmod( dest_path.c_str(), srcStat.st_mode ); chmod( dest_path.c_str(), srcStat.st_mode );
chown( dest_path.c_str(), srcStat.st_uid, srcStat.st_gid ); chown( dest_path.c_str(), srcStat.st_uid, srcStat.st_gid );
srcFile.Close(); srcFile.Close();
destFile.Close(); destFile.Close();
#endif #endif
return true; return true;
} }