Kaydet (Commit) df2e78f1 authored tarafından Caolán McNamara's avatar Caolán McNamara

replace check of eof and GetError with good

Change-Id: I7d9f04262ab5420e9a14813fa1274bb9d01e3291
Reviewed-on: https://gerrit.libreoffice.org/45076Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 2161d046
......@@ -73,7 +73,7 @@ void SbiImage::Clear()
bool SbiGood( SvStream const & r )
{
return !r.eof() && r.GetError() == ERRCODE_NONE;
return r.good();
}
// Open Record
......
......@@ -1362,13 +1362,11 @@ namespace emfio
mnCurrentAction++;
mpInputStream->ReadUInt32(mnRecSize).ReadUInt16( nFunction );
if( mpInputStream->GetError()
|| (mnRecSize < 3 )
|| (mnRecSize == 3
&& nFunction == 0
)
|| mpInputStream->eof()
)
if (
!mpInputStream->good() ||
(mnRecSize < 3) ||
(mnRecSize == 3 && nFunction == 0)
)
{
if( mpInputStream->eof() )
mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR );
......
......@@ -281,7 +281,7 @@ bool PBMReader::ImplReadBody()
case 0 :
while ( nHeight != mnHeight )
{
if ( mrPBM.eof() || mrPBM.GetError() )
if (!mrPBM.good())
return false;
if ( --nShift < 0 )
......@@ -303,7 +303,7 @@ bool PBMReader::ImplReadBody()
case 1 :
while ( nHeight != mnHeight )
{
if ( mrPBM.eof() || mrPBM.GetError() )
if (!mrPBM.good())
return false;
mrPBM.ReadUChar( nDat );
......@@ -321,7 +321,7 @@ bool PBMReader::ImplReadBody()
case 2 :
while ( nHeight != mnHeight )
{
if ( mrPBM.eof() || mrPBM.GetError() )
if (!mrPBM.good())
return false;
sal_uInt8 nR, nG, nB;
......@@ -346,7 +346,7 @@ bool PBMReader::ImplReadBody()
case 0 :
while ( !bFinished )
{
if ( mrPBM.eof() || mrPBM.GetError() )
if (!mrPBM.good())
return false;
mrPBM.ReadUChar( nDat );
......@@ -405,7 +405,7 @@ bool PBMReader::ImplReadBody()
continue;
}
if ( mrPBM.eof() || mrPBM.GetError() )
if (!mrPBM.good())
return false;
mrPBM.ReadUChar( nDat );
......@@ -478,7 +478,7 @@ bool PBMReader::ImplReadBody()
continue;
}
if ( mrPBM.eof() || mrPBM.GetError() )
if (!mrPBM.good())
return false;
mrPBM.ReadUChar( nDat );
......
......@@ -1213,7 +1213,7 @@ void PictReader::ReadHeader()
// a small test to check if versionOp code exists after the bdbox ( with no extra NOP codes)
pPict->Seek(nOffset+10);
pPict->ReadBytes(sBuf, 2);
if (pPict->eof() || pPict->GetError()) break;
if (!pPict->good()) break;
if (sBuf[0] == 0x11 || (sBuf[0] == 0x00 && sBuf[1] == 0x11)) ; // maybe ok
else continue;
}
......@@ -1231,7 +1231,7 @@ void PictReader::ReadHeader()
if (st >= 3 && actualConfid != 20) continue;
aBoundingRect=tools::Rectangle( x1,y1, x2, y2 );
if (pPict->eof() || pPict->GetError()) continue;
if (!pPict->good()) continue;
// read version
pPict->ReadBytes(sBuf, 2);
// version 1 file
......@@ -1250,7 +1250,7 @@ void PictReader::ReadHeader()
}
while ( sBuf[0] == 0x00 && numZero < 10);
actualConfid -= (numZero-1); // extra nop are dubious
if (pPict->eof() || pPict->GetError()) continue;
if (!pPict->good()) continue;
if (sBuf[0] != 0x11) continue; // not a version opcode
// abnormal version 1 file
if (sBuf[1] == 0x01 ) {
......@@ -1265,7 +1265,7 @@ void PictReader::ReadHeader()
// 3 Bytes ignored : end of version arg 0x02FF (ie: 0xFF), HeaderOp : 0x0C00
pPict->SeekRel( 3 );
pPict->ReadInt16( nExtVer ).ReadInt16( nReserved );
if (pPict->eof() || pPict->GetError()) continue;
if (!pPict->good()) continue;
if ( nExtVer == -2 ) // extended version 2 picture
{
......
......@@ -62,7 +62,7 @@ bool SAL_CALL LotusWordProImportFilter::importImpl( const Sequence< css::beans::
}
SvFileStream inputStream( sURL, StreamMode::READ );
if ( inputStream.eof() || ( inputStream.GetError() != ERRCODE_NONE ) )
if (!inputStream.good())
return false;
// An XML import service: what we push sax messages to..
......
......@@ -530,9 +530,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, OUString &rText )
// need to work out some more line information
do
{
if (!Seek( mpRowPosArray[mnRowPosCount]) ||
mpDatStream->GetError() != ERRCODE_NONE ||
mpDatStream->eof())
if (!Seek(mpRowPosArray[mnRowPosCount]) || !mpDatStream->good())
{
bRet = false;
break;
......@@ -541,9 +539,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, OUString &rText )
mcTextSep);
mnStreamPos = mpDatStream->Tell();
mpRowPosArray[++mnRowPosCount] = mnStreamPos;
} while (nLine >= mnRowPosCount &&
mpDatStream->GetError() == ERRCODE_NONE &&
!mpDatStream->eof());
} while (nLine >= mnRowPosCount && mpDatStream->good());
if (mpDatStream->eof() &&
mnStreamPos == mpRowPosArray[mnRowPosCount-1])
{
......
......@@ -105,7 +105,7 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde
if ( nRead < 32000 )
aSeq.realloc( nRead );
xTargetStream->writeBytes( aSeq );
} while( !pTempStream->eof() && !pTempStream->GetError() && nRead );
} while (pTempStream->good() && nRead);
if ( pTempStream->GetError() )
throw io::IOException();
......
......@@ -193,14 +193,14 @@ sal_uInt32 SvParser<T>::GetNextChar()
bool bSeekBack = true;
rInput.ReadUChar( c1 );
bErr = rInput.eof() || rInput.GetError();
bErr = !rInput.good();
if( !bErr )
{
if( 0xff == c1 || 0xfe == c1 )
{
unsigned char c2;
rInput.ReadUChar( c2 );
bErr = rInput.eof() || rInput.GetError();
bErr = !rInput.good();
if( !bErr )
{
if( 0xfe == c1 && 0xff == c2 )
......@@ -221,14 +221,14 @@ sal_uInt32 SvParser<T>::GetNextChar()
{
unsigned char c2;
rInput.ReadUChar( c2 );
bErr = rInput.eof() || rInput.GetError();
bErr = !rInput.good();
if( !bErr )
{
if( ( 0xef == c1 && 0xbb == c2 ) || ( 0xbb == c1 && 0xef == c2 ) )
{
unsigned char c3(0);
rInput.ReadUChar( c3 );
bErr = rInput.eof() || rInput.GetError();
bErr = !rInput.good();
if( !bErr && ( 0xbf == c3 ) )
{
SetSrcEncoding(RTL_TEXTENCODING_UTF8);
......@@ -252,13 +252,12 @@ sal_uInt32 SvParser<T>::GetNextChar()
unsigned char c1, c2;
rInput.ReadUChar( c1 ).ReadUChar( c2 );
if( 2 == rInput.Tell() &&
!(rInput.eof() || rInput.GetError()) &&
if( 2 == rInput.Tell() && rInput.good() &&
( (bUCS2BSrcEnc && 0xfe == c1 && 0xff == c2) ||
(!bUCS2BSrcEnc && 0xff == c1 && 0xfe == c2) ) )
rInput.ReadUChar( c1 ).ReadUChar( c2 );
bErr = rInput.eof() || rInput.GetError();
bErr = !rInput.good();
if( !bErr )
{
if( bUCS2BSrcEnc )
......@@ -279,7 +278,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
{
sal_Char c1; // signed, that's the text converter expects
rInput.ReadChar( c1 );
bErr = rInput.eof() || rInput.GetError();
bErr = !rInput.good();
if( !bErr )
{
if (
......@@ -315,7 +314,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
while( (nInfo&RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOOSMALL) != 0 )
{
rInput.ReadChar( c1 );
bErr = rInput.eof() || rInput.GetError();
bErr = !rInput.good();
if( bErr )
break;
......@@ -361,7 +360,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
nLen < 10 )
{
rInput.ReadChar( c1 );
bErr = rInput.eof() || rInput.GetError();
bErr = !rInput.good();
if( bErr )
break;
......
......@@ -320,7 +320,7 @@ void SwEditShell::ApplyAutoMark()
SearchAlgorithms2::ABSOLUTE,
'\\' );
while( !rStrm.GetError() && !rStrm.eof() )
while (rStrm.good())
{
OString aRdLine;
rStrm.ReadLine( aRdLine );
......
......@@ -1068,8 +1068,7 @@ bool SwLayCacheIoImpl::OpenRec( sal_uInt8 cType )
sal_uInt32 nVal(0);
pStream->ReadUInt32( nVal );
sal_uInt8 cRecTyp = (sal_uInt8)nVal;
if( !nVal || cRecTyp != cType ||
pStream->GetErrorCode() != ERRCODE_NONE || pStream->eof() )
if (!nVal || cRecTyp != cType || !pStream->good())
{
OSL_ENSURE( nVal, "OpenRec: Record-Header is 0" );
OSL_ENSURE( cRecTyp == cType, "OpenRec: Wrong Record Type" );
......
......@@ -4095,7 +4095,7 @@ void SwEntryBrowseBox::ReadEntries(SvStream& rInStr)
{
AutoMarkEntry* pToInsert = nullptr;
rtl_TextEncoding eTEnc = osl_getThreadTextEncoding();
while( !rInStr.GetError() && !rInStr.eof() )
while (rInStr.good())
{
OUString sLine;
rInStr.ReadByteStringLine( sLine, eTEnc );
......
......@@ -221,14 +221,14 @@ sal_uInt8 ImpDetectJPG_GetNextMarker( SvStream& rStm )
do
{
rStm.ReadUChar( nByte );
if ( rStm.eof() || rStm.GetError() ) // as 0 is not allowed as marker,
return 0; // we can use it as errorcode
if (!rStm.good()) // as 0 is not allowed as marker,
return 0; // we can use it as errorcode
}
while ( nByte != 0xff );
do
{
rStm.ReadUChar( nByte );
if ( rStm.eof() || rStm.GetError() )
if (!rStm.good())
return 0;
}
while( nByte == 0xff );
......@@ -263,7 +263,7 @@ bool GraphicDescriptor::ImpDetectJPG( SvStream& rStm, bool bExtendedInfo )
bool bScanFailure = false;
bool bScanFinished = false;
while( !bScanFailure && !bScanFinished && !rStm.eof() && !rStm.GetError() )
while (!bScanFailure && !bScanFinished && rStm.good())
{
sal_uInt8 nMarker = ImpDetectJPG_GetNextMarker( rStm );
switch( nMarker )
......@@ -555,15 +555,14 @@ bool GraphicDescriptor::ImpDetectPNG( SvStream& rStm, bool bExtendedInfo )
rStm.ReadUInt32( nLen32 );
rStm.ReadUInt32( nTemp32 );
while( ( nTemp32 != 0x70485973 ) && ( nTemp32 != 0x49444154 )
&& !rStm.eof() && !rStm.GetError() )
&& rStm.good() )
{
rStm.SeekRel( 4 + nLen32 );
rStm.ReadUInt32( nLen32 );
rStm.ReadUInt32( nTemp32 );
}
if ( nTemp32 == 0x70485973
&& !rStm.eof() && !rStm.GetError() )
if (nTemp32 == 0x70485973 && rStm.good())
{
sal_uLong nXRes;
sal_uLong nYRes;
......
......@@ -1444,7 +1444,7 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
// reading which will create VDevs and other stuff, just to
// read nothing. CAUTION: Eof is only true AFTER reading another
// byte, a speciality of SvMemoryStream (!)
if (rIStm.GetError() || rIStm.eof())
if (!rIStm.good())
return;
if (NATIVE_FORMAT_50 == nTmp)
......
......@@ -263,7 +263,7 @@ bool PNGReaderImpl::ReadNextChunk()
// get the next chunk from the stream
// unless we are at the end of the PNG stream
if( mrPNGStream.eof() || (mrPNGStream.GetError() != ERRCODE_NONE) )
if (!mrPNGStream.good())
return false;
if( !maChunkSeq.empty() && (maChunkSeq.back().nType == PNGCHUNK_IEND) )
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment