diff options
author | David Robillard <d@drobilla.net> | 2011-03-02 08:49:23 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-03-02 08:49:23 +0000 |
commit | bb14fdecabb00dbda2740343f22ecb817dc52f47 (patch) | |
tree | fce60a5bb52ff4a770c7945a4f05f696dd771b1c /src/reader.c | |
parent | 5b72a58a2f0dc020bee2bba6b3b19d0a278dfd21 (diff) | |
download | serd-bb14fdecabb00dbda2740343f22ecb817dc52f47.tar.gz serd-bb14fdecabb00dbda2740343f22ecb817dc52f47.tar.bz2 serd-bb14fdecabb00dbda2740343f22ecb817dc52f47.zip |
Fix parsing several files/strings with the same parser.
Add serd_read_state_expand.
git-svn-id: http://svn.drobilla.net/serd/trunk@114 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/reader.c b/src/reader.c index b19ffcdc..904422b0 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1429,6 +1429,7 @@ serd_reader_read_file(SerdReader me, FILE* file, const uint8_t* name) me->read_head = 0; me->cur = cur; me->from_file = true; + me->eof = false; /* Read into the second page of the buffer. Occasionally peek_string will move the read_head to before this point when readahead causes @@ -1455,6 +1456,7 @@ serd_reader_read_string(SerdReader me, const uint8_t* utf8) me->read_head = 0; me->cur = cur; me->from_file = false; + me->eof = false; const bool ret = read_turtleDoc(me); @@ -1485,6 +1487,30 @@ serd_read_state_free(SerdReadState state) SERD_API SerdNode +serd_read_state_expand(SerdReadState state, + const SerdNode* node) +{ + if (node->type == SERD_CURIE) { + SerdChunk prefix; + SerdChunk suffix; + serd_env_expand(state->env, node, &prefix, &suffix); + SerdNode ret = { SERD_URI, + prefix.len + suffix.len + 1, + prefix.len + suffix.len, // FIXME: UTF-8 + NULL }; + ret.buf = malloc(ret.n_bytes); + snprintf((char*)ret.buf, ret.n_bytes, "%s%s", prefix.buf, suffix.buf); + return ret; + } else if (node->type == SERD_URI) { + SerdURI ignored; + return serd_node_new_uri_from_node(node, &state->base_uri, &ignored); + } else { + return SERD_NODE_NULL; + } +} + +SERD_API +SerdNode serd_read_state_get_base_uri(SerdReadState state, SerdURI* out) { |