diff options
-rw-r--r-- | src/env.c | 14 | ||||
-rw-r--r-- | src/env.h | 2 | ||||
-rw-r--r-- | src/writer.c | 3 |
3 files changed, 11 insertions, 8 deletions
@@ -247,13 +247,14 @@ serd_env_qualify(const SerdEnv* const env, const SerdNode* const uri) SerdStatus serd_env_expand_in_place(const SerdEnv* const env, - const SerdNode* const curie, + const SerdStringView curie, SerdStringView* const uri_prefix, SerdStringView* const uri_suffix) { - const char* const str = serd_node_string(curie); - const char* const colon = (const char*)memchr(str, ':', curie->length + 1); - if (curie->type != SERD_CURIE || !colon) { + const char* const str = curie.data; + const char* const colon = + str ? (const char*)memchr(str, ':', curie.length + 1) : NULL; + if (!colon) { return SERD_BAD_ARG; } @@ -263,7 +264,7 @@ serd_env_expand_in_place(const SerdEnv* const env, uri_prefix->data = serd_node_string(prefix->uri); uri_prefix->length = prefix->uri ? prefix->uri->length : 0; uri_suffix->data = colon + 1; - uri_suffix->length = curie->length - name_len - 1; + uri_suffix->length = curie.length - name_len - 1; return SERD_SUCCESS; } return SERD_BAD_CURIE; @@ -284,7 +285,8 @@ expand_curie(const SerdEnv* env, const SerdNode* node) SerdStringView prefix; SerdStringView suffix; - if (serd_env_expand_in_place(env, node, &prefix, &suffix)) { + if (serd_env_expand_in_place( + env, serd_node_string_view(node), &prefix, &suffix)) { return NULL; } @@ -28,7 +28,7 @@ serd_env_qualify_in_place(const SerdEnv* env, */ SerdStatus serd_env_expand_in_place(const SerdEnv* env, - const SerdNode* curie, + SerdStringView curie, SerdStringView* uri_prefix, SerdStringView* uri_suffix); diff --git a/src/writer.c b/src/writer.c index 42a6ded0..dc41d522 100644 --- a/src/writer.c +++ b/src/writer.c @@ -885,7 +885,8 @@ write_curie(SerdWriter* const writer, const SerdNode* const node) (writer->flags & (SERD_WRITE_UNQUALIFIED | SERD_WRITE_UNRESOLVED)); if (!supports_abbrev(writer) || !fast) { - if ((st = serd_env_expand_in_place(writer->env, node, &prefix, &suffix))) { + const SerdStringView curie = serd_node_string_view(node); + if ((st = serd_env_expand_in_place(writer->env, curie, &prefix, &suffix))) { return w_err(writer, st, "undefined namespace prefix '%s'\n", node_str); } } |