home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!cygnus.com!bothner
- From: bothner@cygnus.com
- Newsgroups: gnu.g++.lib.bug
- Subject: Re: 2.3: ostrstream and freeze
- Date: 26 Jan 1993 21:47:12 -0500
- Organization: GNUs Not Usenet
- Lines: 67
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-lib-g++@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <9301260718.AA07832@cygnus.com>
- References: <9301250337.AA08048@cs.rice.edu>
-
- > Unfreezing a previously frozen (with str) ostrstream, when that
- > ostrstream has a fixed, user-supplied buffer,
-
- Well, you can't unfreeze an ostrstream with a fixed user-supplied
- buffer. In this case the freeze(0) should be ignored.
- Patches to do so are appended below.
-
- --Per Bothner
- Cygnus Support bothner@cygnus.com
-
- ===================================================================
- RCS file: /rel/cvsfiles/devo/libg++/iostream/strstream.h,v
- retrieving revision 1.10
- diff -c -r1.10 strstream.h
- *** 1.10 1992/11/03 06:30:01
- --- strstream.h 1993/01/26 03:01:10
- ***************
- *** 33,38 ****
- --- 33,39 ----
- void init_const() { xsetflags(_S_NO_WRITES); }
- void init_static(char *ptr, int size, char *pstart);
- protected:
- + int is_static() const { return _allocate_buffer == (_alloc_type)0; }
- virtual int overflow(int = EOF);
- virtual int underflow();
- virtual int pbackfail(int c);
- ***************
- *** 56,64 ****
- strstreambuf(const signed char *ptr, int size)
- { init_static((char*)ptr, size, NULL); init_const(); }
- #endif
- int frozen() { return _flags & _S_USER_BUF ? 1 : 0; }
- void freeze(int n=1)
- ! { if (n) _flags |= _S_USER_BUF; else _flags &= ~_S_USER_BUF; }
- _G_size_t pcount();
- char *str();
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- --- 57,67 ----
- strstreambuf(const signed char *ptr, int size)
- { init_static((char*)ptr, size, NULL); init_const(); }
- #endif
- + // Note: frozen() is always true if is_static().
- int frozen() { return _flags & _S_USER_BUF ? 1 : 0; }
- void freeze(int n=1)
- ! { if (!is_static())
- ! { if (n) _flags |= _S_USER_BUF; else _flags &= ~_S_USER_BUF; } }
- _G_size_t pcount();
- char *str();
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- ===================================================================
- RCS file: /rel/cvsfiles/devo/libg++/iostream/strstream.C,v
- retrieving revision 1.15
- diff -c -r1.15 strstream.C
- *** 1.15 1992/10/17 00:26:47
- --- strstream.C 1993/01/26 02:59:57
- ***************
- *** 182,189 ****
- streampos strstreambuf::seekoff(streamoff off, _seek_dir dir,
- int mode /*=ios::in|ios::out*/)
- {
- - _allocate_buffer = default_alloc;
- - _free_buffer = default_free;
- size_t cur_size = pcount();
- streampos new_pos = EOF;
-
- --- 182,187 ----
-
-