aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/serd/serd.h8
-rw-r--r--src/env.c2
-rw-r--r--src/reader.c2
-rw-r--r--src/writer.c13
-rw-r--r--test/test_env.c6
-rw-r--r--test/test_reader_writer.c8
6 files changed, 21 insertions, 18 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 941473ac..649217f3 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -643,8 +643,8 @@ serd_env_free(SerdEnv* SERD_NULLABLE env);
/// Get the current base URI
SERD_API
const SerdNode* SERD_NONNULL
-serd_env_get_base_uri(const SerdEnv* SERD_NONNULL env,
- SerdURIView* SERD_NULLABLE out);
+serd_env_base_uri(const SerdEnv* SERD_NONNULL env,
+ SerdURIView* SERD_NULLABLE out);
/// Set the current base URI
SERD_API
@@ -753,7 +753,7 @@ serd_reader_set_error_sink(SerdReader* SERD_NONNULL reader,
/// Return the `handle` passed to serd_reader_new()
SERD_PURE_API
void* SERD_NULLABLE
-serd_reader_get_handle(const SerdReader* SERD_NONNULL reader);
+serd_reader_handle(const SerdReader* SERD_NONNULL reader);
/**
Set a prefix to be added to all blank node identifiers.
@@ -886,7 +886,7 @@ serd_writer_free(SerdWriter* SERD_NULLABLE writer);
/// Return the env used by `writer`
SERD_PURE_API
SerdEnv* SERD_NONNULL
-serd_writer_get_env(SerdWriter* SERD_NONNULL writer);
+serd_writer_env(SerdWriter* SERD_NONNULL writer);
/**
A convenience sink function for writing to a FILE*.
diff --git a/src/env.c b/src/env.c
index 0538db69..caf50b08 100644
--- a/src/env.c
+++ b/src/env.c
@@ -62,7 +62,7 @@ serd_env_free(SerdEnv* env)
}
const SerdNode*
-serd_env_get_base_uri(const SerdEnv* env, SerdURIView* out)
+serd_env_base_uri(const SerdEnv* env, SerdURIView* out)
{
if (out) {
*out = env->base_uri;
diff --git a/src/reader.c b/src/reader.c
index fa84d7d7..9b4fe189 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -246,7 +246,7 @@ serd_reader_free(SerdReader* reader)
}
void*
-serd_reader_get_handle(const SerdReader* reader)
+serd_reader_handle(const SerdReader* reader)
{
return reader->handle;
}
diff --git a/src/writer.c b/src/writer.c
index 24c56895..89600e9c 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -579,6 +579,10 @@ write_uri_node(SerdWriter* const writer,
return sink("a", 1, writer) == 1;
}
+ if (!strcmp(node->buf, NS_RDF "nil")) {
+ return sink("()", 2, writer) == 2;
+ }
+
if (has_scheme && (writer->flags & SERD_WRITE_CURIED) &&
serd_env_qualify(writer->env, node, &prefix, &suffix) &&
is_name(suffix.buf, suffix.len)) {
@@ -590,7 +594,7 @@ write_uri_node(SerdWriter* const writer,
}
if (!has_scheme && !supports_uriref(writer) &&
- !serd_env_get_base_uri(writer->env, NULL)->buf) {
+ !serd_env_base_uri(writer->env, NULL)->buf) {
w_err(writer,
SERD_ERR_BAD_ARG,
"syntax does not support URI reference <%s>\n",
@@ -603,7 +607,7 @@ write_uri_node(SerdWriter* const writer,
SerdURIView in_base_uri;
SerdURIView uri;
SerdURIView abs_uri;
- serd_env_get_base_uri(writer->env, &in_base_uri);
+ serd_env_base_uri(writer->env, &in_base_uri);
serd_uri_parse(node->buf, &uri);
serd_uri_resolve(&uri, &in_base_uri, &abs_uri);
bool rooted = uri_is_under(&writer->base_uri, &writer->root_uri);
@@ -1006,7 +1010,7 @@ SerdStatus
serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri)
{
if (!serd_env_set_base_uri(writer->env, uri)) {
- serd_env_get_base_uri(writer->env, &writer->base_uri);
+ serd_env_base_uri(writer->env, &writer->base_uri);
if (writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG) {
if (writer->context.graph.type || writer->context.subject.type) {
@@ -1020,7 +1024,6 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri)
writer->indent = 0;
return reset_context(writer, true);
}
-
return SERD_ERR_UNKNOWN;
}
@@ -1080,7 +1083,7 @@ serd_writer_free(SerdWriter* writer)
}
SerdEnv*
-serd_writer_get_env(SerdWriter* writer)
+serd_writer_env(SerdWriter* writer)
{
return writer->env;
}
diff --git a/test/test_env.c b/test/test_env.c
index 6882ae62..336cbc55 100644
--- a/test/test_env.c
+++ b/test/test_env.c
@@ -42,7 +42,7 @@ test_env(void)
assert(!serd_env_set_base_uri(env, NULL));
assert(serd_env_set_base_uri(env, &SERD_NODE_NULL));
- assert(serd_node_equals(serd_env_get_base_uri(env, NULL), &SERD_NODE_NULL));
+ assert(serd_node_equals(serd_env_base_uri(env, NULL), &SERD_NODE_NULL));
SerdStringView prefix;
SerdStringView suffix;
@@ -82,9 +82,9 @@ test_env(void)
assert(!serd_env_qualify(env, &shorter_uri, &prefix_name, &suffix));
assert(!serd_env_set_base_uri(env, &u));
- assert(serd_node_equals(serd_env_get_base_uri(env, NULL), &u));
+ assert(serd_node_equals(serd_env_base_uri(env, NULL), &u));
assert(!serd_env_set_base_uri(env, NULL));
- assert(!serd_env_get_base_uri(env, NULL)->buf);
+ assert(!serd_env_base_uri(env, NULL)->buf);
serd_env_free(env);
}
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index d0301a87..7cb4066a 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -90,7 +90,7 @@ test_read_chunks(void)
serd_reader_new(SERD_TURTLE, rt, free, NULL, NULL, test_sink, NULL);
assert(reader);
- assert(serd_reader_get_handle(reader) == rt);
+ assert(serd_reader_handle(reader) == rt);
assert(f);
SerdStatus st = serd_reader_start_stream(reader, f, NULL, false);
@@ -146,7 +146,7 @@ test_read_string(void)
serd_reader_new(SERD_TURTLE, rt, free, NULL, NULL, test_sink, NULL);
assert(reader);
- assert(serd_reader_get_handle(reader) == rt);
+ assert(serd_reader_handle(reader) == rt);
// Test reading a string that ends exactly at the end of input (no newline)
const SerdStatus st =
@@ -179,7 +179,7 @@ test_writer(const char* const path)
assert(serd_writer_set_base_uri(writer, &lit));
assert(serd_writer_set_prefix(writer, &lit, &lit));
assert(serd_writer_end_anon(writer, NULL));
- assert(serd_writer_get_env(writer) == env);
+ assert(serd_writer_env(writer) == env);
uint8_t buf[] = {0xEF, 0xBF, 0xBD, 0};
SerdNode s = serd_node_from_string(SERD_URI, "");
@@ -281,7 +281,7 @@ test_reader(const char* path)
SerdReader* reader =
serd_reader_new(SERD_TURTLE, rt, free, NULL, NULL, test_sink, NULL);
assert(reader);
- assert(serd_reader_get_handle(reader) == rt);
+ assert(serd_reader_handle(reader) == rt);
SerdNode g = serd_node_from_string(SERD_URI, "http://example.org/");
serd_reader_set_default_graph(reader, &g);