diff options
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/reader.c b/src/reader.c index 4c448de6..0bc5927f 100644 --- a/src/reader.c +++ b/src/reader.c @@ -30,7 +30,7 @@ static SerdStatus serd_reader_prepare(SerdReader* reader); -int +SerdStatus r_err(SerdReader* reader, SerdStatus st, const char* fmt, ...) { va_list args; @@ -39,7 +39,7 @@ r_err(SerdReader* reader, SerdStatus st, const char* fmt, ...) const SerdError e = { st, cur->filename, cur->line, cur->col, fmt, &args }; serd_world_error(reader->world, &e); va_end(args); - return 0; + return st; } void @@ -108,11 +108,15 @@ push_node(SerdReader* reader, SerdType type, const char* str, size_t n_bytes) return push_node_padded(reader, n_bytes, type, str, n_bytes); } -bool +SerdStatus emit_statement(SerdReader* reader, ReadContext ctx, SerdNode* o) { SerdNode* graph = ctx.graph; - if (!graph && reader->default_graph) { + if (!o) { + return SERD_ERR_BAD_SYNTAX; + } else if (!reader->sink->statement) { + return SERD_SUCCESS; + } else if (!graph && reader->default_graph) { graph = reader->default_graph; } @@ -120,15 +124,14 @@ emit_statement(SerdReader* reader, ReadContext ctx, SerdNode* o) (subject and predicate) were already zeroed by subsequent pushes. */ serd_node_zero_pad(o); - bool ret = !reader->sink->statement || - !reader->sink->statement( - reader->sink->handle, *ctx.flags, graph, - ctx.subject, ctx.predicate, o); + const SerdStatus st = reader->sink->statement( + reader->sink->handle, *ctx.flags, graph, + ctx.subject, ctx.predicate, o); *ctx.flags &= SERD_ANON_CONT|SERD_LIST_CONT; // Preserve only cont flags - return ret; + return st; } -static bool +static SerdStatus read_statement(SerdReader* reader) { switch (reader->syntax) { @@ -298,7 +301,7 @@ serd_reader_read_chunk(SerdReader* reader) st = serd_byte_source_advance(&reader->source); } - return st ? st : read_statement(reader) ? SERD_SUCCESS : SERD_FAILURE; + return st ? st : read_statement(reader); } SerdStatus |