From 2cd1a89109651a19138aec9988d765208d7709e5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 1 Nov 2010 23:15:11 +0000 Subject: Minor changes to the float that may circumvent some stupidness in the mingwrt snprintf code. I really need to write my own number parser/writer. --- src/float.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/float.cpp') diff --git a/src/float.cpp b/src/float.cpp index 139df3e..e85dff8 100644 --- a/src/float.cpp +++ b/src/float.cpp @@ -19,21 +19,28 @@ Gats::Float::~Float() void Gats::Float::write( Bu::Stream &rOut ) const { - char buf[50]; - - int iSize = snprintf( buf, 50, "%la", fVal ); + if( sWriteCache.isEmpty() ) + { + char buf[50]; + int iSize = snprintf( buf, 50, "%la", fVal ); + sWriteCache.set( buf, iSize ); + } rOut.write("f", 1 ); - Gats::Integer::writePackedInt( rOut, iSize ); - rOut.write( buf, iSize ); + Gats::Integer::writePackedInt( rOut, sWriteCache.getSize() ); + rOut.write( sWriteCache.getStr(), sWriteCache.getSize() ); } +#include +using namespace Bu; + void Gats::Float::read( Bu::Stream &rIn, char cType ) { int iSize; Gats::Integer::readPackedInt( rIn, iSize ); char buf[50]; - rIn.read( buf, iSize ); + buf[rIn.read( buf, iSize )] = '\0'; + sio << "Reading float, iSize = " << iSize << ", str = " << buf << sio.nl; sscanf( buf, "%la", &fVal ); } -- cgit v1.2.3