You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix crash caused by trailing spaces
This commit is contained in:
@@ -1175,7 +1175,7 @@ String String::get_slicec(char32_t p_splitter, int p_slice) const {
|
||||
}
|
||||
}
|
||||
|
||||
Vector<String> String::split_spaces() const {
|
||||
Vector<String> String::split_spaces(int p_maxsplit) const {
|
||||
Vector<String> ret;
|
||||
int from = 0;
|
||||
int i = 0;
|
||||
@@ -1199,6 +1199,11 @@ Vector<String> String::split_spaces() const {
|
||||
}
|
||||
|
||||
if (empty && inside) {
|
||||
if (p_maxsplit > 0 && p_maxsplit == ret.size()) {
|
||||
// Put rest of the string and leave cycle.
|
||||
ret.push_back(substr(from));
|
||||
break;
|
||||
}
|
||||
ret.push_back(substr(from, i - from));
|
||||
inside = false;
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ public:
|
||||
Vector<String> split(const char *p_splitter = "", bool p_allow_empty = true, int p_maxsplit = 0) const;
|
||||
Vector<String> rsplit(const String &p_splitter = "", bool p_allow_empty = true, int p_maxsplit = 0) const;
|
||||
Vector<String> rsplit(const char *p_splitter = "", bool p_allow_empty = true, int p_maxsplit = 0) const;
|
||||
Vector<String> split_spaces() const;
|
||||
Vector<String> split_spaces(int p_maxsplit = 0) const;
|
||||
Vector<double> split_floats(const String &p_splitter, bool p_allow_empty = true) const;
|
||||
Vector<float> split_floats_mk(const Vector<String> &p_splitters, bool p_allow_empty = true) const;
|
||||
Vector<int> split_ints(const String &p_splitter, bool p_allow_empty = true) const;
|
||||
|
||||
Reference in New Issue
Block a user