encoding.c: Support calling peekc past the end of the buffer. This makes calling peekc easier.

This commit is contained in:
Reece H. Dunn
2017-04-26 07:48:34 +01:00
parent 3f692f498b
commit b897ff5aa8
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -803,6 +803,8 @@ text_decoder_getc(espeak_ng_TEXT_DECODER *decoder)
uint32_t
text_decoder_peekc(espeak_ng_TEXT_DECODER *decoder)
{
if (decoder->current == decoder->end) return 0;
const uint8_t *current = decoder->current;
uint32_t c = decoder->get(decoder);
decoder->current = current;
+4
View File
@@ -866,6 +866,10 @@ test_peekc()
assert(text_decoder_getc(decoder) == 'd');
assert(text_decoder_eof(decoder) == 1);
// Calling peekc past the end of the buffer.
assert(text_decoder_peekc(decoder) == '\0');
assert(text_decoder_eof(decoder) == 1);
destroy_text_decoder(decoder);
}