Skip to content

Commit 210e40d

Browse files
committed
fixed a bug in the print builtin implementation where it was incorrectly adding newlines, ensuring it now behaves exactly as documented in the README
1 parent 37c981e commit 210e40d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/stdlib/standard_library.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ pub fn print_builtin(env: &mut Environment<Expression>) -> Statement {
6969
.map(|(_, v)| v)
7070
.unwrap_or(Expression::CString("".to_string()));
7171
match value {
72-
Expression::CString(s) => println!("{}", s),
73-
Expression::CInt(i) => println!("{}", i),
74-
Expression::CReal(f) => println!("{}", f),
75-
_ => println!("{:?}", value),
72+
Expression::CString(s) => print!("{}", s),
73+
Expression::CInt(i) => print!("{}", i),
74+
Expression::CReal(f) => print!("{}", f),
75+
_ => print!("{:?}", value),
7676
}
77+
use std::io::{self, Write};
78+
io::stdout().flush().unwrap();
7779
Statement::Return(Box::new(Expression::CVoid))
7880
}
7981

0 commit comments

Comments
 (0)