aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/newline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/unstable/newline.cpp')
-rw-r--r--src/unstable/newline.cpp68
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
10Bu::NewLine::NewLine( Bu::Stream &rNext ) :
11 Bu::Filter( rNext ),
12 bExChar( false )
13{
14}
15
16Bu::NewLine::~NewLine()
17{
18}
19
20void Bu::NewLine::start()
21{
22}
23
24Bu::size Bu::NewLine::stop()
25{
26 return 0;
27}
28
29Bu::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
64Bu::size Bu::NewLine::write( const void *, Bu::size )
65{
66 return 0;
67}
68