diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-02-12 06:33:09 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-02-12 06:33:09 +0000 |
commit | d66d62236b3354e26157efa91689d1a22ae3866d (patch) | |
tree | be168d183a56189d039fa3fbffc25d75fc1d0633 | |
parent | d61161061bd5998ef4b1fc2aaad2cf4bbd78e90d (diff) | |
download | libbu++-d66d62236b3354e26157efa91689d1a22ae3866d.tar.gz libbu++-d66d62236b3354e26157efa91689d1a22ae3866d.tar.bz2 libbu++-d66d62236b3354e26157efa91689d1a22ae3866d.tar.xz libbu++-d66d62236b3354e26157efa91689d1a22ae3866d.zip |
Well, it compiles. I think I may make newline inherit from buffer, I dunno...
-rw-r--r-- | src/newline.cpp | 14 | ||||
-rw-r--r-- | 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() | |||
19 | return 0; | 19 | return 0; |
20 | } | 20 | } |
21 | 21 | ||
22 | size_t Bu::NewLine::read( void *pBuf, size_t iAmnt ) | 22 | size_t Bu::NewLine::read( void *pBufV, size_t iAmnt ) |
23 | { | 23 | { |
24 | size_t iRead = rNext.read( pBuf, iAmnt ); | 24 | size_t iTotal = 0; |
25 | size_t iOffset = 0; | 25 | size_t iOffset = 0; |
26 | size_t iRead = rNext.read( pBufV, iAmnt ); | ||
27 | char *pBuf = (char *)pBufV; | ||
26 | 28 | ||
27 | for( size_t i = 0; i < iRead; i++ ) | 29 | for( size_t i = 0; i < iRead; i++ ) |
28 | { | 30 | { |
29 | if( pBuf[i] == '\r' ) | 31 | if( pBuf[i] == '\r' ) |
30 | { | 32 | { |
31 | pBuf[i+iOffset] = '\n'; | 33 | pBuf[i+iOffset] = '\n'; |
32 | if( pBuf[j+1] == '\n' ) | 34 | if( pBuf[i+1] == '\n' ) |
33 | { | 35 | { |
34 | iOffset--; | 36 | iOffset--; |
35 | } | 37 | } |
36 | } | 38 | } |
37 | else if( pBuf[i] == '\n' ) | 39 | else if( pBuf[i] == '\n' ) |
38 | { | 40 | { |
39 | if( pBuf[j+1] == '\r' ) | 41 | pBuf[i+iOffset] = '\n'; |
42 | if( pBuf[i+1] == '\r' ) | ||
40 | { | 43 | { |
41 | iOffset--; | 44 | iOffset--; |
42 | } | 45 | } |
@@ -47,7 +50,8 @@ size_t Bu::NewLine::read( void *pBuf, size_t iAmnt ) | |||
47 | } | 50 | } |
48 | } | 51 | } |
49 | 52 | ||
50 | iRead += iOffset; | 53 | iTotal += iRead + iOffset; |
54 | return iTotal; | ||
51 | } | 55 | } |
52 | 56 | ||
53 | size_t Bu::NewLine::write( const void *pBuf, size_t iAmnt ) | 57 | 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 @@ | |||
2 | #include "bu/file.h" | 2 | #include "bu/file.h" |
3 | #include "bu/newline.h" | 3 | #include "bu/newline.h" |
4 | #include "bu/csvreader.h" | 4 | #include "bu/csvreader.h" |
5 | #include "bu/buffer.h" | ||
5 | #include "bu/sio.h" | 6 | #include "bu/sio.h" |
6 | 7 | ||
7 | using namespace Bu; | 8 | using namespace Bu; |
@@ -23,7 +24,8 @@ public: | |||
23 | { | 24 | { |
24 | File fIn( aArgs[1], File::Read ); | 25 | File fIn( aArgs[1], File::Read ); |
25 | NewLine nlIn( fIn ); | 26 | NewLine nlIn( fIn ); |
26 | CsvReader rCsv( nlIn ); | 27 | Buffer bIn( nlIn ); |
28 | CsvReader rCsv( bIn ); | ||
27 | while( !fIn.isEos() ) | 29 | while( !fIn.isEos() ) |
28 | { | 30 | { |
29 | sio << rCsv.readLine() << sio.nl; | 31 | sio << rCsv.readLine() << sio.nl; |