# HG changeset patch # User jld # Date 1321895670 0 # Node ID 9de096a3010bba383e176a4c9c20eb8506814853 # Parent d3c77215b7bba013e5fede991e19ee48206dbe6e * include/ustl/ustring.h: Fix incorrect behaviour of iat when passed offset+npos. Reported by Frank Pagliughi. Patch from uSTL HEAD. [ Bugzilla 1001390 ] diff --git a/packages/language/cxx/ustl/current/ChangeLog b/packages/language/cxx/ustl/current/ChangeLog --- a/packages/language/cxx/ustl/current/ChangeLog +++ b/packages/language/cxx/ustl/current/ChangeLog @@ -1,3 +1,9 @@ +2011-11-21 John Dallaway + + * include/ustl/ustring.h: Fix incorrect behaviour of iat when passed + offset+npos. Reported by Frank Pagliughi. Patch from uSTL HEAD. + [ Bugzilla 1001390 ] + 2010-06-25 Simon Kallweit * include/*: @@ -42,7 +48,7 @@ 2009-08-20 Uwe Kindler reverse_iterator; typedef ::ustl::reverse_iterator const_reverse_iterator; typedef utf8in_iterator utf8_iterator; - static const uoff_t npos = static_cast(-1); ///< Value that means the end of string. + static const size_type npos = INT_MAX; ///< Value that means the end of string. public: inline string (void) : memblock () { relink ("",0); } string (const string& s); @@ -84,8 +84,8 @@ public: inline utf8_iterator utf8_end (void) const { return (utf8_iterator (end())); } inline const_reference at (uoff_t pos) const { assert (pos <= size() && begin()); return (begin()[pos]); } inline reference at (uoff_t pos) { assert (pos <= size() && begin()); return (begin()[pos]); } - inline const_iterator iat (uoff_t pos) const { return (begin() + min (pos, size())); } - inline iterator iat (uoff_t pos) { return (begin() + min (pos, size())); } + inline const_iterator iat (uoff_t pos) const { return (begin() + (__builtin_constant_p(pos) && pos >= npos ? size() : min(pos,size()))); } + inline iterator iat (uoff_t pos) { return (const_cast(const_cast(this)->iat(pos))); } const_iterator wiat (uoff_t i) const; inline iterator wiat (uoff_t i) { return (const_cast(const_cast(this)->wiat(i))); } inline const_reference back (void) const { return (at(size()-1)); }