Blame SOURCES/gcc32-libstdc++-fully-dynamic-strings.patch

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