From 68b8b5136677435a84da7d277e78470ac4a41a64 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 20 Oct 2010 21:06:49 +0000 Subject: Hopefully this fixes some really out there fstring corner casese. --- src/fbasicstring.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/fbasicstring.h b/src/fbasicstring.h index 19853f5..4c33479 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h @@ -1118,7 +1118,7 @@ namespace Bu */ chr *getStr() { - if( core->pFirst == NULL ) + if( core->pFirst == NULL || core->nLength == 0 ) return (chr *)""; flatten(); @@ -1133,7 +1133,7 @@ namespace Bu */ const chr *getStr() const { - if( core->pFirst == NULL ) + if( core->pFirst == NULL || core->nLength == 0 ) return (chr *)""; flatten(); @@ -1219,7 +1219,7 @@ namespace Bu DEPRECATED chr *c_str() { - if( core->pFirst == NULL ) + if( core->pFirst == NULL || core->nLength == 0 ) return NULL; flatten(); @@ -1235,7 +1235,7 @@ namespace Bu DEPRECATED const chr *c_str() const { - if( core->pFirst == NULL ) + if( core->pFirst == NULL || core->nLength == 0 ) return NULL; flatten(); @@ -1460,7 +1460,7 @@ namespace Bu */ bool operator==( const chr *pData ) const { - if( core->pFirst == NULL ) { + if( core->pFirst == NULL || core->nLength == 0 ) { if( pData == NULL ) return true; if( pData[0] == (chr)0 ) @@ -1646,9 +1646,11 @@ namespace Bu bool compareSub( const chr *pData, long nIndex, long nLen ) const { - if( core->pFirst == NULL ) { + if( core->pFirst == NULL || core->nLength == 0 ) { if( pData == NULL ) return true; + if( nLen == 0 ) + return true; if( pData[0] == (chr)0 ) return true; return false; @@ -1673,7 +1675,7 @@ namespace Bu bool compareSub( const MyType &rData, long nIndex, long nLen ) const { - if( core->pFirst == NULL || rData.core->pFirst == NULL ) + if( core->pFirst == NULL || core->nLength == 0 || rData.core->pFirst == NULL || rData.core->nLength == 0 ) return false; if( nLen < 0 ) nLen = rData.core->nLength; @@ -1922,7 +1924,7 @@ namespace Bu void trimBack( chr c ) { - if( core->pFirst == NULL ) + if( core->pFirst == NULL || core->nLength == 0 ) return; flatten(); for( ; core->pFirst->nLength > 0 && core->pFirst->pData[core->pFirst->nLength-1] == c; core->pFirst->nLength--, core->nLength-- ) { } @@ -2018,7 +2020,7 @@ namespace Bu if( isFlat() ) return; - if( core->pFirst == NULL ) + if( core->pFirst == NULL || core->nLength == 0 ) return; Chunk *pNew = core->newChunk( core->nLength ); -- cgit v1.2.3