From f74a7448036d6fbe3f6562aa6e87d7e7478f0341 Mon Sep 17 00:00:00 2001 From: David Robillard <d@drobilla.net> Date: Fri, 24 Feb 2023 20:44:32 -0500 Subject: Factor out serd_byte_source_skip_bom() --- src/reader.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'src/reader.c') diff --git a/src/reader.c b/src/reader.c index 85db9b0b..cfeaf0c0 100644 --- a/src/reader.c +++ b/src/reader.c @@ -309,23 +309,6 @@ serd_reader_free(SerdReader* const reader) serd_wfree(reader->world, reader); } -static SerdStatus -skip_bom(SerdReader* const me) -{ - if (serd_byte_source_peek(me->source) == 0xEF) { - if (serd_byte_source_advance(me->source) || - serd_byte_source_peek(me->source) != 0xBB || - serd_byte_source_advance(me->source) || - serd_byte_source_peek(me->source) != 0xBF || - serd_byte_source_advance(me->source)) { - r_err(me, SERD_BAD_SYNTAX, "corrupt byte order mark"); - return SERD_BAD_SYNTAX; - } - } - - return SERD_SUCCESS; -} - SerdStatus serd_reader_start(SerdReader* const reader, SerdInputStream* const input, @@ -354,7 +337,9 @@ serd_reader_prepare(SerdReader* const reader) { SerdStatus st = serd_byte_source_prepare(reader->source); if (st == SERD_SUCCESS) { - st = skip_bom(reader); + if ((st = serd_byte_source_skip_bom(reader->source))) { + r_err(reader, SERD_BAD_SYNTAX, "corrupt byte order mark"); + } } else if (st == SERD_FAILURE) { reader->source->eof = true; } -- cgit v1.2.1