Fixed algorithm problem in Str.split, that would drop the final str in the return list if it was empty

This commit is contained in:
Chad Stearns 2020-11-16 02:04:55 -05:00
parent 7b488d0970
commit a3720e6c3d
2 changed files with 64 additions and 25 deletions

View file

@ -133,7 +133,7 @@ pub fn strSplitInPlace(
var str_index : usize = 0;
if (str_len > delimiter_len) {
const end_index : usize = str_len - delimiter_len;
const end_index : usize = str_len - delimiter_len + 1;
while (str_index <= end_index) {
var delimiter_index : usize = 0;
var matches_delimiter = true;
@ -301,7 +301,7 @@ pub fn countSegments(
if (str_len > delimiter_len) {
var str_index: usize = 0;
const end_cond: usize = str_len - delimiter_len;
const end_cond: usize = str_len - delimiter_len + 1;
while (str_index < end_cond) {
var delimiter_index: usize = 0;