diff --git a/dtool/src/dtoolutil/pfstream.h b/dtool/src/dtoolutil/pfstream.h index ca08aedbac..78502cf0ef 100644 --- a/dtool/src/dtoolutil/pfstream.h +++ b/dtool/src/dtoolutil/pfstream.h @@ -6,7 +6,7 @@ #ifndef __PFSTREAM_H__ #define __PFSTREAM_H__ -#include "pfstreambuf.h" +#include "pfstreamBuf.h" class EXPCL_DTOOL ipfstream : public istream { PUBLISHED: diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index 6f50fe55df..4cef88a2a9 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -83,21 +83,35 @@ int PipeStreamBuf::sync(void) { int PipeStreamBuf::underflow(void) { assert(_pipe != (FILE*)0L); assert(_dir == Input); + if ((eback() == (char*)0L) || (gptr() == (char*)0L) || + (egptr() == (char*)0L)) { + // must be in win32 + char* buf = new char[4096]; + char* ebuf = &(buf[4096]); + setg(buf, ebuf, ebuf); + } if (gptr() < egptr()) { char c = *(gptr()); return c; } if (feof(_pipe) != 0) return EOF; - // size_t len = ebuf() - base(); - size_t len = 1024; +#ifdef WIN32_VC + size_t len = 4096; +#else /* WIN32_VC */ + size_t len = ebuf() - base(); +#endif /* WIN32_VC */ char* buf = new char[len]; size_t n = fread(buf, 1, len, _pipe); int ret = buf[0]; if (n == 0) ret = EOF; else { - // memcpy(base()+(len - n), buf, n); +#ifdef WIN32_VC + memcpy(eback()+(len-n), buf, n); +#else /* WIN32_VC */ + memcpy(base()+(len-n), buf, n); +#endif /* WIN32_VC */ gbump(-n); } delete buf;