Mercurial > ecos
changeset 3066:9de096a3010b
* include/ustl/ustring.h: Fix incorrect behaviour of iat when passed
offset+npos. Reported by Frank Pagliughi. Patch from uSTL HEAD.
[ Bugzilla 1001390 ]
| author | jld |
|---|---|
| date | Mon, 21 Nov 2011 17:14:30 +0000 |
| parents | d3c77215b7bb |
| children | 31e709d67a8c |
| files | packages/language/cxx/ustl/current/ChangeLog packages/language/cxx/ustl/current/include/ustl/ustring.h |
| diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/language/cxx/ustl/current/ChangeLog +++ b/packages/language/cxx/ustl/current/ChangeLog @@ -1,3 +1,9 @@ +2011-11-21 John Dallaway <john@dallaway.org.uk> + + * 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 <simon.kallweit@intefo.ch> * include/*: @@ -42,7 +48,7 @@ 2009-08-20 Uwe Kindler <uwe_kindler@web // ####GPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
--- a/packages/language/cxx/ustl/current/include/ustl/ustring.h +++ b/packages/language/cxx/ustl/current/include/ustl/ustring.h @@ -55,7 +55,7 @@ public: typedef ::ustl::reverse_iterator<iterator> reverse_iterator; typedef ::ustl::reverse_iterator<const_iterator> const_reverse_iterator; typedef utf8in_iterator<const_iterator> utf8_iterator; - static const uoff_t npos = static_cast<uoff_t>(-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<iterator>(const_cast<const string*>(this)->iat(pos))); } const_iterator wiat (uoff_t i) const; inline iterator wiat (uoff_t i) { return (const_cast<iterator>(const_cast<const string*>(this)->wiat(i))); } inline const_reference back (void) const { return (at(size()-1)); }
