fix readln EOF handling
This commit is contained in:
parent
109feaa163
commit
fa60d4c1e0
3 changed files with 9 additions and 4 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -22,7 +22,7 @@ checksum = "b03f7fbd470aa8b3ad163c85cce8bccfc11cc9c44ef12da0a4eddd98bd307352"
|
|||
|
||||
[[package]]
|
||||
name = "spl"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"multicall",
|
||||
"once_cell",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "spl"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
edition = "2021"
|
||||
description = "Stack Pogramming Language: A simple, concise scripting language."
|
||||
license = "MIT"
|
||||
|
|
|
@ -663,9 +663,14 @@ pub fn import(stack: &mut Stack) -> OError {
|
|||
|
||||
pub fn readln(stack: &mut Stack) -> OError {
|
||||
let mut s = String::new();
|
||||
stdin()
|
||||
if stdin()
|
||||
.read_line(&mut s)
|
||||
.map_err(|x| stack.error(ErrorKind::IO(format!("{x:?}"))))?;
|
||||
.map_err(|x| stack.error(ErrorKind::IO(format!("{x:?}"))))?
|
||||
== 0
|
||||
{
|
||||
stack.push(Value::Null.spl());
|
||||
return Ok(());
|
||||
}
|
||||
let s = if let Some(s) = s.strip_suffix("\r\n") {
|
||||
s.to_owned()
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue