[Scummvm-git-logs] scummvm master -> 9ab48df4b6b4889179177a4b9cd35162834ac8aa
criezy
criezy at scummvm.org
Wed Sep 2 20:04:00 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9ab48df4b6 COMMON: Fix comparaison operators for U32String
Commit: 9ab48df4b6b4889179177a4b9cd35162834ac8aa
https://github.com/scummvm/scummvm/commit/9ab48df4b6b4889179177a4b9cd35162834ac8aa
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-09-02T21:01:15+01:00
Commit Message:
COMMON: Fix comparaison operators for U32String
They were supposed to compare two U32String, but due to a copy/paste
error they were comparing a U32String with a String. It compiled
because there is a String constructor that takes a U32String (and
converts it to UTF-8), but it was probably not quite working as
expected for non-ASCII characters.
Changed paths:
common/ustr.cpp
common/ustr.h
diff --git a/common/ustr.cpp b/common/ustr.cpp
index 5e247c2c87..f3013ced65 100644
--- a/common/ustr.cpp
+++ b/common/ustr.cpp
@@ -198,10 +198,10 @@ bool U32String::operator!=(const char *x) const {
return !equals(x);
}
-bool U32String::operator<(const String &x) const {
+bool U32String::operator<(const U32String &x) const {
for (uint32 i = 0, n = x.size(); i < _size && i < n; ++i) {
uint32 sc = _str[i];
- uint8 xc = x[i];
+ uint32 xc = x[i];
if (sc < xc)
return true;
else if (sc > xc)
@@ -210,14 +210,14 @@ bool U32String::operator<(const String &x) const {
return (_size < x.size());
}
-bool U32String::operator<=(const String &x) const {
+bool U32String::operator<=(const U32String &x) const {
return !operator>(x);
}
-bool U32String::operator>(const String &x) const {
+bool U32String::operator>(const U32String &x) const {
for (uint i = 0, n = x.size(); i < _size && i < n; ++i) {
uint32 sc = _str[i];
- uint8 xc = x[i];
+ uint32 xc = x[i];
if (sc > xc)
return true;
else if (sc < xc)
@@ -226,7 +226,7 @@ bool U32String::operator>(const String &x) const {
return (_size > x.size());
}
-bool U32String::operator>=(const String &x) const {
+bool U32String::operator>=(const U32String &x) const {
return !operator<(x);
}
diff --git a/common/ustr.h b/common/ustr.h
index 3e544f0c44..45c3c31abd 100644
--- a/common/ustr.h
+++ b/common/ustr.h
@@ -136,10 +136,10 @@ public:
bool operator!=(const value_type *x) const;
bool operator!=(const char *x) const;
- bool operator<(const String &x) const;
- bool operator<=(const String &x) const;
- bool operator>(const String &x) const;
- bool operator>=(const String &x) const;
+ bool operator<(const U32String &x) const;
+ bool operator<=(const U32String &x) const;
+ bool operator>(const U32String &x) const;
+ bool operator>=(const U32String &x) const;
/**
* Compares whether two U32String are the same based on memory comparison.
More information about the Scummvm-git-logs
mailing list