aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.c')
-rw-r--r--src/reader.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/reader.c b/src/reader.c
index 5d8d1dbd..ee27a2fb 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -33,7 +33,7 @@
static SerdStatus serd_reader_prepare(SerdReader* reader);
-int
+SerdStatus
r_err(SerdReader* reader, SerdStatus st, const char* fmt, ...)
{
va_list args;
@@ -42,7 +42,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
@@ -111,11 +111,13 @@ 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 (!reader->sink->statement) {
+ return SERD_SUCCESS;
+ } else if (!graph && reader->default_graph) {
graph = reader->default_graph;
}
@@ -123,15 +125,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) {
@@ -302,7 +303,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