Fix splitting an empty string

This commit is contained in:
Bruce Hill 2024-09-02 23:24:16 -04:00
parent 6e4be93848
commit 9d2e9c02fe
2 changed files with 6 additions and 0 deletions

View File

@ -1428,6 +1428,9 @@ public Text_t Text$replace(Text_t text, Text_t pattern, Text_t replacement)
public array_t Text$split(Text_t text, Text_t pattern)
{
if (text.length == 0) // special case
return (array_t){.length=0};
if (pattern.length == 0) // special case
return Text$clusters(text);

View File

@ -152,3 +152,6 @@ func main():
>> "+":join([:Text])
= ""
>> "":split()
= []