[v3] remove instantiations, backwards tweaks

Benjamin Kosnik bkoz@redhat.com
Mon Jul 1 12:58:00 GMT 2002


Ouch. The previous post hadn't finished testing.... this one has. It
explicitly adds the strstream bits to the so versioning scheme, and
removes the 'using namespace std' in strestream.h.... which was
colossally stupid.

tested x86/linux

-benjamin

2002-07-01  Benjamin Kosnik  <bkoz@redhat.com>

	* include/backward/strstream: Remove namespace std. Transfer to...
	* include/backward/strstream.h: ...here. Qualify std names.
	* src/strstream.cc: Remove namespace std.
	* include/Makefile.am (backward_headers): Remove strstream.h.
	* include/Makefile.in: Regenerate.
	* config/linker-map.gnu: Export strstream bits.
	
	* src/fstream-inst.cc: Tweak.
	* src/io-inst.cc: Same.
	* src/istream-inst.cc: Same.
	* src/misc-inst.cc: Same.
	* src/ostream-inst.cc: Same.
	* src/sstream-inst.cc: Same.
	* src/valarray-inst.cc: Same.
	* src/misc-inst.cc: Remove unused instantiations.
  	
Index: config/linker-map.gnu
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/linker-map.gnu,v
retrieving revision 1.13
diff -c -p -r1.13 linker-map.gnu
*** config/linker-map.gnu	17 Apr 2002 20:08:17 -0000	1.13
--- config/linker-map.gnu	1 Jul 2002 19:53:25 -0000
*************** GLIBCPP_3.1 {
*** 38,44 ****
        std::_S_bit_count;
        std::_S_first_one;
        std::__default_alloc_template*;
!       std::__malloc_alloc_template*
      };
  
      # Names not in an 'extern' block are mangled names.
--- 38,48 ----
        std::_S_bit_count;
        std::_S_first_one;
        std::__default_alloc_template*;
!       std::__malloc_alloc_template*;
!       strstreambuf::*;
!       istrstream::*;
!       ostrstream::*;
!       strstream::*
      };
  
      # Names not in an 'extern' block are mangled names.
Index: include/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/Makefile.am,v
retrieving revision 1.38
diff -c -p -r1.38 Makefile.am
*** include/Makefile.am	20 Jun 2002 19:08:12 -0000	1.38
--- include/Makefile.am	1 Jul 2002 19:53:29 -0000
*************** backward_headers = \
*** 139,145 ****
  	${backward_srcdir}/vector.h \
  	${backward_srcdir}/fstream.h \
  	${backward_srcdir}/strstream.h \
- 	${backward_srcdir}/strstream \
  	${backward_srcdir}/backward_warning.h
  
  ext_srcdir = ${glibcpp_srcdir}/include/ext
--- 139,144 ----
Index: include/backward/strstream.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/backward/strstream.h,v
retrieving revision 1.6
diff -c -p -r1.6 strstream.h
*** include/backward/strstream.h	31 Mar 2001 20:15:42 -0000	1.6
--- include/backward/strstream.h	1 Jul 2002 19:53:31 -0000
***************
*** 1,22 ****
! // -*- C++ -*- forwarding header.
! // Copyright (C) 2000 Free Software Foundation
  
! // This file is part of GNU CC.
  //
! // GNU CC is free software; you can redistribute it and/or modify
! // it under the terms of the GNU General Public License as published by
! // the Free Software Foundation; either version 2, or (at your option)
  // any later version.
! // 
! // GNU CC is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  // GNU General Public License for more details.
! // 
! // You should have received a copy of the GNU General Public License
! // along with GNU CC; see the file COPYING.  If not, write to
! // the Free Software Foundation, 59 Temple Place - Suite 330,
! // Boston, MA 02111-1307, USA.
  
  // As a special exception, you may use this file as part of a free software
  // library without restriction.  Specifically, if other files instantiate
--- 1,22 ----
! // Backward-compat support -*- C++ -*-
  
! // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  //
! // This file is part of the GNU ISO C++ Library.  This library is free
! // software; you can redistribute it and/or modify it under the
! // terms of the GNU General Public License as published by the
! // Free Software Foundation; either version 2, or (at your option)
  // any later version.
! 
! // This library is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  // GNU General Public License for more details.
! 
! // You should have received a copy of the GNU General Public License along
! // with this library; see the file COPYING.  If not, write to the Free
! // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
! // USA.
  
  // As a special exception, you may use this file as part of a free software
  // library without restriction.  Specifically, if other files instantiate
***************
*** 27,41 ****
  // invalidate any other reasons why the executable file might be covered by
  // the GNU General Public License.
  
  #ifndef _CPP_BACKWARD_STRSTREAM_H
  #define _CPP_BACKWARD_STRSTREAM_H 1
  
! #include "strstream"
! 
! using std::strstreambuf;
! using std::istrstream;
! using std::ostrstream;
! using std::strstream;
! 
  #endif 
- 
--- 27,174 ----
  // invalidate any other reasons why the executable file might be covered by
  // the GNU General Public License.
  
+ /*
+  * Copyright (c) 1998
+  * Silicon Graphics Computer Systems, Inc.
+  *
+  * Permission to use, copy, modify, distribute and sell this software
+  * and its documentation for any purpose is hereby granted without fee,
+  * provided that the above copyright notice appear in all copies and
+  * that both that copyright notice and this permission notice appear
+  * in supporting documentation.  Silicon Graphics makes no
+  * representations about the suitability of this software for any
+  * purpose.  It is provided "as is" without express or implied warranty.
+  */
+ 
+ // WARNING: The classes defined in this header are DEPRECATED.  This
+ // header is defined in section D.7.1 of the C++ standard, and it
+ // MAY BE REMOVED in a future standard revision.  You should use the
+ // header <sstream> instead.
+ 
  #ifndef _CPP_BACKWARD_STRSTREAM_H
  #define _CPP_BACKWARD_STRSTREAM_H 1
  
! #include "backward_warning.h"
! #include <iosfwd>
! #include <ios>
! #include <istream>
! #include <ostream>
! #include <string>
! 
! // Class strstreambuf, a streambuf class that manages an array of char.
! // Note that this class is not a template.
! class strstreambuf : public std::basic_streambuf<char>
! {
! public:                         
!   // Types.
!   typedef std::char_traits<char>              _Traits;
!   typedef std::basic_streambuf<char, _Traits> _Base;
! 
! public:  
!   // Constructor, destructor
!   explicit strstreambuf(std::streamsize __initial_capacity = 0);
!   strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*));
! 
!   strstreambuf(char* __get, std::streamsize __n, char* __put = 0);
!   strstreambuf(signed char* __get, std::streamsize __n, 
! 	       signed char* __put = 0);
!   strstreambuf(unsigned char* __get, std::streamsize __n, 
! 	       unsigned char* __put=0);
!   
!   strstreambuf(const char* __get, std::streamsize __n);
!   strstreambuf(const signed char* __get, std::streamsize __n);
!   strstreambuf(const unsigned char* __get, std::streamsize __n);
!   
!   virtual ~strstreambuf();
! 
! public:
!   void freeze(bool = true);
!   char* str();
!   int pcount() const;
! 
! protected:
!   virtual int_type overflow(int_type __c  = _Traits::eof());
!   virtual int_type pbackfail(int_type __c = _Traits::eof());
!   virtual int_type underflow();
!   virtual _Base* setbuf(char* __buf, std::streamsize __n);
!   virtual pos_type seekoff(off_type __off, std::ios_base::seekdir __dir,
! 			   std::ios_base::openmode __mode
! 			   = std::ios_base::in | std::ios_base::out);
!   virtual pos_type seekpos(pos_type __pos, std::ios_base::openmode __mode
! 			   = std::ios_base::in | std::ios_base::out);
!   
! private:  
!   // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun.
!   char* _M_alloc(size_t);
!   void  _M_free(char*);
!   
!   // Helper function used in constructors.
!   void _M_setup(char* __get, char* __put, std::streamsize __n);
!   
! private:  
!   // Data members.
!   void* (*_M_alloc_fun)(size_t);
!   void  (*_M_free_fun)(void*);
!   
!   bool _M_dynamic  : 1;
!   bool _M_frozen   : 1;
!   bool _M_constant : 1;
! };
! 
! // Class istrstream, an istream that manages a strstreambuf.
! class istrstream : public std::basic_istream<char>
! {
! public:
!   explicit istrstream(char*);
!   explicit istrstream(const char*);
!   istrstream(char* , std::streamsize);
!   istrstream(const char*, std::streamsize);
!   virtual ~istrstream();
!   
!   strstreambuf* rdbuf() const;
!   char* str();
!   
! private:
!   strstreambuf _M_buf;
! };
! 
! // Class ostrstream
! class ostrstream : public std::basic_ostream<char>
! {
! public:
!   ostrstream();
!   ostrstream(char*, int, std::ios_base::openmode = std::ios_base::out);
!   virtual ~ostrstream();
!   
!   strstreambuf* rdbuf() const;
!   void freeze(bool = true);
!   char* str();
!   int pcount() const;
!   
! private:
!   strstreambuf _M_buf;
! };
! 
! // Class strstream
! class strstream : public std::basic_iostream<char>
! {
! public:
!   typedef char                        char_type;
!   typedef std::char_traits<char>::int_type int_type;
!   typedef std::char_traits<char>::pos_type pos_type;
!   typedef std::char_traits<char>::off_type off_type;
!   
!   strstream();
!   strstream(char*, int, 
! 	    std::ios_base::openmode = std::ios_base::in | std::ios_base::out);
!   virtual ~strstream();
!   
!   strstreambuf* rdbuf() const;
!   void freeze(bool = true);
!   int pcount() const;
!   char* str();
!   
! private:
!   strstreambuf _M_buf;
! };
  #endif 
Index: src/fstream-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/fstream-inst.cc,v
retrieving revision 1.1
diff -c -p -r1.1 fstream-inst.cc
*** src/fstream-inst.cc	27 May 2002 14:55:52 -0000	1.1
--- src/fstream-inst.cc	1 Jul 2002 19:53:31 -0000
*************** namespace std
*** 59,62 ****
  #ifdef _GLIBCPP_USE_WCHAR_T
    template class basic_fstream<wchar_t>;
  #endif
! } //std
--- 59,62 ----
  #ifdef _GLIBCPP_USE_WCHAR_T
    template class basic_fstream<wchar_t>;
  #endif
! } // namespace std
Index: src/io-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/io-inst.cc,v
retrieving revision 1.1
diff -c -p -r1.1 io-inst.cc
*** src/io-inst.cc	27 May 2002 14:55:52 -0000	1.1
--- src/io-inst.cc	1 Jul 2002 19:53:31 -0000
*************** namespace std
*** 57,60 ****
  #ifdef _GLIBCPP_USE_WCHAR_T
    template class basic_iostream<wchar_t>; 
  #endif
! } //std
--- 57,60 ----
  #ifdef _GLIBCPP_USE_WCHAR_T
    template class basic_iostream<wchar_t>; 
  #endif
! } // namespace std
Index: src/istream-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/istream-inst.cc,v
retrieving revision 1.1
diff -c -p -r1.1 istream-inst.cc
*** src/istream-inst.cc	27 May 2002 14:55:53 -0000	1.1
--- src/istream-inst.cc	1 Jul 2002 19:53:31 -0000
*************** namespace std
*** 67,70 ****
    template wistream& operator>>(wistream&, _Setprecision);
    template wistream& operator>>(wistream&, _Setw);
  #endif
! } //std
--- 67,70 ----
    template wistream& operator>>(wistream&, _Setprecision);
    template wistream& operator>>(wistream&, _Setw);
  #endif
! } // namespace std
Index: src/misc-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/misc-inst.cc,v
retrieving revision 1.17
diff -c -p -r1.17 misc-inst.cc
*** src/misc-inst.cc	27 May 2002 14:55:53 -0000	1.17
--- src/misc-inst.cc	1 Jul 2002 19:53:31 -0000
*************** namespace std
*** 67,102 ****
      basic_istream<wchar_t>& 
      getline(basic_istream<wchar_t>&, wstring&);
  #endif
! 
! #if 1
!   // XXX
!   // 2002-05-24 These are no longer needed and should be deleted.
! 
!   // algorithm
!   typedef  _Char_traits_match<char, char_traits<char> > char_match;
! 
!   template 
!     const char*  
!     find_if<const char *, char_match>
!     (const char *, const char *, char_match, random_access_iterator_tag);
! 
! #ifdef _GLIBCPP_USE_WCHAR_T
!   typedef  _Char_traits_match<wchar_t, char_traits<wchar_t> > wchar_match;
! 
!   template const wchar_t*  
!     find_if<const wchar_t*, wchar_match>
!     (const wchar_t*, const wchar_t*, wchar_match, random_access_iterator_tag);
! #endif
!   
!   template 
!     string* 
!     __uninitialized_fill_n_aux<string*, size_t, string>
!     (string*, size_t, string const &, __false_type);
! 
!   template 
!     string* 
!     __uninitialized_copy_aux<vector<string>::const_iterator, string *>
!     (vector<string>::const_iterator, vector<string>::const_iterator, 
!      string*, __false_type);
! #endif
! } //std
--- 67,70 ----
      basic_istream<wchar_t>& 
      getline(basic_istream<wchar_t>&, wstring&);
  #endif
! } // namespace std
Index: src/ostream-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/ostream-inst.cc,v
retrieving revision 1.1
diff -c -p -r1.1 ostream-inst.cc
*** src/ostream-inst.cc	27 May 2002 14:55:53 -0000	1.1
--- src/ostream-inst.cc	1 Jul 2002 19:53:31 -0000
*************** namespace std
*** 73,76 ****
    template wostream& operator<<(wostream&, _Setprecision);
    template wostream& operator<<(wostream&, _Setw);
  #endif
! } //std
--- 73,76 ----
    template wostream& operator<<(wostream&, _Setprecision);
    template wostream& operator<<(wostream&, _Setw);
  #endif
! } // namespace std
Index: src/sstream-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/sstream-inst.cc,v
retrieving revision 1.1
diff -c -p -r1.1 sstream-inst.cc
*** src/sstream-inst.cc	27 May 2002 14:55:53 -0000	1.1
--- src/sstream-inst.cc	1 Jul 2002 19:53:31 -0000
*************** namespace std
*** 59,62 ****
  #ifdef _GLIBCPP_USE_WCHAR_T
    template class basic_stringstream<wchar_t>; 
  #endif
! } //std
--- 59,62 ----
  #ifdef _GLIBCPP_USE_WCHAR_T
    template class basic_stringstream<wchar_t>; 
  #endif
! } // namespace std
Index: src/strstream.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/strstream.cc,v
retrieving revision 1.10
diff -c -p -r1.10 strstream.cc
*** src/strstream.cc	8 Jun 2002 15:14:56 -0000	1.10
--- src/strstream.cc	1 Jul 2002 19:53:32 -0000
***************
*** 54,202 ****
  #include <string.h>
  #include <limits.h>
  
! namespace std
  {
!   strstreambuf::strstreambuf(streamsize initial_capacity)
!   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true), 
!     _M_frozen(false), _M_constant(false)
!   {
!     _M_buf_size = _M_buf_size_opt = max(initial_capacity, streamsize(16));
!     _M_buf = _M_alloc(_M_buf_size);
!     if (_M_buf) 
!       {
! 	setp(_M_buf, _M_buf + _M_buf_size);
! 	setg(_M_buf, _M_buf, _M_buf);
!       }
!   }
! 
!   strstreambuf::strstreambuf(void* (*alloc_f)(size_t), void (*free_f)(void*))
!   : _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true), 
!     _M_frozen(false), _M_constant(false)
!   {
!     _M_buf_size = _M_buf_size_opt = 16;
!     _M_buf = _M_alloc(_M_buf_size);
!     if (_M_buf) 
!       {
! 	setp(_M_buf, _M_buf + _M_buf_size);
! 	setg(_M_buf, _M_buf, _M_buf);
!       }
!   }
! 
!   strstreambuf::strstreambuf(char* get, streamsize n, char* put)
!   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!     _M_frozen(false), _M_constant(false)
!   { _M_setup(get, put, n); }
  
!   strstreambuf::strstreambuf(signed char* get, streamsize n, signed char* put)
!   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
    _M_frozen(false), _M_constant(false)
!   { _M_setup(reinterpret_cast<char*>(get), reinterpret_cast<char*>(put), n); }
  
!   strstreambuf::strstreambuf(unsigned char* get, streamsize n, 
! 			     unsigned char* put)
!   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!     _M_frozen(false), _M_constant(false)
!   { _M_setup(reinterpret_cast<char*>(get), reinterpret_cast<char*>(put), n); }
! 
!   strstreambuf::strstreambuf(const char* get, streamsize n)
!   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!     _M_frozen(false), _M_constant(true)
!   { _M_setup(const_cast<char*>(get), 0, n); }
! 
!   strstreambuf::strstreambuf(const signed char* get, streamsize n)
!   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!     _M_frozen(false), _M_constant(true)
!   { _M_setup(reinterpret_cast<char*>(const_cast<signed char*>(get)), 0, n); }
! 
!   strstreambuf::strstreambuf(const unsigned char* get, streamsize n)
!   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!     _M_frozen(false), _M_constant(true)
!   { _M_setup(reinterpret_cast<char*>(const_cast<unsigned char*>(get)), 0, n); }
! 
!   strstreambuf::~strstreambuf()
!   {
!     if (_M_dynamic && !_M_frozen)
!       {
! 	char* p = this->eback();
! 	_M_free(p);
! 	if (p == _M_buf)
! 	  _M_buf = 0;
!       }
!     if (_M_buf)
!       _M_free(_M_buf);
!   }
! 
!   void 
!   strstreambuf::freeze(bool frozenflag)
!   {
!     if (_M_dynamic)
!       _M_frozen = frozenflag;
!   }
! 
!   char* 
!   strstreambuf::str()
!   {
!     freeze(true);
!     return eback();
!   }
! 
!   int 
!   strstreambuf::pcount() const
!   { return pptr() ? pptr() - pbase() : 0; }
! 
!   strstreambuf::int_type 
!   strstreambuf::overflow(int_type c) 
!   {
!     if (c == traits_type::eof())
!       return traits_type::not_eof(c);
      
!     // Try to expand the buffer.
!     if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant) 
!       {
! 	ptrdiff_t old_size = epptr() - pbase();
! 	ptrdiff_t new_size = max(2 * old_size, ptrdiff_t(1));
  	
! 	char* buf = _M_alloc(new_size);
! 	if (buf) 
! 	  {
! 	    memcpy(buf, pbase(), old_size);
! 	    char* old_buffer = pbase();
! 	    bool reposition_get = false;
! 	    ptrdiff_t old_get_offset;
! 	    if (gptr() != 0) 
! 	      {
! 		reposition_get = true;
! 		old_get_offset = gptr() - eback();
! 	      }
  	    
! 	    _M_buf = buf;
! 	    _M_buf_size = _M_buf_size_opt = new_size;
! 	    setp(buf, buf + new_size);
! 	    pbump(old_size);
! 
! 	    if (reposition_get)
! 	      setg(buf, buf + old_get_offset, buf + 
! 		   max(old_get_offset, old_size));
! 
! 	    _M_free(old_buffer);
! 	  }
!       }
      
!     if (pptr() != epptr()) 
!       {
! 	*pptr() = c;
! 	pbump(1);
! 	return c;
!       }
!     else
!       return traits_type::eof();
!   }
  
!   strstreambuf::int_type 
!   strstreambuf::pbackfail(int_type c)
!   {
!     if (gptr() != eback()) 
!       {
        if (c == _Traits::eof()) 
  	{
  	  gbump(-1);
--- 54,202 ----
  #include <string.h>
  #include <limits.h>
  
! using namespace std;
! 
! strstreambuf::strstreambuf(streamsize initial_capacity)
! : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true), 
!   _M_frozen(false), _M_constant(false)
! {
!   _M_buf_size = _M_buf_size_opt = max(initial_capacity, streamsize(16));
!   _M_buf = _M_alloc(_M_buf_size);
!   if (_M_buf) 
!     {
!       setp(_M_buf, _M_buf + _M_buf_size);
!       setg(_M_buf, _M_buf, _M_buf);
!     }
! }
! 
! strstreambuf::strstreambuf(void* (*alloc_f)(size_t), void (*free_f)(void*))
! : _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true), 
!   _M_frozen(false), _M_constant(false)
  {
!   _M_buf_size = _M_buf_size_opt = 16;
!   _M_buf = _M_alloc(_M_buf_size);
!   if (_M_buf) 
!     {
!       setp(_M_buf, _M_buf + _M_buf_size);
!       setg(_M_buf, _M_buf, _M_buf);
!     }
! }
  
! strstreambuf::strstreambuf(char* get, streamsize n, char* put)
! : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
    _M_frozen(false), _M_constant(false)
! { _M_setup(get, put, n); }
! 
! strstreambuf::strstreambuf(signed char* get, streamsize n, signed char* put)
! : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!   _M_frozen(false), _M_constant(false)
! { _M_setup(reinterpret_cast<char*>(get), reinterpret_cast<char*>(put), n); }
! 
! strstreambuf::strstreambuf(unsigned char* get, streamsize n, 
! 			   unsigned char* put)
! : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!   _M_frozen(false), _M_constant(false)
! { _M_setup(reinterpret_cast<char*>(get), reinterpret_cast<char*>(put), n); }
! 
! strstreambuf::strstreambuf(const char* get, streamsize n)
! : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!   _M_frozen(false), _M_constant(true)
! { _M_setup(const_cast<char*>(get), 0, n); }
! 
! strstreambuf::strstreambuf(const signed char* get, streamsize n)
! : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!   _M_frozen(false), _M_constant(true)
! { _M_setup(reinterpret_cast<char*>(const_cast<signed char*>(get)), 0, n); }
! 
! strstreambuf::strstreambuf(const unsigned char* get, streamsize n)
! : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), 
!   _M_frozen(false), _M_constant(true)
! { _M_setup(reinterpret_cast<char*>(const_cast<unsigned char*>(get)), 0, n); }
! 
! strstreambuf::~strstreambuf()
! {
!   if (_M_dynamic && !_M_frozen)
!     {
!       char* p = this->eback();
!       _M_free(p);
!       if (p == _M_buf)
! 	_M_buf = 0;
!     }
!   if (_M_buf)
!     _M_free(_M_buf);
! }
! 
! void 
! strstreambuf::freeze(bool frozenflag)
! {
!   if (_M_dynamic)
!     _M_frozen = frozenflag;
! }
! 
! char* 
! strstreambuf::str()
! {
!   freeze(true);
!   return eback();
! }
! 
! int 
! strstreambuf::pcount() const
! { return pptr() ? pptr() - pbase() : 0; }
  
! strstreambuf::int_type 
! strstreambuf::overflow(int_type c) 
! {
!   if (c == traits_type::eof())
!     return traits_type::not_eof(c);
      
!   // Try to expand the buffer.
!   if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant) 
!     {
!       ptrdiff_t old_size = epptr() - pbase();
!       ptrdiff_t new_size = max(2 * old_size, ptrdiff_t(1));
  	
!       char* buf = _M_alloc(new_size);
!       if (buf) 
! 	{
! 	  memcpy(buf, pbase(), old_size);
! 	  char* old_buffer = pbase();
! 	  bool reposition_get = false;
! 	  ptrdiff_t old_get_offset;
! 	  if (gptr() != 0) 
! 	    {
! 	      reposition_get = true;
! 	      old_get_offset = gptr() - eback();
! 	    }
  	    
! 	  _M_buf = buf;
! 	  _M_buf_size = _M_buf_size_opt = new_size;
! 	  setp(buf, buf + new_size);
! 	  pbump(old_size);
! 
! 	  if (reposition_get)
! 	    setg(buf, buf + old_get_offset, buf + 
! 		 max(old_get_offset, old_size));
! 
! 	  _M_free(old_buffer);
! 	}
!     }
      
!   if (pptr() != epptr()) 
!     {
!       *pptr() = c;
!       pbump(1);
!       return c;
!     }
!   else
!     return traits_type::eof();
! }
  
! strstreambuf::int_type 
! strstreambuf::pbackfail(int_type c)
! {
!   if (gptr() != eback()) 
!     {
        if (c == _Traits::eof()) 
  	{
  	  gbump(-1);
*************** namespace std
*** 214,424 ****
  	  return c;
  	}
      }
!     return _Traits::eof();
!   }
  
!   strstreambuf::int_type 
!   strstreambuf::underflow()
!   {
!     if (gptr() == egptr() && pptr() && pptr() > egptr())
!       setg(eback(), gptr(), pptr());
      
!     if (gptr() != egptr())
!       return (unsigned char) *gptr();
!     else
!       return _Traits::eof();
!   }
  
!   basic_streambuf<char, char_traits<char> >*
!   strstreambuf::setbuf(char*, streamsize)
!   { return this; }
! 
!   strstreambuf::pos_type
!   strstreambuf::seekoff(off_type off, ios_base::seekdir dir, 
! 			ios_base::openmode mode)
!   {
!     bool do_get = false;
!     bool do_put = false;
! 
!     if ((mode & (ios_base::in | ios_base::out)) 
! 	== (ios_base::in | ios_base::out) &&
! 	(dir == ios_base::beg || dir == ios_base::end))
!       do_get = do_put = true;
!     else if (mode & ios_base::in)
!       do_get = true;
!     else if (mode & ios_base::out)
!       do_put = true;
! 
!     // !gptr() is here because, according to D.7.1 paragraph 4, the seekable
!     // area is undefined if there is no get area.
!     if ((!do_get && !do_put) || (do_put && !pptr()) || !gptr())
        return pos_type(off_type(-1));
  
!     char* seeklow  = eback();
!     char* seekhigh = epptr() ? epptr() : egptr();
  
!     off_type newoff;
!     switch (dir) 
!       {
!       case ios_base::beg:
! 	newoff = 0;
! 	break;
!       case ios_base::end:
! 	newoff = seekhigh - seeklow;
! 	break;
!       case ios_base::cur:
! 	newoff = do_put ? pptr() - seeklow : gptr() - seeklow;
! 	break;
!       default:
! 	return pos_type(off_type(-1));
!       }
!     
!     off += newoff;
!     if (off < 0 || off > seekhigh - seeklow)
!       return pos_type(off_type(-1));
  
!     if (do_put) 
!       {
! 	if (seeklow + off < pbase()) 
! 	  {
! 	    setp(seeklow, epptr());
! 	    pbump(off);
! 	  }
! 	else 
! 	  {
! 	    setp(pbase(), epptr());
! 	    pbump(off - (pbase() - seeklow));
! 	  }
!       }
!     if (do_get) 
!       {
! 	if (off <= egptr() - seeklow)
! 	  setg(seeklow, seeklow + off, egptr());
! 	else if (off <= pptr() - seeklow)
! 	  setg(seeklow, seeklow + off, pptr());
! 	else
! 	  setg(seeklow, seeklow + off, epptr());
!       }
!     return pos_type(newoff);
!   }
! 
!   strstreambuf::pos_type
!   strstreambuf::seekpos(pos_type pos, ios_base::openmode mode)
!   { return seekoff(pos - pos_type(off_type(0)), ios_base::beg, mode); }
! 
!   char* 
!   strstreambuf::_M_alloc(size_t n)
!   {
!     if (_M_alloc_fun)
!       return static_cast<char*>(_M_alloc_fun(n));
      else
!       return new char[n];
!   }
  
!   void 
!   strstreambuf::_M_free(char* p)
!   {
!     if (p)
!       if (_M_free_fun)
! 	_M_free_fun(p);
!       else
! 	delete[] p;
!   }
! 
!   void 
!   strstreambuf::_M_setup(char* get, char* put, streamsize n)
!   {
!     if (get) 
!       {
! 	size_t N = n > 0 ? size_t(n) : n == 0 ? strlen(get) : size_t(INT_MAX);
  	
! 	if (put) 
! 	  {
! 	    setg(get, get, put);
! 	    setp(put, put + N);
! 	  }
! 	else 
! 	  setg(get, get, get + N);
!       }
!   }
! 
!   istrstream::istrstream(char* s)
!   : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0)
!   { basic_ios<char>::init(&_M_buf); }
! 
!   istrstream::istrstream(const char* s)
!   : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0)
!   { basic_ios<char>::init(&_M_buf); }
! 
!   istrstream::istrstream(char* s, streamsize n)
!   : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n)
!   { basic_ios<char>::init(&_M_buf); }
! 
!   istrstream::istrstream(const char* s, streamsize n)
!   : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n)
!   { basic_ios<char>::init(&_M_buf); }
! 
!   istrstream::~istrstream() { }
! 
!   strstreambuf* 
!   istrstream::rdbuf() const 
!   { return const_cast<strstreambuf*>(&_M_buf); }
! 
!   char* 
!   istrstream::str() 
!   { return _M_buf.str(); }
! 
!   ostrstream::ostrstream()
!   : basic_ios<char>(), basic_ostream<char>(0), _M_buf()
!   { basic_ios<char>::init(&_M_buf); }
! 
!   ostrstream::ostrstream(char* s, int n, ios_base::openmode mode)
!   : basic_ios<char>(), basic_ostream<char>(0), 
!     _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s)
!   { basic_ios<char>::init(&_M_buf); }
! 
!   ostrstream::~ostrstream() {}
! 
!   strstreambuf* 
!   ostrstream::rdbuf() const
!   { return const_cast<strstreambuf*>(&_M_buf); }
! 
!   void 
!   ostrstream::freeze(bool freezeflag)
!   { _M_buf.freeze(freezeflag); }
! 
!   char* 
!   ostrstream::str()
!   { return _M_buf.str(); }
! 
!   int 
!   ostrstream::pcount() const
!   { return _M_buf.pcount(); }
! 
!   strstream::strstream()
!   : basic_ios<char>(), basic_iostream<char>(0), _M_buf()
!   { basic_ios<char>::init(&_M_buf); }
! 
!   strstream::strstream(char* s, int n, ios_base::openmode mode)
!   : basic_ios<char>(), basic_iostream<char>(0), 
!     _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s)
!   { basic_ios<char>::init(&_M_buf); }
! 
!   strstream::~strstream() { }
! 
!   strstreambuf* 
!   strstream::rdbuf() const
!   { return const_cast<strstreambuf*>(&_M_buf); }
! 
!   void 
!   strstream::freeze(bool freezeflag)
!   { _M_buf.freeze(freezeflag); }
! 
!   int 
!   strstream::pcount() const
!   { return _M_buf.pcount(); }
! 
!   char* 
!   strstream::str()
!   { return _M_buf.str(); }
! } // namespace std
--- 214,421 ----
  	  return c;
  	}
      }
!   return _Traits::eof();
! }
  
! strstreambuf::int_type 
! strstreambuf::underflow()
! {
!   if (gptr() == egptr() && pptr() && pptr() > egptr())
!     setg(eback(), gptr(), pptr());
      
!   if (gptr() != egptr())
!     return (unsigned char) *gptr();
!   else
!     return _Traits::eof();
! }
! 
! basic_streambuf<char, char_traits<char> >*
! strstreambuf::setbuf(char*, streamsize)
! { return this; }
! 
! strstreambuf::pos_type
! strstreambuf::seekoff(off_type off, ios_base::seekdir dir, 
! 		      ios_base::openmode mode)
! {
!   bool do_get = false;
!   bool do_put = false;
  
!   if ((mode & (ios_base::in | ios_base::out)) 
!       == (ios_base::in | ios_base::out) &&
!       (dir == ios_base::beg || dir == ios_base::end))
!     do_get = do_put = true;
!   else if (mode & ios_base::in)
!     do_get = true;
!   else if (mode & ios_base::out)
!     do_put = true;
! 
!   // !gptr() is here because, according to D.7.1 paragraph 4, the seekable
!   // area is undefined if there is no get area.
!   if ((!do_get && !do_put) || (do_put && !pptr()) || !gptr())
!     return pos_type(off_type(-1));
! 
!   char* seeklow  = eback();
!   char* seekhigh = epptr() ? epptr() : egptr();
! 
!   off_type newoff;
!   switch (dir) 
!     {
!     case ios_base::beg:
!       newoff = 0;
!       break;
!     case ios_base::end:
!       newoff = seekhigh - seeklow;
!       break;
!     case ios_base::cur:
!       newoff = do_put ? pptr() - seeklow : gptr() - seeklow;
!       break;
!     default:
        return pos_type(off_type(-1));
+     }
+     
+   off += newoff;
+   if (off < 0 || off > seekhigh - seeklow)
+     return pos_type(off_type(-1));
+ 
+   if (do_put) 
+     {
+       if (seeklow + off < pbase()) 
+ 	{
+ 	  setp(seeklow, epptr());
+ 	  pbump(off);
+ 	}
+       else 
+ 	{
+ 	  setp(pbase(), epptr());
+ 	  pbump(off - (pbase() - seeklow));
+ 	}
+     }
+   if (do_get) 
+     {
+       if (off <= egptr() - seeklow)
+ 	setg(seeklow, seeklow + off, egptr());
+       else if (off <= pptr() - seeklow)
+ 	setg(seeklow, seeklow + off, pptr());
+       else
+ 	setg(seeklow, seeklow + off, epptr());
+     }
+   return pos_type(newoff);
+ }
  
! strstreambuf::pos_type
! strstreambuf::seekpos(pos_type pos, ios_base::openmode mode)
! { return seekoff(pos - pos_type(off_type(0)), ios_base::beg, mode); }
  
! char* 
! strstreambuf::_M_alloc(size_t n)
! {
!   if (_M_alloc_fun)
!     return static_cast<char*>(_M_alloc_fun(n));
!   else
!     return new char[n];
! }
  
! void 
! strstreambuf::_M_free(char* p)
! {
!   if (p)
!     if (_M_free_fun)
!       _M_free_fun(p);
      else
!       delete[] p;
! }
  
! void 
! strstreambuf::_M_setup(char* get, char* put, streamsize n)
! {
!   if (get) 
!     {
!       size_t N = n > 0 ? size_t(n) : n == 0 ? strlen(get) : size_t(INT_MAX);
  	
!       if (put) 
! 	{
! 	  setg(get, get, put);
! 	  setp(put, put + N);
! 	}
!       else 
! 	setg(get, get, get + N);
!     }
! }
! 
! istrstream::istrstream(char* s)
! : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0)
! { basic_ios<char>::init(&_M_buf); }
! 
! istrstream::istrstream(const char* s)
! : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0)
! { basic_ios<char>::init(&_M_buf); }
! 
! istrstream::istrstream(char* s, streamsize n)
! : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n)
! { basic_ios<char>::init(&_M_buf); }
! 
! istrstream::istrstream(const char* s, streamsize n)
! : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n)
! { basic_ios<char>::init(&_M_buf); }
! 
! istrstream::~istrstream() { }
! 
! strstreambuf* 
! istrstream::rdbuf() const 
! { return const_cast<strstreambuf*>(&_M_buf); }
! 
! char* 
! istrstream::str() 
! { return _M_buf.str(); }
! 
! ostrstream::ostrstream() : basic_ios<char>(), basic_ostream<char>(0), _M_buf()
! { basic_ios<char>::init(&_M_buf); }
! 
! ostrstream::ostrstream(char* s, int n, ios_base::openmode mode)
! : basic_ios<char>(), basic_ostream<char>(0), 
!   _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s)
! { basic_ios<char>::init(&_M_buf); }
! 
! ostrstream::~ostrstream() {}
! 
! strstreambuf* 
! ostrstream::rdbuf() const
! { return const_cast<strstreambuf*>(&_M_buf); }
! 
! void 
! ostrstream::freeze(bool freezeflag)
! { _M_buf.freeze(freezeflag); }
! 
! char* 
! ostrstream::str()
! { return _M_buf.str(); }
! 
! int 
! ostrstream::pcount() const
! { return _M_buf.pcount(); }
! 
! strstream::strstream() : basic_ios<char>(), basic_iostream<char>(0), _M_buf()
! { basic_ios<char>::init(&_M_buf); }
! 
! strstream::strstream(char* s, int n, ios_base::openmode mode)
! : basic_ios<char>(), basic_iostream<char>(0), 
!   _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s)
! { basic_ios<char>::init(&_M_buf); }
! 
! strstream::~strstream() { }
! 
! strstreambuf* 
! strstream::rdbuf() const
! { return const_cast<strstreambuf*>(&_M_buf); }
! 
! void 
! strstream::freeze(bool freezeflag)
! { _M_buf.freeze(freezeflag); }
! 
! int 
! strstream::pcount() const
! { return _M_buf.pcount(); }
! 
! char* 
! strstream::str()
! { return _M_buf.str(); }
Index: src/valarray-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/valarray-inst.cc,v
retrieving revision 1.7
diff -c -p -r1.7 valarray-inst.cc
*** src/valarray-inst.cc	4 Jan 2002 21:27:36 -0000	1.7
--- src/valarray-inst.cc	1 Jul 2002 19:53:33 -0000
***************
*** 35,41 ****
  
  namespace std
  {
!   // Some explicit instanciations.
    template void
       __valarray_fill(size_t* __restrict__, size_t, const size_t&);
    
--- 35,41 ----
  
  namespace std
  {
!   // Some explicit instantiations.
    template void
       __valarray_fill(size_t* __restrict__, size_t, const size_t&);
    
*************** namespace std
*** 112,118 ****
                               const valarray<size_t>& __s)
        : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
          _M_index(__l.size() == 0 ? 0 : __valarray_product(__l))
!   { __gslice_to_index(__o, __l, __s, _M_index); }
!   
  } // namespace std
- 
--- 112,116 ----
                               const valarray<size_t>& __s)
        : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
          _M_index(__l.size() == 0 ? 0 : __valarray_product(__l))
!   { __gslice_to_index(__o, __l, __s, _M_index); }  
  } // namespace std



More information about the Gcc-patches mailing list