aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-07-05 21:01:12 +0200
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commit7515bb32246098af42bb105e9e1256ce1f6018ae (patch)
treef5845c842f119f5be747ac6dd86bb30bc8bd5ebc /src
parent8bc4e0d94cdcd7b05ec50533cb8b618e47eb13aa (diff)
downloadserd-7515bb32246098af42bb105e9e1256ce1f6018ae.tar.gz
serd-7515bb32246098af42bb105e9e1256ce1f6018ae.tar.bz2
serd-7515bb32246098af42bb105e9e1256ce1f6018ae.zip
Simplify writer style options
Diffstat (limited to 'src')
-rw-r--r--src/serdi.c23
-rw-r--r--src/writer.c6
2 files changed, 8 insertions, 21 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 8939ae3b..9bf42ac2 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -205,25 +205,10 @@ main(int argc, char** argv)
SerdWorld* world = serd_world_new();
SerdEnv* env = serd_env_new(base);
- SerdStyleFlags output_style = 0;
- if (output_syntax == SERD_NTRIPLES || ascii) {
- output_style |= SERD_STYLE_ASCII;
- } else if (output_syntax == SERD_TURTLE) {
- output_style |= SERD_STYLE_ABBREVIATED;
- if (!full_uris) {
- output_style |= SERD_STYLE_CURIED;
- }
- }
-
- if ((input_syntax == SERD_TURTLE || input_syntax == SERD_TRIG) ||
- (output_style & SERD_STYLE_CURIED)) {
- // Base URI may change and/or we're abbreviating URIs, so must resolve
- output_style |= SERD_STYLE_RESOLVED;
- }
-
- if (bulk_write) {
- output_style |= SERD_STYLE_BULK;
- }
+ const SerdStyleFlags output_style =
+ ((ascii ? SERD_STYLE_ASCII : 0) | //
+ (bulk_write ? SERD_STYLE_BULK : 0) | //
+ (full_uris ? (SERD_STYLE_UNQUALIFIED | SERD_STYLE_UNRESOLVED) : 0));
SerdWriter* writer = serd_writer_new(world,
output_syntax,
diff --git a/src/writer.c b/src/writer.c
index fc8f86b4..3e918a0c 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -512,7 +512,8 @@ write_uri_node(SerdWriter* const writer,
return sink("a", 1, writer) == 1;
} else if (supports_abbrev(writer) && !strcmp(node_str, NS_RDF "nil")) {
return sink("()", 2, writer) == 2;
- } else if (has_scheme && (writer->style & SERD_STYLE_CURIED) &&
+ } else if (has_scheme && supports_abbrev(writer) &&
+ !(writer->style & SERD_STYLE_UNQUALIFIED) &&
serd_env_qualify_in_place(writer->env, node, &prefix, &suffix) &&
is_name(serd_node_string(prefix), serd_node_length(prefix)) &&
is_name(suffix.buf, suffix.len)) {
@@ -523,7 +524,8 @@ write_uri_node(SerdWriter* const writer,
}
write_sep(writer, SEP_URI_BEGIN);
- if (writer->style & SERD_STYLE_RESOLVED) {
+ if (!(writer->style & SERD_STYLE_UNRESOLVED) &&
+ serd_env_base_uri(writer->env)) {
const SerdURI* base_uri = serd_env_get_parsed_base_uri(writer->env);
SerdURI uri;
SerdURI abs_uri;