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,19 +325,21 @@ void String::replace(const String &find_str, const String &with, const int count
|
|||||||
}
|
}
|
||||||
|
|
||||||
int String::compare(const String &other) const {
|
int String::compare(const String &other) const {
|
||||||
|
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]) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (size() < other.size()) {
|
if (size() < other.size()) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (size() > other.size()) {
|
} else if (size() > other.size()) {
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < _size; ++i) {
|
|
||||||
if (_data[i] < other._data[i]) {
|
|
||||||
return 1;
|
|
||||||
} else if (_data[i] > other._data[i]) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user