From 6e6402825bcd6021d62fd2eb8a0669641fe9c266 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 3 Aug 2009 21:33:33 +0000 Subject: Hey, buffer has some good tweaks, added some stuff and fixed stuff in formatter and base64 no longer accidentally complains about properly formatted streams, as much... --- src/base64.cpp | 9 +++++++-- src/buffer.cpp | 18 +++++++++--------- src/formatter.h | 9 +++++++-- 3 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/base64.cpp b/src/base64.cpp index ccf9077..55df550 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -118,9 +118,14 @@ size_t Bu::Base64::read( void *pBuf, size_t nBytes ) { if( rNext.isEos() ) { - iChars = 0; bEosIn = true; - throw Base64Exception("Premature end of stream detected while decoding Base64 data."); + if( j != 0 ) + { + throw Base64Exception( + "Premature end of stream detected while " + "decoding Base64 data." + ); + } } return sIn; } diff --git a/src/buffer.cpp b/src/buffer.cpp index 5e7fb9a..d4eb8a6 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -40,12 +40,12 @@ void Bu::Buffer::fillReadBuf() { if( iReadBufFill+iReadPos < iBufSize ) { - printf("Buffer: Attempting to read %db.\n", iBufSize-iReadBufFill-iReadPos ); + //printf("Buffer: Attempting to read %db.\n", iBufSize-iReadBufFill-iReadPos ); iReadBufFill += rNext.read( sReadBuf+iReadPos+iReadBufFill, iBufSize-iReadBufFill-iReadPos ); - printf("Buffer: Read from stream, %db now in buffer.\n", iReadBufFill ); + //printf("Buffer: Read from stream, %db now in buffer.\n", iReadBufFill ); } } @@ -82,7 +82,7 @@ size_t Bu::Buffer::read( void *pBuf, size_t nBytes ) } while( nTotRead < nBytes && iReadBufFill > 0 ); - printf("Buffer: %db returned, %db remain in buffer.\n", nTotRead, iReadBufFill ); + //printf("Buffer: %db returned, %db remain in buffer.\n", nTotRead, iReadBufFill ); return nTotRead; } @@ -107,14 +107,14 @@ size_t Bu::Buffer::write( const void *pBuf, size_t nBytes ) ); nTotWrote += iAmnt; iWriteBufFill += iAmnt; - printf("Buffer: Moved %db to write buffer, %db filled now.\n", - iAmnt, iWriteBufFill ); + //printf("Buffer: Moved %db to write buffer, %db filled now.\n", + //iAmnt, iWriteBufFill ); } while( iWritePos+iWriteBufFill == iBufSize ) { - printf("iWritePos = %d\n", iWritePos ); + //printf("iWritePos = %d\n", iWritePos ); int iWr = rNext.write( sWriteBuf+iWritePos, iWriteBufFill ); - printf("Buffer: Wrote %db from buffer to stream, %db filled now.\n", iWr, iWriteBufFill-iWr ); + //printf("Buffer: Wrote %db from buffer to stream, %db filled now.\n", iWr, iWriteBufFill-iWr ); if( iWr == 0 ) { return nTotWrote; @@ -139,12 +139,12 @@ void Bu::Buffer::flush() { if( iWriteBufFill > 0 ) { - printf("Buffer: Flushing remaining data, %db.\n", iWriteBufFill ); + //printf("Buffer: Flushing remaining data, %db.\n", iWriteBufFill ); int iWr = 0; do { iWr = rNext.write( sWriteBuf+iWritePos, iWriteBufFill ); - printf("Buffer: %db written to stream.\n", iWr ); + //printf("Buffer: %db written to stream.\n", iWr ); iWritePos += iWr; iWriteBufFill -= iWr; } while( iWriteBufFill > 0 && iWr > 0 ); diff --git a/src/formatter.h b/src/formatter.h index aacf893..8bb8e08 100644 --- a/src/formatter.h +++ b/src/formatter.h @@ -64,9 +64,14 @@ namespace Bu return Fmt( uWidth, 16, Right, false, bCaps, '0' ); } - static Fmt oct( unsigned int uWidth=0, bool bCaps=true ) + static Fmt oct( unsigned int uWidth=0 ) { - return Fmt( uWidth, 8, Right, false, bCaps, '0' ); + return Fmt( uWidth, 8, Right, false, false, '0' ); + } + + static Fmt bin( unsigned int uWidth=0 ) + { + return Fmt( uWidth, 1, Right, false, false, '0' ); } static Fmt ptr( bool bCaps=true ) -- cgit v1.2.3