shithub: mc

Download patch

ref: 57d9a13a1046c79a3393317c47f93ebb54807786
parent: 003c3c95490986905616bd7c79b9ab2a9d65e115
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Mar 18 17:45:39 EDT 2017

We want to remove trailing spaces when tokenizing.

    Even if we run out of slots, the trailing spaces should be
    removed.

--- a/lib/std/strsplit.myr
+++ b/lib/std/strsplit.myr
@@ -5,6 +5,7 @@
 use "option"
 use "slpush"
 use "strfind"
+use "strstrip"
 use "types"
 use "utf"
 
@@ -96,7 +97,7 @@
 			elif idx < toks#.len - 1
 				toks#[idx] = s[i:j]
 			else
-				toks#[idx] = s[i:]
+				toks#[idx] = strrstrip(s[i:])
 				idx++
 				break
 			;;
--- a/lib/std/test/strsplit.myr
+++ b/lib/std/test/strsplit.myr
@@ -27,6 +27,7 @@
 	/* buffered tokenizing */
 	check(std.bstrtok(b[:], "a b  c\td"), ["a", "b", "c", "d"][:])
 	check(std.bstrtok(b[:2], "a b  c\td"), ["a", "b  c\td"][:])
+	check(std.bstrtok(b[:2], "a b  c\td   "), ["a", "b  c\td"][:])
 }
 
 const check = {a, b