Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix STREAM-UNREAD-CHAR #38

Merged
merged 1 commit into from
Aug 13, 2017
Merged

fix STREAM-UNREAD-CHAR #38

merged 1 commit into from
Aug 13, 2017

Conversation

fboundp
Copy link

@fboundp fboundp commented Aug 12, 2017

In STREAM-READ-CHAR, the first value returned from the
BABEL:CODE-POINT-COUNTER function was used to track
LAST-CHAR-SIZE (the number of bytes consumed while reading a
character). However, it is actually the number of characters decoded,
and for this particular call, it is always 1. As a result, a later
STREAM-UNREAD-CHAR of a multibyte character will cause BUFFER-POSITION
to point into the middle of the encoded byte sequence, ultimately
leading to a decoding error.

Instead, use the second value returned from the
BABEL:CODE-POINT-COUNTER function, the position in the buffer to start
the next decoding, and compute LAST-CHAR-SIZE using its difference
from BUFFER-POSITION.

In STREAM-READ-CHAR, the first value returned from the
BABEL:CODE-POINT-COUNTER function was used to track
LAST-CHAR-SIZE (the number of bytes consumed while reading a
character). However, it is actually the number of characters decoded,
and for this particular call, it is always 1. As a result, a later
STREAM-UNREAD-CHAR of a multibyte character will cause BUFFER-POSITION
to point into the middle of the encoded byte sequence, ultimately
leading to a decoding error.

Instead, use the second value returned from the
BABEL:CODE-POINT-COUNTER function, the position in the buffer to start
the next decoding, and compute LAST-CHAR-SIZE using its difference
from BUFFER-POSITION.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 70.892% when pulling c8ef342 on nconcio:unread-char-fix into ca24e01 on fukamachi:master.

@fukamachi fukamachi merged commit 501f466 into fukamachi:master Aug 13, 2017
@fukamachi
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants