diff options
author | David Robillard <d@drobilla.net> | 2019-03-10 16:44:22 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | 1c7a8efa90003d21e19b47bbad185390cea5963c (patch) | |
tree | e4b5ceaf2ff9f19d4c6c59765808d014ae87ff01 | |
parent | 99141be3df23c17ab219c08c8e496c4bb41297e6 (diff) | |
download | serd-1c7a8efa90003d21e19b47bbad185390cea5963c.tar.gz serd-1c7a8efa90003d21e19b47bbad185390cea5963c.tar.bz2 serd-1c7a8efa90003d21e19b47bbad185390cea5963c.zip |
Pass context flags to write_sep()
-rw-r--r-- | src/writer.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/writer.c b/src/writer.c index 9fd0110e..19ce926b 100644 --- a/src/writer.c +++ b/src/writer.c @@ -595,8 +595,10 @@ write_newline(SerdWriter* writer) } SERD_NODISCARD static SerdStatus -write_sep(SerdWriter* writer, const Sep sep) +write_sep(SerdWriter* writer, const SerdStatementFlags flags, Sep sep) { + (void)flags; + SerdStatus st = SERD_SUCCESS; const SepRule* const rule = &rules[sep]; @@ -852,12 +854,12 @@ write_blank(SerdWriter* const writer, if (supports_abbrev(writer)) { if ((field == SERD_SUBJECT && (flags & SERD_ANON_S)) || (field == SERD_OBJECT && (flags & SERD_ANON_O))) { - return write_sep(writer, SEP_ANON_BEGIN); + return write_sep(writer, flags, SEP_ANON_BEGIN); } if ((field == SERD_SUBJECT && (flags & SERD_LIST_S)) || (field == SERD_OBJECT && (flags & SERD_LIST_O))) { - return write_sep(writer, SEP_LIST_BEGIN); + return write_sep(writer, flags, SEP_LIST_BEGIN); } if ((field == SERD_SUBJECT && (flags & SERD_EMPTY_S)) || @@ -922,7 +924,7 @@ write_pred(SerdWriter* writer, SerdStatementFlags flags, const SerdNode* pred) SerdStatus st = SERD_SUCCESS; TRY(st, write_node(writer, pred, SERD_PREDICATE, flags)); - TRY(st, write_sep(writer, SEP_P_O)); + TRY(st, write_sep(writer, flags, SEP_P_O)); serd_node_set(&writer->context.predicate, pred); writer->context.predicates = true; @@ -939,14 +941,14 @@ write_list_next(SerdWriter* const writer, SerdStatus st = SERD_SUCCESS; if (!strcmp(serd_node_string(object), NS_RDF "nil")) { - TRY(st, write_sep(writer, SEP_LIST_END)); + TRY(st, write_sep(writer, writer->context.flags, SEP_LIST_END)); return SERD_FAILURE; } if (!strcmp(serd_node_string(predicate), NS_RDF "first")) { TRY(st, write_node(writer, object, SERD_OBJECT, flags)); } else { - TRY(st, write_sep(writer, SEP_LIST_SEP)); + TRY(st, write_sep(writer, writer->context.flags, SEP_LIST_SEP)); } return st; @@ -958,11 +960,11 @@ terminate_context(SerdWriter* writer) SerdStatus st = SERD_SUCCESS; if (ctx(writer, SERD_SUBJECT)) { - TRY(st, write_sep(writer, SEP_END_S)); + TRY(st, write_sep(writer, writer->context.flags, SEP_END_S)); } if (ctx(writer, SERD_GRAPH)) { - TRY(st, write_sep(writer, SEP_GRAPH_END)); + TRY(st, write_sep(writer, writer->context.flags, SEP_GRAPH_END)); } return st; @@ -1013,7 +1015,7 @@ serd_writer_write_statement(SerdWriter* const writer, if (graph) { TRY(st, write_newline(writer)); TRY(st, write_node(writer, graph, SERD_GRAPH, flags)); - TRY(st, write_sep(writer, SEP_GRAPH_BEGIN)); + TRY(st, write_sep(writer, flags, SEP_GRAPH_BEGIN)); serd_node_set(&writer->context.graph, graph); } } @@ -1043,6 +1045,7 @@ serd_writer_write_statement(SerdWriter* const writer, TRY(st, write_sep(writer, + flags, after_end ? (open_o ? SEP_JOIN_O_AA : SEP_JOIN_O_AN) : (open_o ? SEP_JOIN_O_NA : SEP_END_O))); @@ -1055,7 +1058,7 @@ serd_writer_write_statement(SerdWriter* const writer, } const bool first = !ctx(writer, SERD_PREDICATE); - TRY(st, write_sep(writer, first ? SEP_S_P : SEP_END_P)); + TRY(st, write_sep(writer, flags, first ? SEP_S_P : SEP_END_P)); TRY(st, write_pred(writer, flags, predicate)); } @@ -1065,7 +1068,7 @@ serd_writer_write_statement(SerdWriter* const writer, // No abbreviation if (serd_stack_is_empty(&writer->anon_stack)) { if (ctx(writer, SERD_SUBJECT)) { - TRY(st, write_sep(writer, SEP_END_S)); + TRY(st, write_sep(writer, flags, SEP_END_S)); } if (writer->last_sep == SEP_END_S || writer->last_sep == SEP_END_DIRECT) { @@ -1074,13 +1077,13 @@ serd_writer_write_statement(SerdWriter* const writer, TRY(st, write_node(writer, subject, SERD_SUBJECT, flags)); if ((flags & (SERD_ANON_S | SERD_LIST_S))) { - TRY(st, write_sep(writer, SEP_ANON_S_P)); + TRY(st, write_sep(writer, flags, SEP_ANON_S_P)); } else { - TRY(st, write_sep(writer, SEP_S_P)); + TRY(st, write_sep(writer, flags, SEP_S_P)); } } else { - TRY(st, write_sep(writer, SEP_ANON_S_P)); + TRY(st, write_sep(writer, flags, SEP_ANON_S_P)); } reset_context(writer, 0U); @@ -1133,7 +1136,7 @@ serd_writer_end_anon(SerdWriter* writer, const SerdNode* node) } // Write the end separator ']' and pop the context - TRY(st, write_sep(writer, SEP_ANON_END)); + TRY(st, write_sep(writer, writer->context.flags, SEP_ANON_END)); pop_context(writer); if (writer->context.predicate && @@ -1240,7 +1243,7 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri) TRY(st, esink(uri_string.data, uri_string.length, writer)); TRY(st, esink(">", 1, writer)); writer->last_sep = SEP_NODE; - TRY(st, write_sep(writer, SEP_END_DIRECT)); + TRY(st, write_sep(writer, writer->context.flags, SEP_END_DIRECT)); } return reset_context(writer, RESET_GRAPH | RESET_INDENT); @@ -1280,7 +1283,7 @@ serd_writer_set_prefix(SerdWriter* writer, TRY(st, ewrite_uri(writer, serd_node_string(uri), uri->length)); TRY(st, esink(">", 1, writer)); writer->last_sep = SEP_NODE; - TRY(st, write_sep(writer, SEP_END_DIRECT)); + TRY(st, write_sep(writer, writer->context.flags, SEP_END_DIRECT)); } return reset_context(writer, RESET_GRAPH | RESET_INDENT); |