diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/unstable/newline.cpp | |
parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
download | libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2 libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip |
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/unstable/newline.cpp')
-rw-r--r-- | src/unstable/newline.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/unstable/newline.cpp b/src/unstable/newline.cpp new file mode 100644 index 0000000..ffc9eb0 --- /dev/null +++ b/src/unstable/newline.cpp | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/newline.h" | ||
9 | |||
10 | Bu::NewLine::NewLine( Bu::Stream &rNext ) : | ||
11 | Bu::Filter( rNext ), | ||
12 | bExChar( false ) | ||
13 | { | ||
14 | } | ||
15 | |||
16 | Bu::NewLine::~NewLine() | ||
17 | { | ||
18 | } | ||
19 | |||
20 | void Bu::NewLine::start() | ||
21 | { | ||
22 | } | ||
23 | |||
24 | Bu::size Bu::NewLine::stop() | ||
25 | { | ||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | Bu::size Bu::NewLine::read( void *pBufV, Bu::size iAmnt ) | ||
30 | { | ||
31 | Bu::size iTotal = 0; | ||
32 | Bu::size iOffset = 0; | ||
33 | Bu::size iRead = rNext.read( pBufV, iAmnt ); | ||
34 | char *pBuf = (char *)pBufV; | ||
35 | |||
36 | for( Bu::size i = 0; i < iRead; i++ ) | ||
37 | { | ||
38 | if( pBuf[i] == '\r' ) | ||
39 | { | ||
40 | pBuf[i+iOffset] = '\n'; | ||
41 | if( pBuf[i+1] == '\n' ) | ||
42 | { | ||
43 | iOffset--; | ||
44 | } | ||
45 | } | ||
46 | else if( pBuf[i] == '\n' ) | ||
47 | { | ||
48 | pBuf[i+iOffset] = '\n'; | ||
49 | if( pBuf[i+1] == '\r' ) | ||
50 | { | ||
51 | iOffset--; | ||
52 | } | ||
53 | } | ||
54 | else if( iOffset ) | ||
55 | { | ||
56 | pBuf[i+iOffset] = pBuf[i]; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | iTotal += iRead + iOffset; | ||
61 | return iTotal; | ||
62 | } | ||
63 | |||
64 | Bu::size Bu::NewLine::write( const void *, Bu::size ) | ||
65 | { | ||
66 | return 0; | ||
67 | } | ||
68 | |||