Skip to content

Commit

Permalink
Add comments explaining how we report the number of bytes written.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Dec 14, 2019
1 parent a86ddbd commit d07af8a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/wasi-common/src/sandboxed_tty_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ where
self.write_char('�')?;

if let Some(invalid_sequence_length) = error.error_len() {
// An invalid sequence was encountered. Tell the application we've
// written those bytes (though actually, we replaced them with U+FFFD).
result += invalid_sequence_length;
// Set up `input` to resume writing after the end of the sequence.
input = &after_valid[invalid_sequence_length..];
} else {
// The end of the buffer was encountered unexpectedly. Tell the application
// we've written out the remainder of the buffer.
result += after_valid.len();
break;
}
Expand Down

0 comments on commit d07af8a

Please sign in to comment.