From 155f5e2f24c24f5b5ffbf13fcea5cf1a355ec372 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 10 Oct 2020 12:31:29 +0200 Subject: [WIP] Simplify reader and writer flags [WIP] Testing? --- src/read_ntriples.c | 3 ++- src/read_turtle.c | 2 +- src/writer.c | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/read_ntriples.c b/src/read_ntriples.c index 6822b64f..7a43e4c2 100644 --- a/src/read_ntriples.c +++ b/src/read_ntriples.c @@ -240,7 +240,8 @@ read_STRING_LITERAL(SerdReader* const reader, static bool avoid_blank_clashes(const SerdReader* const reader) { - return reader->syntax == SERD_TURTLE || reader->syntax == SERD_TRIG; + return (reader->syntax == SERD_TURTLE || reader->syntax == SERD_TRIG) && + !(reader->flags & SERD_READ_VERBATIM); } static SerdStatus diff --git a/src/read_turtle.c b/src/read_turtle.c index 042393e0..613b33d2 100644 --- a/src/read_turtle.c +++ b/src/read_turtle.c @@ -372,7 +372,7 @@ read_IRIREF(SerdReader* const reader, SerdNode** const dest) return st; } - return (reader->flags & SERD_READ_RELATIVE) + return (reader->flags & SERD_READ_VERBATIM) ? SERD_SUCCESS : resolve_IRIREF(reader, *dest, string_start_offset); } diff --git a/src/writer.c b/src/writer.c index 31daa71c..fa1abd9f 100644 --- a/src/writer.c +++ b/src/writer.c @@ -801,10 +801,10 @@ write_literal(SerdWriter* const writer, SERD_NODISCARD static SerdStatus write_full_uri_node(SerdWriter* const writer, const SerdNode* const node) { - SerdStatus st = SERD_SUCCESS; - const bool resolve_disabled = writer->flags & SERD_WRITE_UNRESOLVED; + SerdStatus st = SERD_SUCCESS; + const bool verbatim = (writer->flags & SERD_WRITE_VERBATIM); - if (resolve_disabled || !serd_env_base_uri(writer->env)) { + if (verbatim || !serd_env_base_uri(writer->env)) { // Resolution disabled or we have no base URI, simply write the node TRY(st, esink("<", 1, writer)); TRY(st, write_uri_from_node(writer, node)); @@ -855,7 +855,7 @@ write_uri_node(SerdWriter* const writer, SerdStringView prefix = {NULL, 0}; SerdStringView suffix = {NULL, 0}; - if (has_scheme && !(writer->flags & SERD_WRITE_UNQUALIFIED) && + if (has_scheme && !(writer->flags & SERD_WRITE_EXPANDED) && !serd_env_qualify(writer->env, string, &prefix, &suffix)) { TRY(st, write_lname(writer, prefix.data, prefix.length)); TRY(st, esink(":", 1, writer)); -- cgit v1.2.1