diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 8c1a439ff7..1335714b20 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -58,7 +58,6 @@ - fix listener scroll to - { } H{ } [ ] tabular-output -- excess newline - multiple listener-run-files is broken -- word wrap in UI broken again - table line styles - x11 input methods - roundoff is still not quite right with tracks diff --git a/library/collections/slicing.factor b/library/collections/slicing.factor index cd97db6d75..cf20e40150 100644 --- a/library/collections/slicing.factor +++ b/library/collections/slicing.factor @@ -97,15 +97,13 @@ strings vectors ; : split-next, V{ } clone , ; -: split-end, building get dup peek empty? [ pop* ] [ drop ] if ; - : (split) ( separator elt -- | separator: elt -- ? ) [ swap call ] keep swap [ drop split-next, ] [ split,, ] if ; inline : split* ( seq separator -- split | separator: elt -- ? ) over >r - [ split-next, swap [ (split) ] each-with split-end, ] + [ split-next, swap [ (split) ] each-with ] { } make r> swap [ swap like ] map-with ; inline : split ( seq separators -- split ) diff --git a/library/io/stdio.factor b/library/io/stdio.factor index 18d5cd3ed7..d1dd528917 100644 --- a/library/io/stdio.factor +++ b/library/io/stdio.factor @@ -24,7 +24,7 @@ SYMBOL: stdio swap stdio get with-nested-stream ; : tabular-output ( grid style quot -- ) - -rot stdio get with-stream-table ; + swap stdio get with-stream-table ; : print ( string -- ) stdio get stream-print ; diff --git a/library/io/string-streams.factor b/library/io/string-streams.factor index a5218e586a..45b9fdee08 100644 --- a/library/io/string-streams.factor +++ b/library/io/string-streams.factor @@ -28,7 +28,7 @@ M: sbuf stream-flush drop ; M: plain-writer with-stream-table ( grid quot style stream -- ) [ - nip swap + drop swap [ [ swap string-out ] map-with ] map-with flip [ format-column ] map-last flip [ " " join ] map diff --git a/library/test/collections/strings.factor b/library/test/collections/strings.factor index a82b9d5d1a..1301540b55 100644 --- a/library/test/collections/strings.factor +++ b/library/test/collections/strings.factor @@ -55,6 +55,12 @@ unit-test [ { "a" "b" "c" "d" "e" "f" } ] [ "aXbYcXdYeXf" "XY" split ] unit-test +[ { "" "" } ] +[ " " " " split ] unit-test + +[ { "hey" } ] +[ "hey" " " split ] unit-test + [ "Hello world" t ] [ "Hello world\n" "\n" ?tail ] unit-test [ "Hello world" f ] [ "Hello world" "\n" ?tail ] unit-test [ "" t ] [ "\n" "\n" ?tail ] unit-test