diff options
author | David Robillard <d@drobilla.net> | 2020-11-14 11:18:42 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-14 11:52:30 +0100 |
commit | 6be4a34047af74c984dc644b4157da0b45c6dd83 (patch) | |
tree | dac1be8529296f847bafa9cae9f62e2e7247acdc /src | |
parent | d4973df7955bd0afac8260d40d11f5a72bacf4f3 (diff) | |
download | serd-6be4a34047af74c984dc644b4157da0b45c6dd83.tar.gz serd-6be4a34047af74c984dc644b4157da0b45c6dd83.tar.bz2 serd-6be4a34047af74c984dc644b4157da0b45c6dd83.zip |
Simplify abbreviated URI writing code
Diffstat (limited to 'src')
-rw-r--r-- | src/writer.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/writer.c b/src/writer.c index 10d5eed9..451b3e13 100644 --- a/src/writer.c +++ b/src/writer.c @@ -510,19 +510,20 @@ write_uri_node(SerdWriter* const writer, } const bool has_scheme = serd_uri_string_has_scheme(node->buf); - if (field == FIELD_PREDICATE && supports_abbrev(writer) - && !strcmp((const char*)node->buf, NS_RDF "type")) { - return sink("a", 1, writer) == 1; - } else if (supports_abbrev(writer) - && !strcmp((const char*)node->buf, NS_RDF "nil")) { - return sink("()", 2, writer) == 2; - } else if (has_scheme && (writer->style & SERD_STYLE_CURIED) && - serd_env_qualify(writer->env, node, &prefix, &suffix) && - is_name(suffix.buf, suffix.len)) { - write_uri(writer, prefix.buf, prefix.n_bytes); - sink(":", 1, writer); - write_uri(writer, suffix.buf, suffix.len); - return true; + if (supports_abbrev(writer)) { + if (field == FIELD_PREDICATE && + !strcmp((const char*)node->buf, NS_RDF "type")) { + return sink("a", 1, writer) == 1; + } else if (!strcmp((const char*)node->buf, NS_RDF "nil")) { + return sink("()", 2, writer) == 2; + } else if (has_scheme && (writer->style & SERD_STYLE_CURIED) && + serd_env_qualify(writer->env, node, &prefix, &suffix) && + is_name(suffix.buf, suffix.len)) { + write_uri(writer, prefix.buf, prefix.n_bytes); + sink(":", 1, writer); + write_uri(writer, suffix.buf, suffix.len); + return true; + } } write_sep(writer, SEP_URI_BEGIN); |