Compare commits

...

2 commits

Author SHA1 Message Date
f07a256fe6 add cat example program 2023-12-16 13:39:41 +01:00
27822fc06a strip trailing newline from manual input 2023-12-16 13:39:25 +01:00
2 changed files with 8 additions and 1 deletions

2
programs/cat.worm Normal file
View file

@ -0,0 +1,2 @@
@00000 11\
\!=?1/

View file

@ -65,7 +65,12 @@ fn main() {
stdin().read_line(&mut input_text).unwrap(); stdin().read_line(&mut input_text).unwrap();
let action: Vec<_> = input_text.trim().split_ascii_whitespace().collect(); let action: Vec<_> = input_text.trim().split_ascii_whitespace().collect();
if input_text.starts_with("input ") { if input_text.starts_with("input ") {
interpreter.input.extend(&input_text.as_bytes()[6..]); interpreter.input.extend(
&input_text
.strip_suffix('\n')
.unwrap_or(&input_text)
.as_bytes()[6..],
);
continue; continue;
} }
match action.as_slice() { match action.as_slice() {