diff options
author | David Robillard <d@drobilla.net> | 2018-12-26 20:04:27 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | 9c00583bd37522a4f1703bf289587b4546edcf53 (patch) | |
tree | 745b6fd07df09ab2a5d6eb7119951dcbb9674e5d | |
parent | 6ea89ed78d344d01de4566ae7cc690c0cfe5673e (diff) | |
download | serd-9c00583bd37522a4f1703bf289587b4546edcf53.tar.gz serd-9c00583bd37522a4f1703bf289587b4546edcf53.tar.bz2 serd-9c00583bd37522a4f1703bf289587b4546edcf53.zip |
Remove serd_reader_set_default_graph()
-rw-r--r-- | include/serd/reader.h | 12 | ||||
-rw-r--r-- | src/reader.c | 29 | ||||
-rw-r--r-- | src/reader.h | 1 | ||||
-rw-r--r-- | test/test_reader_writer.c | 21 |
4 files changed, 14 insertions, 49 deletions
diff --git a/include/serd/reader.h b/include/serd/reader.h index 26641801..aedc5cb3 100644 --- a/include/serd/reader.h +++ b/include/serd/reader.h @@ -5,7 +5,6 @@ #define SERD_READER_H #include "serd/attributes.h" -#include "serd/node.h" #include "serd/sink.h" #include "serd/status.h" #include "serd/stream.h" @@ -57,17 +56,6 @@ SERD_API void serd_reader_add_blank_prefix(SerdReader* SERD_NONNULL reader, const char* SERD_NULLABLE prefix); -/** - Set the URI of the default graph. - - If this is set, the reader will emit quads with the graph set to the given - node for any statements that are not in a named graph (which is currently - all of them since Serd currently does not support any graph syntaxes). -*/ -SERD_API void -serd_reader_set_default_graph(SerdReader* SERD_NONNULL reader, - const SerdNode* SERD_NULLABLE graph); - /// Prepare to read from the file at a local file `uri` SERD_API SerdStatus serd_reader_start_file(SerdReader* SERD_NONNULL reader, diff --git a/src/reader.c b/src/reader.c index 90fee2db..2ef3b66a 100644 --- a/src/reader.c +++ b/src/reader.c @@ -110,11 +110,6 @@ emit_statement(SerdReader* const reader, const ReadContext ctx, SerdNode* const o) { - SerdNode* graph = ctx.graph; - if (!graph && reader->default_graph) { - graph = reader->default_graph; - } - if (reader->stack.size + (2 * sizeof(SerdNode)) > reader->stack.buf_size) { return SERD_BAD_STACK; } @@ -124,7 +119,7 @@ emit_statement(SerdReader* const reader, serd_node_zero_pad(o); const SerdStatus st = serd_sink_write( - reader->sink, *ctx.flags, ctx.subject, ctx.predicate, o, graph); + reader->sink, *ctx.flags, ctx.subject, ctx.predicate, o, ctx.graph); *ctx.flags &= SERD_ANON_CONT | SERD_LIST_CONT; // Preserve only cont flags return st; @@ -156,13 +151,12 @@ serd_reader_new(SerdWorld* const world, SerdReader* me = (SerdReader*)calloc(1, sizeof(SerdReader)); - me->world = world; - me->sink = sink; - me->default_graph = NULL; - me->stack = serd_stack_new(stack_size); - me->syntax = syntax; - me->next_id = 1; - me->strict = true; + me->world = world; + me->sink = sink; + me->stack = serd_stack_new(stack_size); + me->syntax = syntax; + me->next_id = 1; + me->strict = true; // Reserve a bit of space at the end of the stack to zero pad nodes me->stack.buf_size -= serd_node_align; @@ -193,7 +187,6 @@ serd_reader_free(SerdReader* const reader) } serd_reader_finish(reader); - serd_node_free(reader->default_graph); free(reader->stack.buf); free(reader->bprefix); @@ -215,14 +208,6 @@ serd_reader_add_blank_prefix(SerdReader* const reader, const char* const prefix) } } -void -serd_reader_set_default_graph(SerdReader* const reader, - const SerdNode* const graph) -{ - serd_node_free(reader->default_graph); - reader->default_graph = serd_node_copy(graph); -} - static SerdStatus skip_bom(SerdReader* const me) { diff --git a/src/reader.h b/src/reader.h index 28889307..bded249a 100644 --- a/src/reader.h +++ b/src/reader.h @@ -40,7 +40,6 @@ struct SerdReaderImpl { SerdNode* rdf_first; SerdNode* rdf_rest; SerdNode* rdf_nil; - SerdNode* default_graph; SerdByteSource source; SerdStack stack; SerdSyntax syntax; diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index c634bc79..062f65fc 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -35,11 +35,10 @@ typedef struct { } ErrorContext; typedef struct { - int n_base; - int n_prefix; - int n_statement; - int n_end; - const SerdNode* graph; + int n_base; + int n_prefix; + int n_statement; + int n_end; } ReaderTest; static const char* const doc_string = @@ -94,6 +93,7 @@ test_statement_sink(void* handle, const SerdNode* predicate, const SerdNode* object) { + (void)graph; (void)flags; (void)subject; (void)predicate; @@ -101,7 +101,6 @@ test_statement_sink(void* handle, ReaderTest* rt = (ReaderTest*)handle; ++rt->n_statement; - rt->graph = graph; return SERD_SUCCESS; } @@ -553,7 +552,7 @@ static void test_reader(const char* path) { SerdWorld* world = serd_world_new(); - ReaderTest rt = {0, 0, 0, 0, NULL}; + ReaderTest rt = {0, 0, 0, 0}; SerdSink* const sink = serd_sink_new(&rt, NULL); assert(sink); @@ -571,8 +570,6 @@ test_reader(const char* path) assert(serd_reader_read_chunk(reader) == SERD_FAILURE); assert(serd_reader_read_document(reader) == SERD_FAILURE); - SerdNode* g = serd_new_uri(serd_string("http://example.org/")); - serd_reader_set_default_graph(reader, g); serd_reader_add_blank_prefix(reader, "tmp"); #if defined(__GNUC__) @@ -584,8 +581,6 @@ test_reader(const char* path) # pragma GCC diagnostic pop #endif - serd_node_free(g); - assert(serd_reader_start_file(reader, "http://notafile", false)); assert(serd_reader_start_file(reader, "file://invalid", false)); assert(serd_reader_start_file(reader, "file:///nonexistant", false)); @@ -596,9 +591,7 @@ test_reader(const char* path) assert(rt.n_prefix == 0); assert(rt.n_statement == 6); assert(rt.n_end == 0); - assert(rt.graph && serd_node_string(rt.graph) && - !strcmp(serd_node_string(rt.graph), "http://example.org/")); - serd_reader_finish(reader); + assert(!serd_reader_finish(reader)); // A read of a big page hits EOF then fails to read chunks immediately { |