aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-06-19 01:26:44 +0000
committerDavid Robillard <d@drobilla.net>2011-06-19 01:26:44 +0000
commitf2a4b931e85438381eb56051947cef58b364c3eb (patch)
tree097990bc120b60da9633d060b9030d7a89966a9a
parente52ac06922ca578807e61bb4bb5eed4ac626863a (diff)
downloadserd-f2a4b931e85438381eb56051947cef58b364c3eb.tar.gz
serd-f2a4b931e85438381eb56051947cef58b364c3eb.tar.bz2
serd-f2a4b931e85438381eb56051947cef58b364c3eb.zip
Fix abbreviation of repeated predicates with blank objects, and abbreviation memory errors (hopefully fix ticket #710).
Add example test from ticket #710 (as of this revision, this graph, tests/test-blank-cont.ttl, correctly serialises with serdi -i turtle -o turtle, though the indentation is a bit off...). git-svn-id: http://svn.drobilla.net/serd/trunk@205 490d8e77-9747-427b-9fa3-0b8f29cee8a0
-rw-r--r--src/writer.c6
-rw-r--r--tests/test-blank-cont.out4
-rw-r--r--tests/test-blank-cont.ttl4
3 files changed, 12 insertions, 2 deletions
diff --git a/src/writer.c b/src/writer.c
index a1004ca9..137fed93 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -394,12 +394,13 @@ serd_writer_write_statement(SerdWriter* writer,
WriteContext* ctx = (WriteContext*)serd_stack_push(
&writer->anon_stack, sizeof(WriteContext));
*ctx = writer->context;
+ writer->context = WRITE_CONTEXT_NULL; // Prevent deletion...
}
const WriteContext new_context = { serd_node_copy(graph),
serd_node_copy(subject),
serd_node_copy(predicate) };
- reset_context(writer);
+ reset_context(writer); // ... here
writer->context = new_context;
return SERD_SUCCESS;
}
@@ -420,11 +421,12 @@ serd_writer_end_anon(SerdWriter* writer,
--writer->indent;
serd_writer_write_delim(writer, '\n');
writer->sink("]", 1, writer->stream);
- const bool is_subject = serd_node_equals(node, &writer->context.subject);
reset_context(writer);
writer->context = *anon_stack_top(writer);
serd_stack_pop(&writer->anon_stack, sizeof(WriteContext));
+ const bool is_subject = serd_node_equals(node, &writer->context.subject);
if (is_subject) {
+ serd_node_free(&writer->context.predicate);
writer->context.subject = serd_node_copy(node);
writer->context.predicate = SERD_NODE_NULL;
}
diff --git a/tests/test-blank-cont.out b/tests/test-blank-cont.out
new file mode 100644
index 00000000..d64e3e46
--- /dev/null
+++ b/tests/test-blank-cont.out
@@ -0,0 +1,4 @@
+<http://example.org/base#subj> <http://example.org/base#pred> _:genid1 .
+_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/base#FirstThing> .
+<http://example.org/base#subj> <http://example.org/base#pred> _:genid2 .
+_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/base#SecondThing> .
diff --git a/tests/test-blank-cont.ttl b/tests/test-blank-cont.ttl
new file mode 100644
index 00000000..b161cdc4
--- /dev/null
+++ b/tests/test-blank-cont.ttl
@@ -0,0 +1,4 @@
+@prefix : <http://example.org/base#> .
+
+:subj :pred [ a :FirstThing ] ;
+ :pred [ a :SecondThing ] .