Mercurial > hg > xemacs-beta
diff src/text.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 | 15041705c196 96fb76dd98df |
line wrap: on
line diff
--- a/src/text.c Wed Jan 22 17:52:00 2014 +0000 +++ b/src/text.c Thu Jan 23 13:49:40 2014 +0000 @@ -2244,9 +2244,9 @@ /* Return the character count of an lstream or coding buffer of internal-format text, counting partial characters at the beginning of the buffer as whole characters, and *not* counting partial characters at the - end of the buffer. This is because the result of this function is - subtracted from the character count given by the coding system character - tell methods, which include the former but not the latter. */ + end of the buffer. The result of this function is subtracted from the + character count given by the coding system character tell methods, and we + need to treat each buffer in the same way to avoid double-counting. */ Charcount buffered_bytecount_to_charcount (const Ibyte *bufptr, Bytecount len) @@ -2258,10 +2258,10 @@ { if (rep_bytes_by_first_byte (*bufptr) > len) { - /* This is a partial first character, include it. Return - immediately so validate_ibyte_string_backward doesn't run off - the beginning of the string. */ - return (Charcount) 1; + /* This is a partial last character. Return 0, avoid treating it + as a partial first character, since that would lead to it being + counted twice. */ + return (Charcount) 0; } } else