1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: fix bug with string.split_into_lines, when lines have extra CR's at their end (#16620)

This commit is contained in:
Carter 2022-12-09 01:15:50 -06:00 committed by GitHub
parent 7091010a53
commit eb88f7e255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -849,11 +849,9 @@ pub fn (s string) split_into_lines() []string {
return res
}
mut start := 0
mut end := 0
for i := 0; i < s.len; i++ {
if s[i] == 10 {
end = if i > 0 && s[i - 1] == 13 { i - 1 } else { i }
res << if start == end { '' } else { s[start..end] }
res << if start == i { '' } else { s[start..i].trim_right('\r') }
start = i + 1
}
}