From d65769b7b9ad6a8c9c75f8fd96f929f8a2938774 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 30 Sep 2020 12:11:54 +0200 Subject: Simplify reader byte reading interface This eliminates eat_byte() and the way it conflates the status of advancing the source with the current character, which can cause problems with custom sinks. --- src/reader.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/reader.h b/src/reader.h index 69e632e8..9de37f4c 100644 --- a/src/reader.h +++ b/src/reader.h @@ -121,22 +121,15 @@ peek_byte(SerdReader* reader) return source->eof ? EOF : (int)source->read_buf[source->read_head]; } -static inline int -eat_byte(SerdReader* reader) -{ - const int c = peek_byte(reader); - const SerdStatus st = serd_byte_source_advance(&reader->source); - - return st > SERD_FAILURE ? EOF : c; -} - static inline int eat_byte_safe(SerdReader* reader, const int byte) { (void)byte; - const int c = eat_byte(reader); + const int c = peek_byte(reader); assert(c == byte); + + serd_byte_source_advance(&reader->source); return c; } -- cgit v1.2.1