浏览代码

whee, it works now

Cary Sandvig 25 年之前
父节点
当前提交
8acc30a68c
共有 3 个文件被更改,包括 23 次插入17 次删除
  1. 10 8
      dtool/src/dtoolutil/pfstream.I
  2. 8 6
      dtool/src/dtoolutil/pfstream.h
  3. 5 3
      dtool/src/dtoolutil/pfstreamBuf.cxx

+ 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);
   _psb.command(cmd);
 }
 }
 
 
-INLINE void ipfstream::flush(void) {
+INLINE void IPipeStream::flush(void) {
   _psb.flush();
   _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);
   _psb.command(cmd);
 }
 }
 
 
-INLINE void opfstream::flush(void) {
+INLINE void OPipeStream::flush(void) {
   _psb.flush();
   _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"
 #include "pfstreamBuf.h"
 
 
-class EXPCL_DTOOL ipfstream : public istream {
+class EXPCL_DTOOL IPipeStream : public istream {
 PUBLISHED:
 PUBLISHED:
-  INLINE ipfstream(const string);
+  INLINE IPipeStream(const std::string);
 
 
   INLINE void flush(void);
   INLINE void flush(void);
 private:
 private:
   PipeStreamBuf _psb;
   PipeStreamBuf _psb;
 
 
-  INLINE ipfstream(void);
+  INLINE IPipeStream(void);
 };
 };
 
 
-class EXPCL_DTOOL opfstream : public ostream {
+class EXPCL_DTOOL OPipeStream : public ostream {
 PUBLISHED:
 PUBLISHED:
-  INLINE opfstream(const string);
+  INLINE OPipeStream(const std::string);
 
 
   INLINE void flush(void);
   INLINE void flush(void);
 private:
 private:
   PipeStreamBuf _psb;
   PipeStreamBuf _psb;
 
 
-  INLINE opfstream(void);
+  INLINE OPipeStream(void);
 };
 };
 
 
+#include "pfstream.I"
+
 #endif /* __PFSTREAM_H__ */
 #endif /* __PFSTREAM_H__ */
 
 
 
 

+ 5 - 3
dtool/src/dtoolutil/pfstreamBuf.cxx

@@ -20,7 +20,7 @@ PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : _dir(dir),
   allocate();
   allocate();
   assert((dir == Input) || (dir == Output));
   assert((dir == Input) || (dir == Output));
   if (dir == Input) {
   if (dir == Input) {
-    cerr << "allocated reserve is " << blen() << " bytes long" << endl;
+    //    cerr << "allocated reserve is " << blen() << " bytes long" << endl;
     setg(base(), ebuf(), ebuf());
     setg(base(), ebuf(), ebuf());
   } else {
   } else {
     setp(base(), ebuf());
     setp(base(), ebuf());
@@ -74,8 +74,10 @@ int PipeStreamBuf::sync(void) {
     pbump(-n);
     pbump(-n);
   } else {
   } else {
     streamsize n = egptr() - gptr();
     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;
   return 0;
 }
 }