Alternate patch for libstdc++/4354

Paolo Carlini pcarlini@unitus.it
Sat Sep 22 11:19:00 GMT 2001


Hi again.

A much cleaner, semantically equivalent, version of my previous patch is
also viable
(this one too regression tested i686-pc-linux-gnu)

Cheers,
Paolo Carlini.


*** basic_string.tcc.orig Sat Sep 22 19:56:58 2001
--- basic_string.tcc Sat Sep 22 20:04:32 2001
*************** namespace std
*** 453,462 ****
   if (__dmax <= __dnew)
     __throw_length_error("basic_string::_M_replace");
   size_type __off = __i1 - _M_ibegin();
!  _M_mutate(__off, __dold, __dnew);
!  // Invalidated __i1, __i2
!  if (__dnew)
!    _S_copy_chars(_M_data() + __off, __k1, __k2);

   return *this;
        }
--- 453,470 ----
   if (__dmax <= __dnew)
     __throw_length_error("basic_string::_M_replace");
   size_type __off = __i1 - _M_ibegin();
!  if (__dnew < __dold)
!    {
!      if (__dnew)
!        _S_copy_chars(_M_data() + __off, __k1, __k2);
!      _M_mutate(__off, __dold, __dnew);
!    }
!  else
!    {
!      _M_mutate(__off, __dold, __dnew);
!      if (__dnew)
!        _S_copy_chars(_M_data() + __off, __k1, __k2);
!    }

   return *this;
        }




More information about the Libstdc++ mailing list