aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-10-23 22:11:35 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:07 -0500
commit38f85ad8c53c618033e3d0b7cb1fe782c38cf0a3 (patch)
tree8f5f1e7be38d98c9e354a67bdf7b94a3e35c3a60 /src/reader.c
parent3b89559e4c08202bee228e25ea42a4371e333c9b (diff)
downloadserd-38f85ad8c53c618033e3d0b7cb1fe782c38cf0a3.tar.gz
serd-38f85ad8c53c618033e3d0b7cb1fe782c38cf0a3.tar.bz2
serd-38f85ad8c53c618033e3d0b7cb1fe782c38cf0a3.zip
Add SerdCaret
Diffstat (limited to 'src/reader.c')
-rw-r--r--src/reader.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/reader.c b/src/reader.c
index 2ef3b66a..a9c483c0 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -11,6 +11,7 @@
#include "world.h"
#include "serd/stream.h"
+#include "serd/string_view.h"
#include "serd/uri.h"
#include <errno.h>
@@ -27,8 +28,7 @@ r_err(SerdReader* const reader, const SerdStatus st, const char* const fmt, ...)
{
va_list args; // NOLINT(cppcoreguidelines-init-variables)
va_start(args, fmt);
- const Cursor* const cur = &reader->source.cur;
- const SerdError e = {st, cur->filename, cur->line, cur->col, fmt, &args};
+ const SerdError e = {st, &reader->source.caret, fmt, &args};
serd_world_error(reader->world, &e);
va_end(args);
return st;
@@ -230,7 +230,7 @@ serd_reader_start_stream(SerdReader* const reader,
const SerdReadFunc read_func,
const SerdStreamErrorFunc error_func,
void* const stream,
- const char* const name,
+ const SerdNode* const name,
const size_t page_size)
{
return serd_byte_source_open_source(
@@ -251,20 +251,25 @@ serd_reader_start_file(SerdReader* reader, const char* uri, bool bulk)
return SERD_BAD_STREAM;
}
- return serd_byte_source_open_source(&reader->source,
- bulk ? (SerdReadFunc)fread
- : serd_file_read_byte,
- (SerdStreamErrorFunc)ferror,
- (SerdStreamCloseFunc)fclose,
- fd,
- uri,
- bulk ? SERD_PAGE_SIZE : 1);
+ SerdNode* const name = serd_new_uri(serd_string(uri));
+ const SerdStatus st = serd_byte_source_open_source(
+ &reader->source,
+ bulk ? (SerdReadFunc)fread : serd_file_read_byte,
+ (SerdStreamErrorFunc)ferror,
+ (SerdStreamCloseFunc)fclose,
+ fd,
+ name,
+ bulk ? SERD_PAGE_SIZE : 1U);
+ serd_node_free(name);
+ return st;
}
SerdStatus
-serd_reader_start_string(SerdReader* const reader, const char* const utf8)
+serd_reader_start_string(SerdReader* const reader,
+ const char* const utf8,
+ const SerdNode* const name)
{
- return serd_byte_source_open_string(&reader->source, utf8);
+ return serd_byte_source_open_string(&reader->source, utf8, name);
}
static SerdStatus