From 1ca201c4151ce6e4ac4921c641fec7d21d64752c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 24 Sep 2008 19:31:37 +0000 Subject: Something may be wrong. --- src/array.h | 4 ++++ src/bzip2.cpp | 13 ++++++++++++- src/fstring.h | 5 +---- src/trace.h | 7 +++++++ src/unit/array.cpp | 13 ++++++++++--- 5 files changed, 34 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/array.h b/src/array.h index 9233875..e8d8b30 100644 --- a/src/array.h +++ b/src/array.h @@ -157,6 +157,8 @@ namespace Bu src( src ), iPos( iPos ) { + if( this->iPos >= src.getSize() ) + this->iPos = -1; } MyType &src; @@ -218,6 +220,8 @@ namespace Bu src( src ), iPos( iPos ) { + if( this->iPos >= src.getSize() ) + this->iPos = -1; } const MyType &src; diff --git a/src/bzip2.cpp b/src/bzip2.cpp index 9108bcf..c367cff 100644 --- a/src/bzip2.cpp +++ b/src/bzip2.cpp @@ -7,6 +7,8 @@ #include "bu/bzip2.h" #include "bu/exceptions.h" +#define BU_TRACE +#include "bu/trace.h" using namespace Bu; @@ -14,16 +16,19 @@ Bu::BZip2::BZip2( Bu::Stream &rNext, int nCompression ) : Bu::Filter( rNext ), nCompression( nCompression ) { + TRACE( nCompression ); start(); } Bu::BZip2::~BZip2() { + TRACE(); stop(); } void Bu::BZip2::start() { + TRACE(); bzState.state = NULL; bzState.bzalloc = NULL; bzState.bzfree = NULL; @@ -35,6 +40,7 @@ void Bu::BZip2::start() size_t Bu::BZip2::stop() { + TRACE(); if( bzState.state ) { if( bReading ) @@ -72,6 +78,7 @@ size_t Bu::BZip2::stop() void Bu::BZip2::bzError( int code ) { + TRACE( code ); switch( code ) { case BZ_OK: @@ -115,10 +122,12 @@ void Bu::BZip2::bzError( int code ) size_t Bu::BZip2::read( void *pData, size_t nBytes ) { + TRACE( pData, nBytes ); + printf("READ!!!\n"); if( !bzState.state ) { bReading = true; - BZ2_bzDecompressInit( &bzState, 0, 0 ); + BZ2_bzDecompressInit( &bzState, 7, 0 ); bzState.next_in = pBuf; bzState.avail_in = 0; } @@ -167,6 +176,7 @@ size_t Bu::BZip2::read( void *pData, size_t nBytes ) size_t Bu::BZip2::write( const void *pData, size_t nBytes ) { + TRACE( pData, nBytes ); if( !bzState.state ) { bReading = false; @@ -198,6 +208,7 @@ size_t Bu::BZip2::write( const void *pData, size_t nBytes ) bool Bu::BZip2::isOpen() { + TRACE(); return (bzState.state != NULL); } diff --git a/src/fstring.h b/src/fstring.h index bc23e57..167c055 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -21,10 +21,6 @@ #include "bu/hash.h" #include "bu/util.h" -#ifndef min -#define min( a, b ) ((a @@ -1070,6 +1066,7 @@ namespace Bu } #ifdef BU_TRACE + template void __tracer_format( const t &v ); template<> void __tracer_format( const FString &v ); #endif } diff --git a/src/trace.h b/src/trace.h index 7a1f368..82399c2 100644 --- a/src/trace.h +++ b/src/trace.h @@ -45,6 +45,7 @@ namespace Bu looper( v1 ); fwrite( s, (ptrdiff_t)n-(ptrdiff_t)s, 1, stdout ); fwrite( "\n", 1, 1, stdout ); + fflush( stdout ); } template void __tracer( const char *pf, @@ -57,6 +58,7 @@ namespace Bu looper( v2 ); fwrite( s, (ptrdiff_t)n-(ptrdiff_t)s, 1, stdout ); fwrite( "\n", 1, 1, stdout ); + fflush( stdout ); } template @@ -70,6 +72,7 @@ namespace Bu looper( v3 ); fwrite( s, (ptrdiff_t)n-(ptrdiff_t)s, 1, stdout ); fwrite( "\n", 1, 1, stdout ); + fflush( stdout ); } template @@ -84,6 +87,7 @@ namespace Bu looper( v4 ); fwrite( s, (ptrdiff_t)n-(ptrdiff_t)s, 1, stdout ); fwrite( "\n", 1, 1, stdout ); + fflush( stdout ); } template @@ -99,6 +103,7 @@ namespace Bu looper( v5 ); fwrite( s, (ptrdiff_t)n-(ptrdiff_t)s, 1, stdout ); fwrite( "\n", 1, 1, stdout ); + fflush( stdout ); } template ai; for( int j = 0; j < 10; j++ ) @@ -49,7 +50,13 @@ public: for( Bu::Array::const_iterator i = ci.begin(); i != ci.end(); i++ ) unitTest( (*i) == j++ ); } - + + void iterate2() + { + Bu::Array ai; + for( Bu::Array::iterator i = ai.begin(); i != ai.end(); i++ ) + unitFailed("Empty lists shouldn't be iterated through."); + } }; int main( int argc, char *argv[] ) -- cgit v1.2.3