diff options
| author | Martin Fischer <martin@push-f.com> | 2023-08-17 16:12:51 +0200 | 
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2023-08-19 13:41:55 +0200 | 
| commit | cb4e9cf7cfc1612c67f16bfabadbdf442cd380fe (patch) | |
| tree | 5aa2bf7dccafe66d735f3609d446bfad083ab8a3 /src/machine.rs | |
| parent | c15895d44d17984386d3684e2aa85aca386ba3bf (diff) | |
fix: fix lots of position off-by-ones
Previously the PosTrackingReader always mysteriously subtracted 1
from the current position ... this wasn't sound at all ... the machine
just happens to often call `Tokenizer::unread_char` ... but not always.
E.g. for proper comments it didn't which resulted in their offset and
spans being off-by-one, which is fixed by this commit (see test_spans.rs).
Diffstat (limited to 'src/machine.rs')
| -rw-r--r-- | src/machine.rs | 8 | 
1 files changed, 4 insertions, 4 deletions
diff --git a/src/machine.rs b/src/machine.rs index deb3983..a58a754 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -694,7 +694,7 @@ where                  Ok(ControlToken::Continue)              }              Some(x) => { -                slf.emitter.init_attribute_name(slf.reader.position()); +                slf.emitter.init_attribute_name(slf.reader.position() - 1);                  slf.state = State::AttributeName;                  slf.unread_char(Some(x));                  Ok(ControlToken::Continue) @@ -747,7 +747,7 @@ where                  Ok(ControlToken::Eof)              }              Some(x) => { -                slf.emitter.init_attribute_name(slf.reader.position()); +                slf.emitter.init_attribute_name(slf.reader.position() - 1);                  slf.state = State::AttributeName;                  slf.unread_char(Some(x));                  Ok(ControlToken::Continue) @@ -775,7 +775,7 @@ where              }              c => {                  slf.emitter -                    .init_attribute_value(slf.reader.position(), false); +                    .init_attribute_value(slf.reader.position() - 1, false);                  slf.state = State::AttributeValueUnquoted;                  slf.unread_char(c);                  Ok(ControlToken::Continue) @@ -952,7 +952,7 @@ where              }              c => {                  slf.emit_error(Error::IncorrectlyOpenedComment); -                slf.emitter.init_comment(slf.reader.position()); +                slf.emitter.init_comment(slf.reader.position() - 1);                  slf.state = State::BogusComment;                  slf.unread_char(c);                  Ok(ControlToken::Continue)  | 
