From 2e126a66529e48565ebfd2b9dcb77f557cde079c Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 14 Oct 2024 01:05:11 +0200 Subject: [PATCH] fix read-to-end popping too much --- spl/std.spl | 11 +++++++++++ spl/stream.spl | 8 +++----- src/stream/rw.rs | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/spl/std.spl b/spl/std.spl index 6493ee6..c69c29c 100644 --- a/spl/std.spl +++ b/spl/std.spl @@ -427,6 +427,17 @@ construct MicroMap { clear { | with this ; this:pairs:clear; } + to-str { str | with this ; + "{ " + { | with item ; + "'" concat + 0 item:get dup null eq if { "key is null" panic } _str concat + "': '" concat + 1 item:get dup null eq if { "value is null" panic } _str concat + "', " concat + } this:foreach + "}" concat + } } construct Range { diff --git a/spl/stream.spl b/spl/stream.spl index 53ff615..b8c8784 100644 --- a/spl/stream.spl +++ b/spl/stream.spl @@ -30,13 +30,11 @@ construct Stream { buf this:id read-all-stream buf } read-to-end { [int] | with buf this ; - def full 0 banew =full buf gettype "mega" eq if { buf banew =buf } def read - while { buf this:id read-stream pop _mega dup =read } { - full (0 read buf:sub) aadd =full - } pop - full + 0 banew while { buf this:id read-stream pop _mega dup =read } { + (0 read buf:sub) aadd + } } write { mega | with buf this ; buf this:id write-stream diff --git a/src/stream/rw.rs b/src/stream/rw.rs index fe5d5b7..2bdde3b 100644 --- a/src/stream/rw.rs +++ b/src/stream/rw.rs @@ -343,7 +343,7 @@ pub(super) fn stream_cmd(stack: &mut Stack) -> Result { } } if args.is_empty() { - return stack.err(ErrorKind::InvalidCall("command".to_owned())); + return stack.err(ErrorKind::InvalidCall("CMD new-stream".to_owned())); } let mut command = process::Command::new(&args[0]) .args(&args[1..])