Blame SOURCES/compat-libstdc++33++-fully-dynamic-strings.patch

4ac4fd
2004-10-28  Paolo Carlini  <pcarlini@suse.de>
4ac4fd
4ac4fd
	PR libstdc++/16612
4ac4fd
	* include/bits/basic_string.h (basic_string()): When
4ac4fd
	_GLIBCXX_FULLY_DYNAMIC_STRING is defined, don't deal with _S_empty_rep.
4ac4fd
	* include/bits/basic_string.tcc (_S_construct): Likewise.
4ac4fd
4ac4fd
--- libstdc++33-v3/include/bits/basic_string.tcc.jj	2002-11-09 18:42:55.000000000 +0100
4ac4fd
+++ libstdc++33-v3/include/bits/basic_string.tcc	2004-11-12 14:17:19.946131774 +0100
4ac4fd
@@ -77,8 +77,10 @@ namespace std
4ac4fd
       _S_construct(_InIter __beg, _InIter __end, const _Alloc& __a,
4ac4fd
 		   input_iterator_tag)
4ac4fd
       {
4ac4fd
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
4ac4fd
 	if (__beg == __end && __a == _Alloc())
4ac4fd
 	  return _S_empty_rep()._M_refcopy();
4ac4fd
+#endif
4ac4fd
 	// Avoid reallocation for common case.
4ac4fd
 	_CharT __buf[100];
4ac4fd
 	size_type __i = 0;
4ac4fd
@@ -137,11 +139,13 @@ namespace std
4ac4fd
       _S_construct(_InIter __beg, _InIter __end, const _Alloc& __a, 
4ac4fd
 		   forward_iterator_tag)
4ac4fd
       {
4ac4fd
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
4ac4fd
 	if (__beg == __end && __a == _Alloc())
4ac4fd
 	  return _S_empty_rep()._M_refcopy();
4ac4fd
+#endif
4ac4fd
 
4ac4fd
 	// NB: Not required, but considered best practice.
4ac4fd
-	if (__builtin_expect(__beg == _InIter(), 0))
4ac4fd
+	if (__builtin_expect(__beg == _InIter() && __beg != __end, 0))
4ac4fd
 	  __throw_logic_error("attempt to create string with null pointer");
4ac4fd
 
4ac4fd
 	size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
4ac4fd
@@ -166,8 +170,10 @@ namespace std
4ac4fd
     basic_string<_CharT, _Traits, _Alloc>::
4ac4fd
     _S_construct(size_type __n, _CharT __c, const _Alloc& __a)
4ac4fd
     {
4ac4fd
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
4ac4fd
       if (__n == 0 && __a == _Alloc())
4ac4fd
 	return _S_empty_rep()._M_refcopy();
4ac4fd
+#endif
4ac4fd
 
4ac4fd
       // Check for out_of_range and length_error exceptions.
4ac4fd
       _Rep* __r = _Rep::_S_create(__n, __a);
4ac4fd
--- libstdc++33-v3/include/bits/basic_string.h.jj	2002-05-22 15:39:29.000000000 +0200
4ac4fd
+++ libstdc++33-v3/include/bits/basic_string.h	2004-11-12 14:14:42.831975711 +0100
4ac4fd
@@ -923,7 +923,11 @@ namespace std
4ac4fd
   template<typename _CharT, typename _Traits, typename _Alloc>
4ac4fd
     inline basic_string<_CharT, _Traits, _Alloc>::
4ac4fd
     basic_string()
4ac4fd
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
4ac4fd
     : _M_dataplus(_S_empty_rep()._M_refcopy(), _Alloc()) { }
4ac4fd
+#else
4ac4fd
+    : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
4ac4fd
+#endif
4ac4fd
 
4ac4fd
   // operator+
4ac4fd
   template<typename _CharT, typename _Traits, typename _Alloc>