瀏覽代碼

Fix strings.split_iterator when separator is empty

Jacob Friedman 8 月之前
父節點
當前提交
239c511ce9
共有 1 個文件被更改,包括 2 次插入6 次删除
  1. 2 6
      core/strings/strings.odin

+ 2 - 6
core/strings/strings.odin

@@ -1031,14 +1031,10 @@ Returns:
 */
 */
 @private
 @private
 _split_iterator :: proc(s: ^string, sep: string, sep_save: int) -> (res: string, ok: bool) {
 _split_iterator :: proc(s: ^string, sep: string, sep_save: int) -> (res: string, ok: bool) {
+	m := index(s^, sep)
 	if sep == "" {
 	if sep == "" {
-		res = s[:]
-		ok = true
-		s^ = s[len(s):]
-		return
+		m = 1 if len(s) > 0 else -1
 	}
 	}
-
-	m := index(s^, sep)
 	if m < 0 {
 	if m < 0 {
 		// not found
 		// not found
 		res = s[:]
 		res = s[:]