mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-01 21:58:52 +00:00
encoding.c: Support calling peekc past the end of the buffer. This makes calling peekc easier.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user