aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
parent9910494d7bb417fb75f1c99b65f9956d14184059 (diff)
downloadserd-e3fd76d4e5beb8596be651b41be730f62cfdc9d0.tar.gz
serd-e3fd76d4e5beb8596be651b41be730f62cfdc9d0.tar.bz2
serd-e3fd76d4e5beb8596be651b41be730f62cfdc9d0.zip
Make URI writing stricter by default
Diffstat (limited to 'src')
-rw-r--r--src/serdi.c2
-rw-r--r--src/writer.c17
2 files changed, 11 insertions, 8 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 97e9bc22..d82198ad 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -89,7 +89,7 @@ print_usage(const char* const name, const bool error)
" -b Write output in blocks for performance.\n"
" -c PREFIX Chop PREFIX from matching blank node IDs.\n"
" -e Eat input one character at a time.\n"
- " -f Keep full URIs in input (don't qualify).\n"
+ " -f Fast and loose URI pass-through.\n"
" -h Display this help and exit.\n"
" -i SYNTAX Input syntax: turtle/ntriples/trig/nquads.\n"
" -l Lax (non-strict) parsing.\n"
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