Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 5278 invoked from network); 26 Nov 2005 01:13:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Nov 2005 01:13:14 -0000 Received: (qmail 52931 invoked by uid 500); 26 Nov 2005 01:13:14 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 52912 invoked by uid 500); 26 Nov 2005 01:13:14 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 52901 invoked by uid 500); 26 Nov 2005 01:13:14 -0000 Delivered-To: apmail-incubator-stdcxx-cvs@incubator.apache.org Received: (qmail 52898 invoked by uid 99); 26 Nov 2005 01:13:14 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 25 Nov 2005 17:13:14 -0800 Received: (qmail 5024 invoked by uid 65534); 26 Nov 2005 01:12:53 -0000 Message-ID: <20051126011253.5021.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r349056 - in /incubator/stdcxx/trunk/include: string string.cc Date: Sat, 26 Nov 2005 01:12:53 -0000 To: stdcxx-cvs@incubator.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: sebor Date: Fri Nov 25 17:12:48 2005 New Revision: 349056 URL: http://svn.apache.org/viewcvs?rev=349056&view=rev Log: 2005-11-25 Martin Sebor STDCXX-70 * string (basic_string): Took into account the fact that the value of the reference count when read unguarded may be negative (-1) on SPARC V8 when it's being manipulated (incremented or decremented) by another thread, and cast it to an unsigned type in expressions involving relational operators such as < and <=. (begin): Same. (append): Same. * string.cc (operator=): Same. (replace): Same. (__replace_aux): Same. Modified: incubator/stdcxx/trunk/include/string incubator/stdcxx/trunk/include/string.cc Modified: incubator/stdcxx/trunk/include/string URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/string?rev=349056&r1=349055&r2=349056&view=diff ============================================================================== --- incubator/stdcxx/trunk/include/string (original) +++ incubator/stdcxx/trunk/include/string Fri Nov 25 17:12:48 2005 @@ -937,7 +937,7 @@ basic_string (const basic_string<_CharT, _Traits, _Allocator> &__s) : allocator_type (__s.get_allocator ()) { - if (__s._C_pref ()->_C_get_ref () > 0) { + if (size_type (0) < size_type (__s._C_pref ()->_C_get_ref ())) { _C_data = __s._C_data; _C_pref ()->_C_inc_ref (); } @@ -956,7 +956,7 @@ basic_string<_CharT, _Traits, _Allocator>:: begin () { - if (_C_pref ()->_C_get_ref () > 1) + if (size_type (1) < size_type (_C_pref ()->_C_get_ref ())) _C_clone (size ()); // not thread safe: there is exactly one body pointed to by @@ -1180,7 +1180,8 @@ { const size_type __size = size () + __str.size (); - if (__size > capacity () || _C_pref ()->_C_get_ref () > 1) + if ( capacity () < __size + || size_type (1) < size_type (_C_pref ()->_C_get_ref ())) return append (__str, size_type (), __str.size ()); traits_type::copy (_C_data + size (), __str.data (), __str.size () + 1); Modified: incubator/stdcxx/trunk/include/string.cc URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/string.cc?rev=349056&r1=349055&r2=349056&view=diff ============================================================================== --- incubator/stdcxx/trunk/include/string.cc (original) +++ incubator/stdcxx/trunk/include/string.cc Fri Nov 25 17:12:48 2005 @@ -2,7 +2,7 @@ * * string.cc - Definitions for the Standard Library string classes * - * $Id: //stdlib/dev/include/string.cc#63 $ + * $Id$ * *************************************************************************** * @@ -218,7 +218,8 @@ basic_string<_CharT, _Traits, _Allocator>:: operator= (const basic_string &__rhs) { - if (__rhs._C_pref ()->_C_get_ref () > 0) { + if (size_type (0) < size_type (__rhs._C_pref ()->_C_get_ref ())) { + // `rhs' has reference counting enabled __rhs._C_pref ()->_C_inc_ref (); _C_unlink (__rhs._C_data); } @@ -356,7 +357,7 @@ // check for shared representation, insufficient capacity, // and overlapping regions - if ( _C_pref ()->_C_get_ref () > 1 + if ( size_type (1) < size_type (_C_pref ()->_C_get_ref ()) || capacity () < __size1 || __s >= data () && __s < data () + __size0) { @@ -427,7 +428,8 @@ const size_type __rem = __size0 - __xlen - __pos; // check for shared representation, insufficient capacity - if (_C_pref ()->_C_get_ref () > 1 || capacity () < __size1) { + if ( capacity () < __size1 + || size_type (1) < size_type (_C_pref ()->_C_get_ref ())) { // need to allocate a new reference const size_type __cap = _C_grow (__size0, __size1); @@ -621,7 +623,8 @@ size_type __d = 0; size_type __rem = __s.size() - __xlen - __pos; // length of bit at the end // Check for shared representation, insufficient capacity, - if ( (__s._C_pref()->_C_get_ref () > 1) || (__s.capacity() < __len)) + if ( __s.capacity() < __len + || size_type (1) < size_type (__s._C_pref()->_C_get_ref ())) { // Need to allocate a new reference. const size_type __cap = __s._C_grow (__s.size (), __len);