London changes to string:

* std/bastring.cc (check_realloc): Don't be selfish anymore.
	* std/bastring.h (non-const operator[]): Be selfish.
	(iterator forms of insert and erase): Stay selfish.

From-SVN: r16722
This commit is contained in:
Jason Merrill 1997-11-26 07:19:11 +00:00 committed by Jason Merrill
parent 11df6ae767
commit f4f3e8fdf7
4 changed files with 21 additions and 11 deletions

View File

@ -1,3 +1,10 @@
Tue Nov 25 23:16:44 1997 Jason Merrill <jason@yorick.cygnus.com>
London changes to string:
* std/bastring.cc (check_realloc): Don't be selfish anymore.
* std/bastring.h (non-const operator[]): Be selfish.
(iterator forms of insert and erase): Stay selfish.
Tue Nov 25 14:03:43 1997 H.J. Lu (hjl@gnu.org)
* Makefile.in (stmp-complex, bigstmp-complex): Changed to

View File

@ -301,9 +301,10 @@ stuff:
$(MAKE) clean
$(MAKE) -C ../libio c++clean
$(MAKE) -C ../libg++ clean
$(MAKE) $(MAKEFLAGS) check
$(MAKE) -C ../libio check
$(MAKE) -C ../libg++ check
-$(MAKE) $(MAKEFLAGS) check
-$(MAKE) -C ../libio check
-$(MAKE) -C ../libg++ check
-$(MAKE) -C ../gcc check-g++
stuff1:
$(MAKE) clean
@ -311,6 +312,7 @@ stuff1:
$(MAKE) -C ../libg++ clean
stuff2:
$(MAKE) check
$(MAKE) -C ../libio check
$(MAKE) -C ../libg++ check
-$(MAKE) check
-$(MAKE) -C ../libio check
-$(MAKE) -C ../libg++ check
-$(MAKE) -C ../gcc check-g++

View File

@ -87,6 +87,7 @@ inline bool basic_string <charT, traits>::
check_realloc (size_t s) const
{
s += sizeof (charT);
rep ()->selfish = false;
return (rep ()->ref > 1
|| s > capacity ()
|| Rep::excess_slop (s, capacity ()));

View File

@ -220,9 +220,9 @@ public:
basic_string& insert (size_type pos, size_type n, charT c)
{ return replace (pos, 0, n, c); }
iterator insert(iterator p, charT c)
{ insert (p - ibegin (), 1, c); return p; }
{ insert (p - ibegin (), 1, c); selfish (); return p; }
iterator insert(iterator p, size_type n, charT c)
{ insert (p - ibegin (), n, c); return p; }
{ insert (p - ibegin (), n, c); selfish (); return p; }
#ifdef __STL_MEMBER_TEMPLATES
template<class InputIterator>
void insert(iterator p, InputIterator first, InputIterator last)
@ -234,9 +234,9 @@ public:
basic_string& erase (size_type pos = 0, size_type n = npos)
{ return replace (pos, n, (size_type)0, (charT)0); }
iterator erase(iterator p)
{ replace (p - ibegin (), 1, (size_type)0, (charT)0); return p; }
{ replace (p-ibegin (), 1, (size_type)0, (charT)0); selfish (); return p; }
iterator erase(iterator f, iterator l)
{ replace (f - ibegin (), l - f, (size_type)0, (charT)0); return f; }
{ replace (f-ibegin (), l-f, (size_type)0, (charT)0);selfish ();return f; }
basic_string& replace (size_type pos1, size_type n1, const basic_string& str,
size_type pos2 = 0, size_type n2 = npos);
@ -278,7 +278,7 @@ public:
}
reference operator[] (size_type pos)
{ unique (); return (*rep ())[pos]; }
{ selfish (); return (*rep ())[pos]; }
reference at (size_type pos)
{