Mercurial > hg > octave-nkf
changeset 12666:68a59630798d stable
Fix case insenstive use of radio values in graphics objects (bug #33068)
* caseless-str.h (bool operator < (const std::string& s) const)):
New operator in the caseless_str class.
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 11 May 2011 22:02:32 +0200 |
parents | aa3ba343a76f |
children | d8aff843a9e9 |
files | liboctave/caseless-str.h |
diffstat | 1 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/caseless-str.h +++ b/liboctave/caseless-str.h @@ -46,6 +46,29 @@ operator std::string (void) const { return *this; } + bool operator < (const std::string& s) const + { + bool same = true; + const_iterator p1 = begin (); + const_iterator p2 = s.begin (); + + while (p1 != end () && p2 != s.end ()) + { + if (std::tolower (*p2) < std::tolower (*p1)) + return false; + if (same && (std::tolower (*p2) != std::tolower (*p1))) + same = false; + + *p1++; + *p2++; + } + + if (same && (length() >= s.length ())) + return false; + else + return true; + } + // Case-insensitive comparison. bool compare (const std::string& s, size_t limit = std::string::npos) const {