diff options
Diffstat (limited to 'src/byte_source.c')
-rw-r--r-- | src/byte_source.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/byte_source.c b/src/byte_source.c index 727c655f..0e6ae2be 100644 --- a/src/byte_source.c +++ b/src/byte_source.c @@ -16,6 +16,7 @@ #include "byte_source.h" +#include "caret.h" #include "system.h" #include "serd/serd.h" @@ -52,11 +53,9 @@ serd_byte_source_open_source(SerdByteSource* const source, const SerdStreamErrorFunc error_func, const SerdStreamCloseFunc close_func, void* const stream, - const char* const name, + const SerdNode* const name, const size_t page_size) { - const Cursor cur = {name, 1, 1}; - memset(source, '\0', sizeof(*source)); source->read_func = read_func; source->error_func = error_func; @@ -64,7 +63,10 @@ serd_byte_source_open_source(SerdByteSource* const source, source->stream = stream; source->page_size = page_size; source->buf_size = page_size; - source->cur = cur; + source->name = serd_node_copy(name); + source->caret.file = source->name; + source->caret.line = 1u; + source->caret.col = 1u; source->from_stream = true; if (page_size > 1) { @@ -93,13 +95,19 @@ serd_byte_source_prepare(SerdByteSource* const source) SerdStatus serd_byte_source_open_string(SerdByteSource* const source, - const char* const utf8) + const char* const utf8, + const SerdNode* const name) { - const Cursor cur = {"(string)", 1, 1}; - memset(source, '\0', sizeof(*source)); - source->cur = cur; - source->read_buf = (const uint8_t*)utf8; + + source->name = + name ? serd_node_copy(name) : serd_new_string(SERD_STRING("string")); + + source->read_buf = (const uint8_t*)utf8; + source->caret.file = source->name; + source->caret.line = 1u; + source->caret.col = 1u; + return SERD_SUCCESS; } @@ -115,6 +123,7 @@ serd_byte_source_close(SerdByteSource* const source) serd_free_aligned(source->file_buf); } + serd_node_free(source->name); memset(source, '\0', sizeof(*source)); return st; } |