Skip to content

Commit

Permalink
Fix word behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Jul 31, 2023
1 parent 39f9fe5 commit 204f9a4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/modules/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,16 @@ impl Control {
#[cmd(name = "word")]
fn interpret_word(ctx: &mut Context) -> Result<()> {
let separator = ctx.stack.pop_smallint_char()?;
let word = if separator.is_whitespace() {
ctx.input.scan_word()?.ok_or(Error::UnexpectedEof)?
let token = if separator.is_whitespace() {
ctx.input.scan_word()?.ok_or(Error::UnexpectedEof)?.data
} else {
ctx.input.scan_word_until(separator)?
match ctx.input.scan_word_until(separator) {
Ok(token) => token.data,
Err(Error::UnexpectedEof) if separator as u32 == 0 => "",
Err(e) => return Err(e),
}
};
ctx.stack.push(word.data.to_owned())
ctx.stack.push(token.to_owned())
}

#[cmd(name = "skipspc")]
Expand Down

0 comments on commit 204f9a4

Please sign in to comment.