This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project. See the libstdc++ home page for more information.
Here is your code with some changes. Please use diff -cp on the next submission, because it's easier for me (and equivalent to what egcs uses.) I don't have any problems compiling this code with this version of egcs: gcc version egcs-2.92.21 19981118 (gcc2 ss-980609 experimental) are you running into difficulty with some other version? -Benjamin Index: sstream.tcc =================================================================== RCS file: /cvs/cvsfiles/unsupported/isolib/bits/sstream.tcc,v retrieving revision 1.1 diff -c -p -r1.1 sstream.tcc *** sstream.tcc 1998/10/16 02:36:55 1.1 --- sstream.tcc 1998/12/02 22:27:22 *************** *** 1,4 **** --- 1,5 ---- // String based streams -*- C++ -*- + // sstream.tcc // Copyright (C) 1997,1998 Cygnus Solutions // *************** *** 19,24 **** --- 20,27 ---- namespace std { + #if 0 + //981201 bkoz orig template <class _CharT, class _Traits, class _Allocator> basic_stringbuf<_CharT,_Traits,_Allocator>::basic_stringbuf( const basic_string<_CharT,_Traits,_Allocator>& __str, *************** namespace std { *** 58,64 **** --- 61,176 ---- if (_M_mode & ios_base::in) this->setg (this->pbase (), this->pptr (), this->epptr ()); } + #endif + //981201 bkoz this is new + template <class _CharT, class _Traits, class _Allocator> + void + basic_stringbuf<_CharT,_Traits,_Allocator>:: + str (const basic_string<_CharT,_Traits,_Allocator>& __s) + { + _M_str = __s; + // position setting + _M_writeindex = _M_str.length(); + _M_readindex = 0; + } + + template <class _CharT, class _Traits, class _Allocator> + basic_stringbuf<_CharT,_Traits,_Allocator>::int_type + basic_stringbuf<_CharT,_Traits,_Allocator>:: + underflow () + { + if (_M_readindex>=_M_str.length()) + return _Traits::eof(); + return _Traits::to_int_type(_M_str[_M_readindex++]); + } + + template <class _CharT, class _Traits, class _Allocator> + basic_stringbuf<_CharT,_Traits,_Allocator>::int_type + basic_stringbuf<_CharT,_Traits,_Allocator>:: + overflow (int_type __c) + { + if (!_Traits::eq_int_type(__c,_Traits::eof())) + { + if (_M_writeindex>=_M_str.size()) + _M_str.resize(_M_writeindex+1); + _M_str[_M_writeindex++]=__c; + return __c; + } + else + return _Traits::not_eof(__c); + } + + template <class _CharT, class _Traits, class _Allocator> + streamsize + basic_stringbuf<_CharT,_Traits,_Allocator>:: + xsputn (const char_type* __s, streamsize __n) + { + if (_M_writeindex + __n > _M_str.size()) + _M_str.resize(_M_writeindex + __n); + copy(__s, __s + __n, _M_str.begin() + _M_writeindex); + _M_writeindex += __n; + return __n; + } + + template <class _CharT, class _Traits, class _Allocator> + streamsize + basic_stringbuf<_CharT,_Traits,_Allocator>:: + xsgetn (char_type* __s, streamsize __n) + { + if (_M_readindex + __n > _M_str.length()) + __n = _M_str.length() - _M_readindex; + copy(_M_str.begin() + _M_readindex, + _M_str.begin() + (_M_readindex + __n), + __s); + _M_readindex += __n; + return __n; + } + + template <class _CharT, class _Traits, class _Allocator> + int + basic_stringbuf<_CharT,_Traits,_Allocator>::showmanyc() + { + return _M_str.length() - _M_readindex; + } + + template <class _CharT, class _Traits, class _Allocator> + basic_stringbuf<_CharT,_Traits,_Allocator>::pos_type + basic_stringbuf<_CharT,_Traits,_Allocator>:: + seekoff(off_type __off, ios_base::seekdir __way, + ios_base::openmode __which) + { + pos_type __retval = -1; + + if (__which & ios_base::in) + { + switch (__way) + { + case ios_base::beg: + __retval = _M_readindex = __off; + case ios_base::cur: + __retval = _M_readindex += __off; + case ios_base::end: + __retval = _M_readindex = _M_str.size() + __off; + } + } + + if (__which & ios_base::out) + { + switch (__way) + { + case ios_base::beg: + __retval = _M_writeindex = __off; + case ios_base::cur: + __retval = _M_writeindex += __off; + case ios_base::end: + __retval = _M_writeindex = _M_str.size() + __off; + } + } + return __retval; // don't know whether this is right + } + + } // namespace std #endif /* _CPP_SSTREAM_TCC */