aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/env.c16
-rw-r--r--src/writer.c10
-rw-r--r--tests/serd_test.c21
-rw-r--r--wscript2
4 files changed, 35 insertions, 14 deletions
diff --git a/src/env.c b/src/env.c
index 19e2abe8..e5cb954a 100644
--- a/src/env.c
+++ b/src/env.c
@@ -210,6 +210,13 @@ serd_env_expand_node(const SerdEnv* env,
const SerdNode* node)
{
switch (node->type) {
+ case SERD_NOTHING:
+ case SERD_LITERAL:
+ break;
+ case SERD_URI: {
+ SerdURI ignored;
+ return serd_node_new_uri_from_node(node, &env->base_uri, &ignored);
+ }
case SERD_CURIE: {
SerdChunk prefix;
SerdChunk suffix;
@@ -223,13 +230,10 @@ serd_env_expand_node(const SerdEnv* env,
ret.n_chars = serd_strlen(buf, NULL, NULL);
return ret;
}
- case SERD_URI: {
- SerdURI ignored;
- return serd_node_new_uri_from_node(node, &env->base_uri, &ignored);
- }
- default:
- return SERD_NODE_NULL;
+ case SERD_BLANK:
+ break;
}
+ return SERD_NODE_NULL;
}
void
diff --git a/src/writer.c b/src/writer.c
index 31050853..61ff9864 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -642,6 +642,8 @@ write_node(SerdWriter* writer,
{
bool ret = false;
switch (node->type) {
+ case SERD_NOTHING:
+ break;
case SERD_LITERAL:
ret = write_literal(writer, node, datatype, lang, flags);
break;
@@ -653,7 +655,7 @@ write_node(SerdWriter* writer,
break;
case SERD_BLANK:
ret = write_blank(writer, node, field, flags);
- default: break;
+ break;
}
writer->last_sep = SEP_NONE;
return ret;
@@ -715,9 +717,7 @@ serd_writer_write_statement(SerdWriter* writer,
} \
} while (0)
- switch (writer->syntax) {
- case SERD_NTRIPLES:
- case SERD_NQUADS:
+ if (writer->syntax == SERD_NTRIPLES || writer->syntax == SERD_NQUADS) {
TRY(write_node(writer, subject, NULL, NULL, FIELD_SUBJECT, flags));
sink(" ", 1, writer);
TRY(write_node(writer, predicate, NULL, NULL, FIELD_PREDICATE, flags));
@@ -729,8 +729,6 @@ serd_writer_write_statement(SerdWriter* writer,
}
sink(" .\n", 3, writer);
return SERD_SUCCESS;
- default:
- break;
}
if ((graph && !serd_node_equals(graph, &writer->context.graph)) ||
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 5e67eca1..2bf249b7 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -486,6 +486,10 @@ test_env(void)
const SerdNode lit = serd_node_from_string(SERD_LITERAL, USTR("hello"));
assert(serd_env_set_prefix(env, &b, &lit));
+ const SerdNode blank = serd_node_from_string(SERD_BLANK, USTR("b1"));
+ const SerdNode xblank = serd_env_expand_node(env, &blank);
+ assert(serd_node_equals(&xblank, &SERD_NODE_NULL));
+
int n_prefixes = 0;
serd_env_set_prefix_from_strings(env, USTR("eg.2"), USTR("http://example.org/"));
serd_env_foreach(env, count_prefixes, &n_prefixes);
@@ -588,6 +592,23 @@ test_writer(const char* const path)
assert(!strcmp((const char*)out, "@base <http://example.org/base> .\n"));
serd_free(out);
+
+ // Test writing empty node
+ SerdNode nothing = serd_node_from_string(SERD_NOTHING, USTR(""));
+ FILE* const empty = tmpfile();
+
+ writer = serd_writer_new(
+ SERD_TURTLE, (SerdStyle)0, env, NULL, serd_file_sink, empty);
+
+ // FIXME: error handling
+ serd_writer_write_statement(writer, 0, NULL,
+ &s, &p, &nothing, NULL, NULL);
+
+ assert((size_t)ftell(empty) == strlen("<>\n\t<http://example.org/pred> "));
+
+ serd_writer_free(writer);
+ fclose(empty);
+
serd_env_free(env);
fclose(fd);
}
diff --git a/wscript b/wscript
index 5617afa7..6ed66111 100644
--- a/wscript
+++ b/wscript
@@ -63,7 +63,6 @@ def configure(conf):
'-Wno-padded',
'-Wno-reserved-id-macro',
'-Wno-sign-conversion',
- '-Wno-switch-enum',
],
'gcc': [
'-Wno-cast-align',
@@ -74,7 +73,6 @@ def configure(conf):
'-Wno-sign-conversion',
'-Wno-suggest-attribute=const',
'-Wno-suggest-attribute=pure',
- '-Wno-switch-enum',
],
'msvc': [
'/wd4061', # enumerator in switch is not explicitly handled