From c7636dc954eddfe58f7959392602fbc9072d77e7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 29 Mar 2011 04:01:45 +0000 Subject: String's replace function now doesn't get false positives on partial matches at the end of strings. Build should work much better now. --- src/string.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/string.h') diff --git a/src/string.h b/src/string.h index 9270c55..3ac161b 100644 --- a/src/string.h +++ b/src/string.h @@ -203,6 +203,7 @@ namespace Bu if( *a != *b ) return false; } + return true; } @@ -212,11 +213,14 @@ namespace Bu const_iterator b = c; if( a == b ) return true; - for(int j = 0; a && b && j < nLen; a++, b++, j++ ) + int j; + for( j = 0; a && b && j < nLen; a++, b++, j++ ) { if( *a != *b ) return false; } + if( j < nLen ) + return false; return true; } @@ -252,7 +256,7 @@ namespace Bu bool compare( const String &s ) const { if( !pChunk ) return false; - return compare( s.begin() ); + return compare( s.begin(), s.getSize() ); } bool compare( const String &s, int nLen ) const @@ -458,11 +462,14 @@ namespace Bu iterator b = c; if( a == b ) return true; - for(int j = 0; a && b && j < nLen; a++, b++, j++ ) + int j; + for( j = 0; a && b && j < nLen; a++, b++, j++ ) { if( *a != *b ) return false; } + if( j < nLen ) + return false; return true; } @@ -498,7 +505,7 @@ namespace Bu bool compare( const String &s ) const { if( !pChunk ) return false; - return compare( s.begin() ); + return compare( s.begin(), s.getSize() ); } bool compare( const String &s, int nLen ) const -- cgit v1.2.3