aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-07-10 00:32:36 +0000
committerMike Buland <eichlan@xagasoft.com>2007-07-10 00:32:36 +0000
commit22e51abaebd4f0c194e505d879f9b6a2fc31890d (patch)
tree25b57bfbc04af4a772516983d926f3858fe0cd61 /src
parent2de3693dd24463c5a02b9308ddfd674f58bac7c1 (diff)
downloadlibbu++-22e51abaebd4f0c194e505d879f9b6a2fc31890d.tar.gz
libbu++-22e51abaebd4f0c194e505d879f9b6a2fc31890d.tar.bz2
libbu++-22e51abaebd4f0c194e505d879f9b6a2fc31890d.tar.xz
libbu++-22e51abaebd4f0c194e505d879f9b6a2fc31890d.zip
Fixed a bunch of stuff, I don't even know what...
Diffstat (limited to '')
-rw-r--r--src/client.cpp4
-rw-r--r--src/client.h2
-rw-r--r--src/fstring.h15
-rw-r--r--src/logger.cpp9
4 files changed, 19 insertions, 11 deletions
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 )
166 } 166 }
167} 167}
168 168
169void Bu::Client::peek( void *pData, int nBytes ) 169void Bu::Client::peek( void *pData, int nBytes, int nOffset )
170{ 170{
171 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes ); 171 memcpy( pData, sReadBuf.getStr()+nRBOffset+nOffset, nBytes );
172} 172}
173 173
174void Bu::Client::seek( int nBytes ) 174void 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
34 void write( uint32_t nData ); 34 void write( uint32_t nData );
35 void write( uint64_t nData ); 35 void write( uint64_t nData );
36 void read( void *pData, int nBytes ); 36 void read( void *pData, int nBytes );
37 void peek( void *pData, int nBytes ); 37 void peek( void *pData, int nBytes, int nOffset=0 );
38 void seek( int nBytes ); 38 void seek( int nBytes );
39 long getInputSize(); 39 long getInputSize();
40 40
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
222 222
223 Chunk *pNew = newChunk( nNewSize ); 223 Chunk *pNew = newChunk( nNewSize );
224 long nNewLen = (nNewSize<nLength)?(nNewSize):(nLength); 224 long nNewLen = (nNewSize<nLength)?(nNewSize):(nLength);
225 cpy( pNew->pData, pFirst->pData, nNewLen ); 225 if( nLength > 0 )
226 {
227 cpy( pNew->pData, pFirst->pData, nNewLen );
228 aChr.deallocate( pFirst->pData, pFirst->nLength+1 );
229 aChunk.deallocate( pFirst, 1 );
230 }
226 pNew->pData[nNewLen] = (chr)0; 231 pNew->pData[nNewLen] = (chr)0;
227 aChr.deallocate( pFirst->pData, pFirst->nLength+1 );
228 aChunk.deallocate( pFirst, 1 );
229 pFirst = pLast = pNew; 232 pFirst = pLast = pNew;
230 nLength = nNewSize; 233 nLength = nNewSize;
231 } 234 }
@@ -396,7 +399,7 @@ namespace Bu
396 flatten(); 399 flatten();
397 const chr *a = pData; 400 const chr *a = pData;
398 chr *b = pFirst->pData; 401 chr *b = pFirst->pData;
399 for( ; *a!=(chr)0; a++, b++ ) 402 for( ; *a!=(chr)0 || *b!=(chr)0; a++, b++ )
400 { 403 {
401 if( *a != *b ) 404 if( *a != *b )
402 return false; 405 return false;
@@ -420,7 +423,7 @@ namespace Bu
420 pData.flatten(); 423 pData.flatten();
421 const chr *a = pData.pFirst->pData; 424 const chr *a = pData.pFirst->pData;
422 chr *b = pFirst->pData; 425 chr *b = pFirst->pData;
423 for( ; *a!=(chr)0; a++, b++ ) 426 for( ; *a!=(chr)0 || *b!=(chr)0; a++, b++ )
424 { 427 {
425 if( *a != *b ) 428 if( *a != *b )
426 return false; 429 return false;
@@ -587,7 +590,7 @@ namespace Bu
587 long nNewLen = nLength - nAmnt; 590 long nNewLen = nLength - nAmnt;
588 flatten(); 591 flatten();
589 Chunk *pNew = newChunk( nNewLen ); 592 Chunk *pNew = newChunk( nNewLen );
590 cpy( pNew->pData, pFirst->pData, nNewLen ); 593 cpy( pNew->pData, pFirst->pData+nAmnt, nNewLen );
591 clear(); 594 clear();
592 appendChunk( pNew ); 595 appendChunk( pNew );
593 } 596 }
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 @@
5 5
6Bu::Logger::Logger() 6Bu::Logger::Logger()
7{ 7{
8 setFormat("%t");
8} 9}
9 10
10Bu::Logger::~Logger() 11Bu::Logger::~Logger()
@@ -27,7 +28,7 @@ void Bu::Logger::log( int nLevel, const char *sFile, const char *sFunction, int
27 char *line = NULL; 28 char *line = NULL;
28 struct tm *pTime; 29 struct tm *pTime;
29 pTime = localtime( &t ); 30 pTime = localtime( &t );
30 asprintf( 31 if ( asprintf(
31 &line, 32 &line,
32 sLogFormat.getStr(), 33 sLogFormat.getStr(),
33 pTime->tm_year+1900, 34 pTime->tm_year+1900,
@@ -41,7 +42,11 @@ void Bu::Logger::log( int nLevel, const char *sFile, const char *sFunction, int
41 nLine, 42 nLine,
42 text, 43 text,
43 sFunction 44 sFunction
44 ); 45 ) < 0 )
46 {
47 //printf("LOGGER: ERROR ALLOCATING STRING: %s\n", strerror( errno ) );
48 return;
49 }
45 write( fileno(stdout), line, strlen(line) ); 50 write( fileno(stdout), line, strlen(line) );
46 free( text ); 51 free( text );
47 free( line ); 52 free( line );