diff options
Diffstat (limited to 'src/machine.rs')
-rw-r--r-- | src/machine.rs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/machine.rs b/src/machine.rs index f00af0a..26e1652 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -950,11 +950,11 @@ where State::BogusComment => match slf.read_char()? { Some('>') => { slf.state = State::Data; - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment(slf.position_before_match); Ok(ControlToken::Continue) } None => { - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment(slf.position_before_match); Ok(ControlToken::Eof) } Some('\0') => { @@ -994,7 +994,7 @@ where Some('>') => { slf.emit_error(Error::AbruptClosingOfEmptyComment); slf.state = State::Data; - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment(slf.position_before_match); Ok(ControlToken::Continue) } c => { @@ -1008,15 +1008,19 @@ where slf.state = State::CommentEnd; Ok(ControlToken::Continue) } - Some('>') => { + Some(c @ '>') => { slf.emit_error(Error::AbruptClosingOfEmptyComment); slf.state = State::Data; - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment( + slf.position_before_match - slf.reader.len_of_char_in_current_encoding(c), + ); Ok(ControlToken::Continue) } None => { slf.emit_error(Error::EofInComment); - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment( + slf.position_before_match - slf.reader.len_of_char_in_current_encoding('-'), + ); Ok(ControlToken::Eof) } c @ Some(_) => { @@ -1033,6 +1037,7 @@ where Ok(ControlToken::Continue) } Some('-') => { + slf.some_offset = slf.position_before_match; slf.state = State::CommentEndDash; Ok(ControlToken::Continue) } @@ -1109,7 +1114,7 @@ where } None => { slf.emit_error(Error::EofInComment); - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment(slf.some_offset); Ok(ControlToken::Eof) } c => { @@ -1122,7 +1127,7 @@ where State::CommentEnd => match slf.read_char()? { Some('>') => { slf.state = State::Data; - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment(slf.some_offset); Ok(ControlToken::Continue) } Some('!') => { @@ -1135,7 +1140,7 @@ where } None => { slf.emit_error(Error::EofInComment); - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment(slf.some_offset); Ok(ControlToken::Eof) } c @ Some(_) => { @@ -1157,12 +1162,12 @@ where Some('>') => { slf.emit_error(Error::IncorrectlyClosedComment); slf.state = State::Data; - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment(slf.some_offset); Ok(ControlToken::Continue) } None => { slf.emit_error(Error::EofInComment); - slf.emitter.emit_current_comment(slf.reader.position()); + slf.emitter.emit_current_comment(slf.some_offset); Ok(ControlToken::Eof) } c @ Some(_) => { |