[net.lang.c++] Fix for stream putback bug

keith@cecil.UUCP (keith gorlen) (07/24/86)

The stream function "putback" doesn't work if the character being put
back happened to be the last in the buffer.  In this case the byte just
before the buffer will be clobbered.

A quick hack to work around this bug is to modify streambuf::allocate in
file streambuf.c to allocate an extra byte just before the buffer area:
	
		if ((base = new char[BUFSIZE+1]) != NULL) {
			pptr = gptr = ++base;

streambuf::~streambuf in file stream.h must also be modified:

	~streambuf() { if (base != NULL && alloc) delete --base; }

This isn't a clean fix because putback can still cause problems when
buffers are specified via the streambuf::streambuf(char*,int)
constructor.

-- 
---
	Keith Gorlen
	Building 12A, Room 2017
	Computer Systems Laboratory
	Division of Computer Research and Technology
	National Institutes of Health
	Bethesda, MD 20892
	phone:	(301) 496-5363
	uucp:	{decvax!}seismo!elsie!cecil!keith