mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-02-20 15:14:26 +01:00
Fix expected alphanumeric comparison logic in string.
This commit is contained in:
parent
3a5487b2ab
commit
c827f6fe64
@ -325,12 +325,9 @@ void String::replace(const String &find_str, const String &with, const int count
|
||||
}
|
||||
|
||||
int String::compare(const String &other) const {
|
||||
if (size() < other.size()) {
|
||||
return 1;
|
||||
} else if (size() > other.size()) {
|
||||
return 2;
|
||||
} else {
|
||||
for (int i = 0; i < _size; ++i) {
|
||||
int cmp_size = MIN(size(), other.size());
|
||||
|
||||
for (int i = 0; i < cmp_size; ++i) {
|
||||
if (_data[i] < other._data[i]) {
|
||||
return 1;
|
||||
} else if (_data[i] > other._data[i]) {
|
||||
@ -338,6 +335,11 @@ int String::compare(const String &other) const {
|
||||
}
|
||||
}
|
||||
|
||||
if (size() < other.size()) {
|
||||
return 1;
|
||||
} else if (size() > other.size()) {
|
||||
return 2;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user