#1058. Change comparator to return -1 : 0 : 1

v0.27.3
Robin Mills 10 years ago
parent 32f7d1de65
commit 0404bc75e9

@ -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;
}

Loading…
Cancel
Save