Thread View: net.lang.c++
1 messages
1 total messages
Started by keith gorlen
Thu, 24 Jul 1986 12:43
Fix for stream putback bug
Author: keith gorlen
Date: Thu, 24 Jul 1986 12:43
Date: Thu, 24 Jul 1986 12:43
29 lines
1353 bytes
1353 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads