diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index 22005add..738b4ea5 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -872,21 +872,29 @@ namespace Exiv2 { }; // class XmpArrayValue /*! - @brief %LangAltValueComparison + @brief %LangAltValueComparator #1058 https://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/XMPSpecificationPart1.pdf XMP spec chapter B.4 (page 42) the xml:lang qualifier is to be compared case insensitive. */ struct LangAltValueComparator { - bool operator() (const std::string& str1, const std::string& str2) const + int operator() (const std::string& str1, const std::string& str2) const { - bool result = str1.size() != str2.size(); - for (std::string::const_iterator c1 = str1.begin() - , c2 = str2.begin() - ; result && c1 != str1.end() - ; ++c1, ++c2) { - result = tolower(*c1) != tolower(*c2); + int result = str1.size() < str2.size() ? -1 + : str1.size() > str2.size() ? 1 + : 0 + ; + std::string::const_iterator c1 = str1.begin(); + std::string::const_iterator c2 = str2.begin(); + for ( + ; result==0 && c1 != str1.end() + ; ++c1, ++c2 + ) { + result = tolower(*c1) < tolower(*c2) ? -1 + : tolower(*c1) > tolower(*c2) ? 1 + : 0 + ; } return result; }