From d66d62236b3354e26157efa91689d1a22ae3866d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 12 Feb 2010 06:33:09 +0000 Subject: Well, it compiles. I think I may make newline inherit from buffer, I dunno... --- src/newline.cpp | 14 +++++++++----- src/tests/csv.cpp | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/newline.cpp b/src/newline.cpp index 0dbbae5..00c73f9 100644 --- a/src/newline.cpp +++ b/src/newline.cpp @@ -19,24 +19,27 @@ size_t Bu::NewLine::stop() return 0; } -size_t Bu::NewLine::read( void *pBuf, size_t iAmnt ) +size_t Bu::NewLine::read( void *pBufV, size_t iAmnt ) { - size_t iRead = rNext.read( pBuf, iAmnt ); + size_t iTotal = 0; size_t iOffset = 0; + size_t iRead = rNext.read( pBufV, iAmnt ); + char *pBuf = (char *)pBufV; for( size_t i = 0; i < iRead; i++ ) { if( pBuf[i] == '\r' ) { pBuf[i+iOffset] = '\n'; - if( pBuf[j+1] == '\n' ) + if( pBuf[i+1] == '\n' ) { iOffset--; } } else if( pBuf[i] == '\n' ) { - if( pBuf[j+1] == '\r' ) + pBuf[i+iOffset] = '\n'; + if( pBuf[i+1] == '\r' ) { iOffset--; } @@ -47,7 +50,8 @@ size_t Bu::NewLine::read( void *pBuf, size_t iAmnt ) } } - iRead += iOffset; + iTotal += iRead + iOffset; + return iTotal; } size_t Bu::NewLine::write( const void *pBuf, size_t iAmnt ) diff --git a/src/tests/csv.cpp b/src/tests/csv.cpp index 03e1df8..96db756 100644 --- a/src/tests/csv.cpp +++ b/src/tests/csv.cpp @@ -2,6 +2,7 @@ #include "bu/file.h" #include "bu/newline.h" #include "bu/csvreader.h" +#include "bu/buffer.h" #include "bu/sio.h" using namespace Bu; @@ -23,7 +24,8 @@ public: { File fIn( aArgs[1], File::Read ); NewLine nlIn( fIn ); - CsvReader rCsv( nlIn ); + Buffer bIn( nlIn ); + CsvReader rCsv( bIn ); while( !fIn.isEos() ) { sio << rCsv.readLine() << sio.nl; -- cgit v1.2.3