diff options
author | David Robillard <d@drobilla.net> | 2017-06-30 10:23:58 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-06-30 10:29:33 -0400 |
commit | 4024103b305911819df5b86a8f73b3e4d690e6b7 (patch) | |
tree | 618d6fbeb09033a3e36d41a56a8f62fb3dec5661 /src/reader.c | |
parent | 902d171c5e79561a534c3cbb9cc547cd1fadeab7 (diff) | |
download | serd-4024103b305911819df5b86a8f73b3e4d690e6b7.tar.gz serd-4024103b305911819df5b86a8f73b3e4d690e6b7.tar.bz2 serd-4024103b305911819df5b86a8f73b3e4d690e6b7.zip |
Fix spurious error message when parsing empty files
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/reader.c b/src/reader.c index 0ea95fcc..adb0a9ae 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1811,18 +1811,19 @@ serd_reader_read_file(SerdReader* reader, return ret; } -static bool +static SerdStatus skip_bom(SerdReader* me) { if (peek_byte(me) == 0xEF) { eat_byte_safe(me, 0xEF); if (eat_byte_check(me, 0xBB) != 0xBB || eat_byte_check(me, 0xBF) != 0xBF) { - return r_err(me, SERD_ERR_BAD_SYNTAX, "corrupt byte order mark\n"); + r_err(me, SERD_ERR_BAD_SYNTAX, "corrupt byte order mark\n"); + return SERD_ERR_BAD_SYNTAX; } } - return true; + return SERD_SUCCESS; } SERD_API @@ -1860,11 +1861,14 @@ serd_reader_start_source_stream(SerdReader* me, static SerdStatus serd_reader_prepare(SerdReader* me) { - me->eof = false; - if ((me->status = serd_byte_source_prepare(&me->source))) { + me->eof = false; + me->status = serd_byte_source_prepare(&me->source); + if (me->status == SERD_SUCCESS) { + me->status = skip_bom(me); + } else if (me->status == SERD_FAILURE) { + me->eof = true; + } else { r_err(me, me->status, "read error: %s\n", strerror(errno)); - } else if (!skip_bom(me)) { - me->status = SERD_ERR_BAD_SYNTAX; } return me->status; } |