Article View: net.lang.c++
Article #271Fix for stream putback bug
From: 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
Technical Details
Message-ID:
<73@cecil.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!elsie!cecil!keithShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!elsie!cecil!keith From: keith@cecil.UUCP (keith gorlen) Newsgroups: net.lang.c++ Subject: Fix for stream putback bug Message-ID: <73@cecil.UUCP> Date: Thu, 24-Jul-86 08:43:08 EDT Article-I.D.: cecil.73 Posted: Thu Jul 24 08:43:08 1986 Date-Received: Thu, 24-Jul-86 21:41:11 EDT Organization: NIH-CSL, Bethesda, MD Lines: 29