mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Correct bytes._split_iterator
This commit is contained in:
@@ -218,8 +218,8 @@ split_after_n :: proc(s, sep: []byte, n: int, allocator := context.allocator) ->
|
|||||||
|
|
||||||
|
|
||||||
@private
|
@private
|
||||||
_split_iterator :: proc(s: ^[]byte, sep: []byte, sep_save, n: int) -> (res: []byte, ok: bool) {
|
_split_iterator :: proc(s: ^[]byte, sep: []byte, sep_save: int) -> (res: []byte, ok: bool) {
|
||||||
if sep == "" {
|
if len(sep) == 0 {
|
||||||
res = s[:]
|
res = s[:]
|
||||||
ok = true
|
ok = true
|
||||||
s^ = s[len(s):]
|
s^ = s[len(s):]
|
||||||
@@ -230,7 +230,7 @@ _split_iterator :: proc(s: ^[]byte, sep: []byte, sep_save, n: int) -> (res: []by
|
|||||||
if m < 0 {
|
if m < 0 {
|
||||||
// not found
|
// not found
|
||||||
res = s[:]
|
res = s[:]
|
||||||
ok = res != ""
|
ok = len(res) != 0
|
||||||
s^ = s[len(s):]
|
s^ = s[len(s):]
|
||||||
} else {
|
} else {
|
||||||
res = s[:m+sep_save]
|
res = s[:m+sep_save]
|
||||||
@@ -242,11 +242,11 @@ _split_iterator :: proc(s: ^[]byte, sep: []byte, sep_save, n: int) -> (res: []by
|
|||||||
|
|
||||||
|
|
||||||
split_iterator :: proc(s: ^[]byte, sep: []byte) -> ([]byte, bool) {
|
split_iterator :: proc(s: ^[]byte, sep: []byte) -> ([]byte, bool) {
|
||||||
return _split_iterator(s, sep, 0, -1)
|
return _split_iterator(s, sep, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
split_after_iterator :: proc(s: ^[]byte, sep: []byte) -> ([]byte, bool) {
|
split_after_iterator :: proc(s: ^[]byte, sep: []byte) -> ([]byte, bool) {
|
||||||
return _split_iterator(s, sep, len(sep), -1)
|
return _split_iterator(s, sep, len(sep))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user