fix read-to-end popping too much

This commit is contained in:
Daniella / Tove 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 ;
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 {

View file

@ -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

View file

@ -343,7 +343,7 @@ pub(super) fn stream_cmd(stack: &mut Stack) -> Result<Stream, Error> {
}
}
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..])