aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-04-03 10:49:04 -0400
committerDavid Robillard <d@drobilla.net>2023-04-06 07:19:10 -0400
commite3fd76d4e5beb8596be651b41be730f62cfdc9d0 (patch)
tree2c55db64b3a2d0387173b7a210b3065247702018 /src/writer.c
parent9910494d7bb417fb75f1c99b65f9956d14184059 (diff)
downloadserd-e3fd76d4e5beb8596be651b41be730f62cfdc9d0.tar.gz
serd-e3fd76d4e5beb8596be651b41be730f62cfdc9d0.tar.bz2
serd-e3fd76d4e5beb8596be651b41be730f62cfdc9d0.zip
Make URI writing stricter by default
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/writer.c b/src/writer.c
index fcd0e1dc..8fdca6f9 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -677,19 +677,22 @@ write_curie(SerdWriter* const writer,
SerdChunk suffix = {NULL, 0};
SerdStatus st = SERD_SUCCESS;
- switch (writer->syntax) {
- case SERD_NTRIPLES:
- case SERD_NQUADS:
+ // In fast-and-loose Turtle/TriG mode CURIEs are simply passed through
+ const bool fast =
+ !(writer->style & (SERD_STYLE_CURIED | SERD_STYLE_RESOLVED));
+
+ if (!supports_abbrev(writer) || !fast) {
if ((st = serd_env_expand(writer->env, node, &prefix, &suffix))) {
return w_err(writer, st, "undefined namespace prefix '%s'\n", node->buf);
}
+ }
+
+ if (!supports_abbrev(writer)) {
TRY(st, esink("<", 1, writer));
write_uri(writer, prefix.buf, prefix.len);
write_uri(writer, suffix.buf, suffix.len);
TRY(st, esink(">", 1, writer));
- break;
- case SERD_TURTLE:
- case SERD_TRIG:
+ } else {
if (is_inline_start(writer, field, flags)) {
++writer->indent;
TRY(st, write_sep(writer, SEP_ANON_BEGIN));
@@ -702,7 +705,7 @@ write_curie(SerdWriter* const writer,
}
}
- return SERD_SUCCESS;
+ return st;
}
SERD_NODISCARD static SerdStatus