ソースを参照

whee, it works now

Cary Sandvig 25 年 前
コミット
8acc30a68c

+ 10 - 8
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;
 }

+ 8 - 6
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__ */
 
 

+ 5 - 3
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;
 }