aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-08-12 23:38:52 -0400
committerDavid Robillard <d@drobilla.net>2022-01-28 21:57:07 -0500
commitfdf837b4b3baffc65e429c2e6ecc2e764bfed0ac (patch)
tree02e1f667d308c94c2657aab902f62b7712d7dea9 /src/writer.c
parent04ac8e8c12044da5befe0559eb36634babcf771a (diff)
downloadserd-fdf837b4b3baffc65e429c2e6ecc2e764bfed0ac.tar.gz
serd-fdf837b4b3baffc65e429c2e6ecc2e764bfed0ac.tar.bz2
serd-fdf837b4b3baffc65e429c2e6ecc2e764bfed0ac.zip
Fix TriG graph indentation
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/writer.c b/src/writer.c
index 3c7a510a..30e09a4f 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -114,7 +114,7 @@ static const SepRule rules[] = {
{"(", 1, +1, SEP_NONE, SEP_NONE, SEP_NONE},
{"", 0, +0, SEP_ALL, SEP_NONE, SEP_NONE},
{")", 1, -1, SEP_NONE, SEP_NONE, SEP_NONE},
- {"{", 1, +1, SEP_ALL, SEP_NONE, SEP_NONE},
+ {"{", 1, +1, SEP_ALL, SEP_NONE, SEP_ALL},
{"}", 1, -1, SEP_NONE, SEP_NONE, SEP_ALL},
};
@@ -707,14 +707,14 @@ write_sep(SerdWriter* writer, const SerdStatementFlags flags, Sep sep)
}
static void
-reset_context(SerdWriter* writer, bool graph)
+reset_context(SerdWriter* writer, const bool including_graph)
{
// Free any lingering contexts in case there was an error
while (writer->anon_stack_size > 0) {
pop_context(writer);
}
- if (graph && writer->context.graph) {
+ if (including_graph && writer->context.graph) {
memset(writer->context.graph, 0, sizeof(SerdNode));
}
@@ -728,8 +728,11 @@ reset_context(SerdWriter* writer, bool graph)
writer->anon_stack_size = 0;
writer->context.indented_object = false;
- writer->indent = 0;
writer->empty = false;
+
+ if (including_graph) {
+ writer->indent = 0;
+ }
}
static bool
@@ -1123,7 +1126,9 @@ write_turtle_trig_statement(SerdWriter* const writer,
}
// Write new subject
- TRY(st, write_top_level_sep(writer));
+ if (!ctx(writer, SERD_GRAPH)) {
+ TRY(st, write_top_level_sep(writer));
+ }
reset_context(writer, false);
serd_node_set(&writer->context.subject, subject);
TRY(st, write_node(writer, subject, SERD_SUBJECT, flags));