aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-05-02 01:24:55 +0000
committerMike Buland <eichlan@xagasoft.com>2010-05-02 01:24:55 +0000
commitfdf7e508f70bbf24adeb1beba2fc5ab825217f92 (patch)
treefb2703063670a3ed51665f5854d9d7b5fe68efbf
parentb4f8ebcb496ca231fa737307a0f9757d01e37c7b (diff)
downloadlibbu++-fdf7e508f70bbf24adeb1beba2fc5ab825217f92.tar.gz
libbu++-fdf7e508f70bbf24adeb1beba2fc5ab825217f92.tar.bz2
libbu++-fdf7e508f70bbf24adeb1beba2fc5ab825217f92.tar.xz
libbu++-fdf7e508f70bbf24adeb1beba2fc5ab825217f92.zip
wow, bug fixes everywhere.
Diffstat (limited to '')
-rw-r--r--src/client.cpp19
-rw-r--r--src/client.h4
-rw-r--r--src/fbasicstring.h2
-rw-r--r--src/formatter.cpp1
4 files changed, 22 insertions, 4 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 2ea72a2..95008f9 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -173,8 +173,14 @@ void Bu::Client::write( uint64_t nData )
173 sWriteBuf.append( (const char *)&nData, sizeof(nData) ); 173 sWriteBuf.append( (const char *)&nData, sizeof(nData) );
174} 174}
175 175
176void Bu::Client::read( void *pData, int nBytes ) 176int Bu::Client::read( void *pData, int nBytes )
177{ 177{
178 if( nBytes > sReadBuf.getSize()-nRBOffset )
179 {
180 nBytes = sReadBuf.getSize()-nRBOffset;
181 if( nBytes <= 0 )
182 return 0;
183 }
178 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes ); 184 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes );
179 nRBOffset += nBytes; 185 nRBOffset += nBytes;
180 if( sReadBuf.getSize()-nRBOffset == 0 ) 186 if( sReadBuf.getSize()-nRBOffset == 0 )
@@ -192,11 +198,20 @@ void Bu::Client::read( void *pData, int nBytes )
192 sReadBuf.trimFront( nRBOffset ); 198 sReadBuf.trimFront( nRBOffset );
193 nRBOffset = 0; 199 nRBOffset = 0;
194 } 200 }
201
202 return nBytes;
195} 203}
196 204
197void Bu::Client::peek( void *pData, int nBytes, int nOffset ) 205int Bu::Client::peek( void *pData, int nBytes, int nOffset )
198{ 206{
207 if( nBytes+nOffset > sReadBuf.getSize()-nRBOffset )
208 {
209 nBytes = sReadBuf.getSize()-nRBOffset-nOffset;
210 if( nBytes <= 0 )
211 return 0;
212 }
199 memcpy( pData, sReadBuf.getStr()+nRBOffset+nOffset, nBytes ); 213 memcpy( pData, sReadBuf.getStr()+nRBOffset+nOffset, nBytes );
214 return nBytes;
200} 215}
201 216
202void Bu::Client::seek( int nBytes ) 217void Bu::Client::seek( int nBytes )
diff --git a/src/client.h b/src/client.h
index 28db088..aecb16c 100644
--- a/src/client.h
+++ b/src/client.h
@@ -43,8 +43,8 @@ namespace Bu
43 void write( uint16_t nData ); 43 void write( uint16_t nData );
44 void write( uint32_t nData ); 44 void write( uint32_t nData );
45 void write( uint64_t nData ); 45 void write( uint64_t nData );
46 void read( void *pData, int nBytes ); 46 int read( void *pData, int nBytes );
47 void peek( void *pData, int nBytes, int nOffset=0 ); 47 int peek( void *pData, int nBytes, int nOffset=0 );
48 void seek( int nBytes ); 48 void seek( int nBytes );
49 long getInputSize(); 49 long getInputSize();
50 50
diff --git a/src/fbasicstring.h b/src/fbasicstring.h
index e965de8..73951a6 100644
--- a/src/fbasicstring.h
+++ b/src/fbasicstring.h
@@ -1497,6 +1497,8 @@ namespace Bu
1497 return true; 1497 return true;
1498 if( core->nLength != pData.core->nLength ) 1498 if( core->nLength != pData.core->nLength )
1499 return false; 1499 return false;
1500 if( pData.core->pFirst == NULL || core->pFirst == NULL )
1501 return false;
1500 1502
1501 flatten(); 1503 flatten();
1502 pData.flatten(); 1504 pData.flatten();
diff --git a/src/formatter.cpp b/src/formatter.cpp
index 3e0f41e..ce92caa 100644
--- a/src/formatter.cpp
+++ b/src/formatter.cpp
@@ -11,6 +11,7 @@
11 11
12Bu::Formatter::Formatter( Stream &rStream ) : 12Bu::Formatter::Formatter( Stream &rStream ) :
13 rStream( rStream ), 13 rStream( rStream ),
14 bTempFmt( false ),
14 uIndent( 0 ), 15 uIndent( 0 ),
15 cIndent( '\t' ) 16 cIndent( '\t' )
16{ 17{