1 new commit in XEmacs:
https://bitbucket.org/xemacs/xemacs/commits/7343a186a475/
Changeset: 7343a186a475
User: kehoea
Date: 2014-01-23 14:49:40
Summary: Correct some partial character accounting,
buffered_bytecount_to_charcount().
src/ChangeLog addition:
2014-01-23 Aidan Kehoe <kehoea(a)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.
Affected #: 3 files
diff -r 0cb4f494a54809a054e242ee16c00c0e9c34d39d -r
7343a186a4757d2053e550dcb9299fd446970487 src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2014-01-23 Aidan Kehoe <kehoea(a)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.
+
2014-01-22 Aidan Kehoe <kehoea(a)parhasard.net>
* text.c (buffered_bytecount_to_charcount): New.
diff -r 0cb4f494a54809a054e242ee16c00c0e9c34d39d -r
7343a186a4757d2053e550dcb9299fd446970487 src/lstream.c
--- a/src/lstream.c
+++ b/src/lstream.c
@@ -721,8 +721,15 @@
Bytecount newoff = validate_ibyte_string_backward (p, off);
if (newoff < off)
{
+ Charcount before = lstr->unget_character_count;
Lstream_unread (lstr, p + newoff, off - newoff);
off = newoff;
+
+ /* Since it's Lstream_read rather than our consumers unreading the
+ incomplete character (conceptually, not affecting the number of
+ characters ever Lstream_read() from the stream),
+ unget_character_count shouldn't include it. */
+ lstr->unget_character_count = before;
}
}
diff -r 0cb4f494a54809a054e242ee16c00c0e9c34d39d -r
7343a186a4757d2053e550dcb9299fd446970487 src/text.c
--- a/src/text.c
+++ b/src/text.c
@@ -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
Repository URL:
https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches