Mercurial > hg > xemacs-beta
comparison src/lstream.c @ 5785:7343a186a475
Correct some partial character accounting, buffered_bytecount_to_charcount().
src/ChangeLog addition:
2014-01-23 Aidan Kehoe <kehoea@parhasard.net>
* lstream.c (Lstream_read_1):
Don't include the unread partial character in
unget_character_count, since our consumers will never be aware of it.
* text.c:
* text.c (buffered_bytecount_to_charcount):
A buffer consisting entirely of a partial character needs to be
treated as a partial last character, not a partial first
character, to avoid double-counting.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 23 Jan 2014 13:49:40 +0000 |
parents | 0cb4f494a548 |
children | d2c0ff38ad5c |
comparison
equal
deleted
inserted
replaced
5784:0cb4f494a548 | 5785:7343a186a475 |
---|---|
719 character at the end. We need to spit back that | 719 character at the end. We need to spit back that |
720 incomplete character. */ | 720 incomplete character. */ |
721 Bytecount newoff = validate_ibyte_string_backward (p, off); | 721 Bytecount newoff = validate_ibyte_string_backward (p, off); |
722 if (newoff < off) | 722 if (newoff < off) |
723 { | 723 { |
724 Charcount before = lstr->unget_character_count; | |
724 Lstream_unread (lstr, p + newoff, off - newoff); | 725 Lstream_unread (lstr, p + newoff, off - newoff); |
725 off = newoff; | 726 off = newoff; |
727 | |
728 /* Since it's Lstream_read rather than our consumers unreading the | |
729 incomplete character (conceptually, not affecting the number of | |
730 characters ever Lstream_read() from the stream), | |
731 unget_character_count shouldn't include it. */ | |
732 lstr->unget_character_count = before; | |
726 } | 733 } |
727 } | 734 } |
728 | 735 |
729 return off == 0 && error_occurred ? -1 : off; | 736 return off == 0 && error_occurred ? -1 : off; |
730 } | 737 } |