fix read-to-end popping too much
This commit is contained in:
parent
fccce8b705
commit
2e126a6652
3 changed files with 15 additions and 6 deletions
11
spl/std.spl
11
spl/std.spl
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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..])
|
||||||
|
|
Loading…
Add table
Reference in a new issue