fix read-to-end popping too much

This commit is contained in:
Daniella 2024-10-14 01:05:11 +02:00
parent fccce8b705
commit 2e126a6652
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
3 changed files with 15 additions and 6 deletions

View file

@ -427,6 +427,17 @@ construct MicroMap {
clear { | with this ; clear { | with this ;
this:pairs:clear; 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 { construct Range {

View file

@ -30,13 +30,11 @@ construct Stream {
buf this:id read-all-stream buf buf this:id read-all-stream buf
} }
read-to-end { [int] | with buf this ; read-to-end { [int] | with buf this ;
def full 0 banew =full
buf gettype "mega" eq if { buf banew =buf } buf gettype "mega" eq if { buf banew =buf }
def read def read
while { buf this:id read-stream pop _mega dup =read } { 0 banew while { buf this:id read-stream pop _mega dup =read } {
full (0 read buf:sub) aadd =full (0 read buf:sub) aadd
} pop }
full
} }
write { mega | with buf this ; write { mega | with buf this ;
buf this:id write-stream buf this:id write-stream

View file

@ -343,7 +343,7 @@ pub(super) fn stream_cmd(stack: &mut Stack) -> Result<Stream, Error> {
} }
} }
if args.is_empty() { 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]) let mut command = process::Command::new(&args[0])
.args(&args[1..]) .args(&args[1..])