mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-28 06:46:21 +01:00
Fix logic in String::substr_index.
This commit is contained in:
parent
a781853b2b
commit
4d6b2f6f55
@ -926,7 +926,7 @@ String String::substr(int p_from, int p_chars) const {
|
|||||||
String String::substr_index(const int start_index, const int end_index) const {
|
String String::substr_index(const int start_index, const int end_index) const {
|
||||||
int s = length();
|
int s = length();
|
||||||
|
|
||||||
if (start_index < 0 || start_index >= s || end_index < 0 || start_index >= s) {
|
if (start_index < 0 || start_index >= s || end_index < 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -934,6 +934,10 @@ String String::substr_index(const int start_index, const int end_index) const {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (end_index >= s) {
|
||||||
|
return substr(start_index, (s - 1) - start_index);
|
||||||
|
}
|
||||||
|
|
||||||
return substr(start_index, end_index - start_index);
|
return substr(start_index, end_index - start_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user