From 5443876d8e15c6ad011ede7d46ed36325a6cb282 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 25 Nov 2018 18:08:54 +0100 Subject: Remove reader status and handle errors more precisely --- src/byte_source.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/byte_source.h') diff --git a/src/byte_source.h b/src/byte_source.h index f88fa6c9..4dfff70f 100644 --- a/src/byte_source.h +++ b/src/byte_source.h @@ -87,13 +87,14 @@ serd_byte_source_advance(SerdByteSource* source) } if (source->from_stream) { - source->eof = false; if (source->page_size > 1) { if (++source->read_head == source->page_size) { + source->eof = false; st = serd_byte_source_page(source); } } else { if (!source->read_func(&source->read_byte, 1, 1, source->stream)) { + source->eof = true; st = source->error_func(source->stream) ? SERD_ERR_UNKNOWN : SERD_FAILURE; } @@ -102,7 +103,7 @@ serd_byte_source_advance(SerdByteSource* source) ++source->read_head; // Move to next character in string } - return source->eof ? SERD_FAILURE : st; + return st ? st : source->eof ? SERD_FAILURE : SERD_SUCCESS; } #endif // SERD_BYTE_SOURCE_H -- cgit v1.2.1