From 645394f02334548d6158187308cffd65b0b4ec77 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 15 Feb 2016 15:36:14 +0200 Subject: cid#1352218 and cid#1352216 in .SDI parser Change-Id: I273d80b4e9fb45955c5496cf5559df5dd4b057b0 --- idl/inc/parser.hxx | 6 +++--- idl/source/prj/command.cxx | 3 +-- idl/source/prj/parser.cxx | 53 +++++++++++----------------------------------- 3 files changed, 16 insertions(+), 46 deletions(-) (limited to 'idl') diff --git a/idl/inc/parser.hxx b/idl/inc/parser.hxx index ccd2f64ae06d..225836967c00 100644 --- a/idl/inc/parser.hxx +++ b/idl/inc/parser.hxx @@ -36,9 +36,9 @@ class SvIdlParser SvTokenStream & rInStm; public: SvIdlParser( SvIdlDataBase& rBase_, SvTokenStream & rInStrm_) : rBase(rBase_), rInStm(rInStrm_) {} - bool ReadSvIdl( bool bImported, const OUString & rPath ); - bool ReadModuleHeader(SvMetaModule& rModule); - bool ReadModuleBody(SvMetaModule& rModule); + void ReadSvIdl( bool bImported, const OUString & rPath ); + void ReadModuleHeader(SvMetaModule& rModule); + void ReadModuleBody(SvMetaModule& rModule); void ReadModuleElement( SvMetaModule& rModule ); void ReadInclude( SvMetaModule& rModule ); void ReadInterfaceOrShell( SvMetaModule& rModule, MetaTypeType aMetaTypeType ); diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx index 3b4467948526..c12c1e755523 100644 --- a/idl/source/prj/command.cxx +++ b/idl/source/prj/command.cxx @@ -126,8 +126,7 @@ bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ) SvTokenStream aTokStm( aFileName ); try { SvIdlParser aParser(*pDataBase, aTokStm); - if( !aParser.ReadSvIdl( false, rCommand.aPath ) ) - return false; + aParser.ReadSvIdl( false, rCommand.aPath ); } catch (const SvParseException& ex) { pDataBase->SetError(ex.aError); pDataBase->WriteError(aTokStm); diff --git a/idl/source/prj/parser.cxx b/idl/source/prj/parser.cxx index cdd80dfecbff..8f368b4d2c32 100644 --- a/idl/source/prj/parser.cxx +++ b/idl/source/prj/parser.cxx @@ -26,63 +26,38 @@ #include #include -bool SvIdlParser::ReadSvIdl( bool bImported, const OUString & rPath ) +void SvIdlParser::ReadSvIdl( bool bImported, const OUString & rPath ) { rBase.SetPath(rPath); // only valid for this iteration - bool bOk = true; SvToken& rTok = rInStm.GetToken(); - while( bOk ) + while( true ) { rTok = rInStm.GetToken(); if( rTok.IsEof() ) - return true; + return; if( rTok.Is( SvHash_module() ) ) { tools::SvRef aModule = new SvMetaModule( bImported ); - if( ReadModuleHeader(*aModule) ) - rBase.GetModuleList().push_back( aModule ); - else - bOk = false; + ReadModuleHeader(*aModule); + rBase.GetModuleList().push_back( aModule ); } - else - bOk = false; - } - if( !bOk || !rTok.IsEof() ) - { - // error treatment - rBase.WriteError( rInStm ); - return false; } - return true; } -bool SvIdlParser::ReadModuleHeader(SvMetaModule& rModule) +void SvIdlParser::ReadModuleHeader(SvMetaModule& rModule) { - sal_uInt32 nTokPos = rInStm.Tell(); - SvToken& rTok = rInStm.GetToken_Next(); - bool bOk = true; - - rTok = rInStm.GetToken_Next(); - if( !rTok.IsIdentifier() ) - { - rInStm.Seek( nTokPos ); - return false; - } + rInStm.GetToken_Next(); + OString aName = ReadIdentifier(); rBase.Push( &rModule ); // onto the context stack - rModule.SetName( rTok.GetString() ); - bOk = ReadModuleBody(rModule); + rModule.SetName( aName ); + ReadModuleBody(rModule); rBase.GetStack().pop_back(); // remove from stack - if( !bOk ) - rInStm.Seek( nTokPos ); - return bOk; } -bool SvIdlParser::ReadModuleBody(SvMetaModule& rModule) +void SvIdlParser::ReadModuleBody(SvMetaModule& rModule) { - sal_uInt32 nTokPos = rInStm.Tell(); - bool bOk = true; if( rInStm.ReadIf( '[' ) ) { while( true ) @@ -100,7 +75,7 @@ bool SvIdlParser::ReadModuleBody(SvMetaModule& rModule) } if( !rInStm.ReadIf( '{' ) ) - return bOk; + return; sal_uInt32 nBeginPos = 0; while( nBeginPos != rInStm.Tell() ) @@ -110,10 +85,6 @@ bool SvIdlParser::ReadModuleBody(SvMetaModule& rModule) rInStm.ReadIfDelimiter(); } ReadChar( '}' ); - - if( !bOk ) - rInStm.Seek( nTokPos ); - return bOk; } void SvIdlParser::ReadModuleElement( SvMetaModule& rModule ) -- cgit v1.2.3