From 8acc30a68c99efe4ff0766652c168cc62406400e Mon Sep 17 00:00:00 2001 From: Cary Sandvig Date: Wed, 13 Dec 2000 20:07:37 +0000 Subject: [PATCH] whee, it works now --- dtool/src/dtoolutil/pfstream.I | 18 ++++++++++-------- dtool/src/dtoolutil/pfstream.h | 14 ++++++++------ dtool/src/dtoolutil/pfstreamBuf.cxx | 8 +++++--- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/dtool/src/dtoolutil/pfstream.I b/dtool/src/dtoolutil/pfstream.I index 542e2a8038..dc1d551c17 100644 --- a/dtool/src/dtoolutil/pfstream.I +++ b/dtool/src/dtoolutil/pfstream.I @@ -3,26 +3,28 @@ // //////////////////////////////////////////////////////////////////// -INLINE ipfstream::ipfstream(const string cmd) : _psb(PipeStreamBuf::Input) { +INLINE IPipeStream::IPipeStream(const std::string cmd) + : istream(&_psb), _psb(PipeStreamBuf::Input) { _psb.command(cmd); } -INLINE void ipfstream::flush(void) { +INLINE void IPipeStream::flush(void) { _psb.flush(); } -INLINE ipfstream::ipfstream(void) : _psb(PipeStreamBuf::Input) { - cerr << "should never call default constructor of ipfstream" << endl; +INLINE IPipeStream::IPipeStream(void) : _psb(PipeStreamBuf::Input) { + cerr << "should never call default constructor of IPipeStream" << endl; } -INLINE opfstream::opfstream(const string cmd) : _psb(PipeStreamBuf::Output) { +INLINE OPipeStream::OPipeStream(const std::string cmd) + : ostream(&_psb), _psb(PipeStreamBuf::Output) { _psb.command(cmd); } -INLINE void opfstream::flush(void) { +INLINE void OPipeStream::flush(void) { _psb.flush(); } -INLINE opfstream::opfstream(void) : _psb(PipeStreamBuf::Output) { - cerr << "should never call default constructor of opfstream" << endl; +INLINE OPipeStream::OPipeStream(void) : _psb(PipeStreamBuf::Output) { + cerr << "should never call default constructor of OPipeStream" << endl; } diff --git a/dtool/src/dtoolutil/pfstream.h b/dtool/src/dtoolutil/pfstream.h index 78502cf0ef..971ba8a8b2 100644 --- a/dtool/src/dtoolutil/pfstream.h +++ b/dtool/src/dtoolutil/pfstream.h @@ -8,28 +8,30 @@ #include "pfstreamBuf.h" -class EXPCL_DTOOL ipfstream : public istream { +class EXPCL_DTOOL IPipeStream : public istream { PUBLISHED: - INLINE ipfstream(const string); + INLINE IPipeStream(const std::string); INLINE void flush(void); private: PipeStreamBuf _psb; - INLINE ipfstream(void); + INLINE IPipeStream(void); }; -class EXPCL_DTOOL opfstream : public ostream { +class EXPCL_DTOOL OPipeStream : public ostream { PUBLISHED: - INLINE opfstream(const string); + INLINE OPipeStream(const std::string); INLINE void flush(void); private: PipeStreamBuf _psb; - INLINE opfstream(void); + INLINE OPipeStream(void); }; +#include "pfstream.I" + #endif /* __PFSTREAM_H__ */ diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index 4cef88a2a9..41b9161410 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -20,7 +20,7 @@ PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : _dir(dir), allocate(); assert((dir == Input) || (dir == Output)); if (dir == Input) { - cerr << "allocated reserve is " << blen() << " bytes long" << endl; + // cerr << "allocated reserve is " << blen() << " bytes long" << endl; setg(base(), ebuf(), ebuf()); } else { setp(base(), ebuf()); @@ -74,8 +74,10 @@ int PipeStreamBuf::sync(void) { pbump(-n); } else { streamsize n = egptr() - gptr(); - gbump(n); // flush all our stored input away - cerr << "pfstream tossed out " << n << " bytes" << endl; + if (n != 0) { + gbump(n); // flush all our stored input away + cerr << "pfstream tossed out " << n << " bytes" << endl; + } } return 0; }