diff options
author | David Robillard <d@drobilla.net> | 2021-07-11 16:42:00 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | 6076b31090176be685c30aa198edd3cebfd4fd7a (patch) | |
tree | 8e98c1dfe12ce6856ba7b338a538642c406915da /src/env.c | |
parent | 1321fefab48b4ced8f7f628211d5c16e40efd94f (diff) | |
download | serd-6076b31090176be685c30aa198edd3cebfd4fd7a.tar.gz serd-6076b31090176be685c30aa198edd3cebfd4fd7a.tar.bz2 serd-6076b31090176be685c30aa198edd3cebfd4fd7a.zip |
Make serd_env_expand_in_place() take a string view instead of a node
Diffstat (limited to 'src/env.c')
-rw-r--r-- | src/env.c | 14 |
1 files changed, 8 insertions, 6 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; } |