Mercurial > hg > octave-nkf
diff liboctave/caseless-str.h @ 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 | fd0a3ac60b0e |
children | 2c96207d0e06 |
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 {