Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit db6f000

Browse files
committed
[[ Bug 22963 ]] Fix native split with unfound multi-char delimiter
This patch fixes an issue where the results of the split command with a multi- char delimiter do not match between the unicode and native code paths. Specifically the native pathway created an array with empty key and value for element while the unicode pathway correctly creates the opposite.
1 parent 7b57891 commit db6f000

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docs/notes/bugfix-22963.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix incorrect result when split does not find multi-char delimiter

libfoundation/src/foundation-string.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5199,7 +5199,10 @@ static void split_find_end_of_element_and_key_native(const char_t *sptr, const c
51995199

52005200
// key not found
52015201
if (sptr == eptr - p_key_length + 1)
5202-
r_key_ptr = sptr;
5202+
{
5203+
r_key_ptr = eptr;
5204+
r_end_ptr = eptr;
5205+
}
52035206

52045207
split_find_end_of_element_native(sptr, eptr, del, p_del_length, r_end_ptr, p_options);
52055208
}

tests/lcs/core/array/split.livecodescript

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,14 @@ on TestBug22586
250250
split tVar by return and ": "
251251
TestAssert "unicode split by unfound multi-char delimiter does not crash", true
252252
end TestBug22586
253+
254+
on TestBug22962
255+
local tVar
256+
put "foo" into tVar
257+
split tVar by return and ": "
258+
TestAssert "native split by unfound multi-char delimiter", the keys of tVar is "foo"
259+
260+
put "foo" & numToCodePoint(0x2192) into tVar
261+
split tVar by return and ": "
262+
TestAssert "unicode split by unfound multi-char delimiter", the keys of tVar is "foo" & numToCodePoint(0x2192)
263+
end TestBug22962

0 commit comments

Comments
 (0)