From 19ae5b05161c19a23a35186588ec81bcbb515752 Mon Sep 17 00:00:00 2001 From: iska Date: Sat, 4 Oct 2014 21:56:22 +0200 Subject: [PATCH] Use explicit values for current-consumed characters in Input Stream Reader class --- HTMLKit/HTMLInputStreamReader.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/HTMLKit/HTMLInputStreamReader.m b/HTMLKit/HTMLInputStreamReader.m index d00d4da..bbe6bd3 100644 --- a/HTMLKit/HTMLInputStreamReader.m +++ b/HTMLKit/HTMLInputStreamReader.m @@ -50,15 +50,15 @@ - (UTF32Char)nextInputCharacter { - if (_location >= _string.length) return EOF; - - _consume = 1; + _consume = 0; UTF32Char nextInputCharacter = CFStringGetCharacterFromInlineBuffer(&_buffer, _location); - if (nextInputCharacter == 0) return EOF; + if (nextInputCharacter == 0 && _location >= _string.length) return EOF; + + _consume = 1; if (nextInputCharacter == CARRIAGE_RETURN) { UniChar next = CFStringGetCharacterFromInlineBuffer(&_buffer, _location + 1); - if (next == LINE_FEED) _consume++; + if (next == LINE_FEED) _consume = 2; return LINE_FEED; } if (CFStringIsSurrogateLowCharacter(nextInputCharacter)) {