From 469bbcf0701e1eb8a6670c23145b0da87357e178 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 25 Mar 2012 20:00:08 +0000 Subject: Code is all reorganized. We're about ready to release. I should write up a little explenation of the arrangement. --- src/unstable/newline.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/unstable/newline.cpp (limited to 'src/unstable/newline.cpp') 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 @@ +/* + * Copyright (C) 2007-2011 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#include "bu/newline.h" + +Bu::NewLine::NewLine( Bu::Stream &rNext ) : + Bu::Filter( rNext ), + bExChar( false ) +{ +} + +Bu::NewLine::~NewLine() +{ +} + +void Bu::NewLine::start() +{ +} + +Bu::size Bu::NewLine::stop() +{ + return 0; +} + +Bu::size Bu::NewLine::read( void *pBufV, Bu::size iAmnt ) +{ + Bu::size iTotal = 0; + Bu::size iOffset = 0; + Bu::size iRead = rNext.read( pBufV, iAmnt ); + char *pBuf = (char *)pBufV; + + for( Bu::size i = 0; i < iRead; i++ ) + { + if( pBuf[i] == '\r' ) + { + pBuf[i+iOffset] = '\n'; + if( pBuf[i+1] == '\n' ) + { + iOffset--; + } + } + else if( pBuf[i] == '\n' ) + { + pBuf[i+iOffset] = '\n'; + if( pBuf[i+1] == '\r' ) + { + iOffset--; + } + } + else if( iOffset ) + { + pBuf[i+iOffset] = pBuf[i]; + } + } + + iTotal += iRead + iOffset; + return iTotal; +} + +Bu::size Bu::NewLine::write( const void *, Bu::size ) +{ + return 0; +} + -- cgit v1.2.3