diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-08-16 14:36:40 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-08-16 14:36:40 +0200 |
commit | 803dfcc3cb3427415bf6d6d2ac6f947c9af8b889 (patch) | |
tree | d6477f11087392555cfe4c375523ed979209c738 /core/string | |
parent | ec74e1494354e3e0eb8851837a7ded2a00beae96 (diff) | |
parent | f483c3aafa5f3cfb1ab763ab4eb077aac74e88d6 (diff) | |
download | redot-engine-803dfcc3cb3427415bf6d6d2ac6f947c9af8b889.tar.gz |
Merge pull request #95613 from timothyqiu/split-empty
Fix `split_floats` behavior when spaces are used as separators
Diffstat (limited to 'core/string')
-rw-r--r-- | core/string/ustring.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index f39ebad8d9..5a1f6925aa 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -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) { |