From 22e51abaebd4f0c194e505d879f9b6a2fc31890d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 10 Jul 2007 00:32:36 +0000 Subject: Fixed a bunch of stuff, I don't even know what... --- src/client.cpp | 4 ++-- src/client.h | 2 +- src/fstring.h | 15 +++++++++------ src/logger.cpp | 9 +++++++-- 4 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/client.cpp b/src/client.cpp index 9f0eb21..dc91e4b 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -166,9 +166,9 @@ void Bu::Client::read( void *pData, int nBytes ) } } -void Bu::Client::peek( void *pData, int nBytes ) +void Bu::Client::peek( void *pData, int nBytes, int nOffset ) { - memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes ); + memcpy( pData, sReadBuf.getStr()+nRBOffset+nOffset, nBytes ); } void Bu::Client::seek( int nBytes ) diff --git a/src/client.h b/src/client.h index 5947521..2b7448c 100644 --- a/src/client.h +++ b/src/client.h @@ -34,7 +34,7 @@ namespace Bu void write( uint32_t nData ); void write( uint64_t nData ); void read( void *pData, int nBytes ); - void peek( void *pData, int nBytes ); + void peek( void *pData, int nBytes, int nOffset=0 ); void seek( int nBytes ); long getInputSize(); diff --git a/src/fstring.h b/src/fstring.h index 00bb12c..73b04ab 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -222,10 +222,13 @@ namespace Bu Chunk *pNew = newChunk( nNewSize ); long nNewLen = (nNewSizepData, pFirst->pData, nNewLen ); + if( nLength > 0 ) + { + cpy( pNew->pData, pFirst->pData, nNewLen ); + aChr.deallocate( pFirst->pData, pFirst->nLength+1 ); + aChunk.deallocate( pFirst, 1 ); + } pNew->pData[nNewLen] = (chr)0; - aChr.deallocate( pFirst->pData, pFirst->nLength+1 ); - aChunk.deallocate( pFirst, 1 ); pFirst = pLast = pNew; nLength = nNewSize; } @@ -396,7 +399,7 @@ namespace Bu flatten(); const chr *a = pData; chr *b = pFirst->pData; - for( ; *a!=(chr)0; a++, b++ ) + for( ; *a!=(chr)0 || *b!=(chr)0; a++, b++ ) { if( *a != *b ) return false; @@ -420,7 +423,7 @@ namespace Bu pData.flatten(); const chr *a = pData.pFirst->pData; chr *b = pFirst->pData; - for( ; *a!=(chr)0; a++, b++ ) + for( ; *a!=(chr)0 || *b!=(chr)0; a++, b++ ) { if( *a != *b ) return false; @@ -587,7 +590,7 @@ namespace Bu long nNewLen = nLength - nAmnt; flatten(); Chunk *pNew = newChunk( nNewLen ); - cpy( pNew->pData, pFirst->pData, nNewLen ); + cpy( pNew->pData, pFirst->pData+nAmnt, nNewLen ); clear(); appendChunk( pNew ); } diff --git a/src/logger.cpp b/src/logger.cpp index aedfe0f..8c058d1 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -5,6 +5,7 @@ Bu::Logger::Logger() { + setFormat("%t"); } Bu::Logger::~Logger() @@ -27,7 +28,7 @@ void Bu::Logger::log( int nLevel, const char *sFile, const char *sFunction, int char *line = NULL; struct tm *pTime; pTime = localtime( &t ); - asprintf( + if ( asprintf( &line, sLogFormat.getStr(), pTime->tm_year+1900, @@ -41,7 +42,11 @@ void Bu::Logger::log( int nLevel, const char *sFile, const char *sFunction, int nLine, text, sFunction - ); + ) < 0 ) + { + //printf("LOGGER: ERROR ALLOCATING STRING: %s\n", strerror( errno ) ); + return; + } write( fileno(stdout), line, strlen(line) ); free( text ); free( line ); -- cgit v1.2.3