1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Fix split_floats behavior when spaces are used as separators

(cherry picked from commit f483c3aafa)
This commit is contained in:
Haoyu Qiu
2024-08-16 13:23:04 +08:00
committed by Rémi Verschelde
parent cfa33666c9
commit 562e583872
2 changed files with 82 additions and 50 deletions

View File

@@ -1537,13 +1537,16 @@ Vector<double> String::split_floats(const String &p_splitter, bool p_allow_empty
int from = 0;
int len = length();
String buffer = *this;
while (true) {
int end = find(p_splitter, from);
if (end < 0) {
end = len;
}
if (p_allow_empty || (end > from)) {
ret.push_back(String::to_float(&get_data()[from]));
buffer[end] = 0;
ret.push_back(String::to_float(&buffer.get_data()[from]));
buffer[end] = _cowdata.get(end);
}
if (end == len) {
@@ -1561,6 +1564,7 @@ Vector<float> String::split_floats_mk(const Vector<String> &p_splitters, bool p_
int from = 0;
int len = length();
String buffer = *this;
while (true) {
int idx;
int end = findmk(p_splitters, from, &idx);
@@ -1572,7 +1576,9 @@ Vector<float> String::split_floats_mk(const Vector<String> &p_splitters, bool p_
}
if (p_allow_empty || (end > from)) {
ret.push_back(String::to_float(&get_data()[from]));
buffer[end] = 0;
ret.push_back(String::to_float(&buffer.get_data()[from]));
buffer[end] = _cowdata.get(end);
}
if (end == len) {