aboutsummaryrefslogtreecommitdiffstats
path: root/src/read_trig.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-12-01 20:39:44 -0500
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commit02d56e83931e53e1cde57247c64d56fda3804f77 (patch)
tree2d1ac467bc56f4f4f3570497427be32d7e36bd1a /src/read_trig.c
parentd094448c095a59117febc8bd4687df071ce9759a (diff)
downloadserd-02d56e83931e53e1cde57247c64d56fda3804f77.tar.gz
serd-02d56e83931e53e1cde57247c64d56fda3804f77.tar.bz2
serd-02d56e83931e53e1cde57247c64d56fda3804f77.zip
[WIP] Tighten up reader node management
[WIP] Broken on 32-bit This makes the reader stack manipulations stricter, to make the code more regular and avoid redundant work and bad cache activity. Now, functions that push node headers and their bodies are responsible for (more or less) immediately pushing any trailing null bytes required for termination and alignment. This makes the writes to the node in the stack more local, ensures nodes are terminated as early as possible (to reduce the risk of using non-terminated strings), and avoids the need to calculate aligned stack allocations.
Diffstat (limited to 'src/read_trig.c')
-rw-r--r--src/read_trig.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/read_trig.c b/src/read_trig.c
index e3d7a7e9..76a693ec 100644
--- a/src/read_trig.c
+++ b/src/read_trig.c
@@ -83,16 +83,20 @@ read_sparql_directive(SerdReader* const reader,
ReadContext* const ctx,
const SerdNode* const token)
{
+ SerdStatus st = SERD_SUCCESS;
+
if (!tokcmp(token, "base", 4)) {
+ TRY(st, push_node_tail(reader));
return read_turtle_base(reader, true, false);
}
if (!tokcmp(token, "prefix", 6)) {
+ TRY(st, push_node_tail(reader));
return read_turtle_prefixID(reader, true, false);
}
if (!tokcmp(token, "graph", 5)) {
- SerdStatus st = SERD_SUCCESS;
+ TRY(st, push_node_tail(reader));
read_turtle_ws_star(reader);
TRY(st, read_labelOrSubject(reader, &ctx->graph));
read_turtle_ws_star(reader);
@@ -165,7 +169,7 @@ read_trig_statement(SerdReader* const reader)
return SERD_FAILURE;
case '\0':
- eat_byte(reader);
+ skip_byte(reader, '\0');
return SERD_FAILURE;
case '@':
@@ -185,7 +189,7 @@ read_trig_statement(SerdReader* const reader)
SerdStatus
read_trigDoc(SerdReader* const reader)
{
- while (!reader->source->eof) {
+ while (!reader->source.eof) {
const size_t orig_stack_size = reader->stack.size;
const SerdStatus st = read_trig_statement(reader);