aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-02-25 16:02:00 -0500
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commit74ddf7934336f16dcdce688333040d82972817fc (patch)
treef1c73da4a614dd7e7fd15762b0a772d56a341afe /src
parent02d56e83931e53e1cde57247c64d56fda3804f77 (diff)
downloadserd-74ddf7934336f16dcdce688333040d82972817fc.tar.gz
serd-74ddf7934336f16dcdce688333040d82972817fc.tar.bz2
serd-74ddf7934336f16dcdce688333040d82972817fc.zip
Move read_IRIREF to read_ntriples.c
Bit of a weird situation this one, since the rule is from NTriples but serd doesn't actually use it in the NTriples parser (since it uses a stricter one instead). Still, I think it makes sense here, and in practice, makes for a more sensible inlining situation.
Diffstat (limited to 'src')
-rw-r--r--src/read_ntriples.c21
-rw-r--r--src/read_ntriples.h4
-rw-r--r--src/read_turtle.c26
3 files changed, 31 insertions, 20 deletions
diff --git a/src/read_ntriples.c b/src/read_ntriples.c
index e5101522..c431574a 100644
--- a/src/read_ntriples.c
+++ b/src/read_ntriples.c
@@ -178,7 +178,7 @@ read_pct_encoded(SerdReader* const reader, SerdNode* const node)
return st;
}
-SerdStatus
+static SerdStatus
read_IRIREF_suffix(SerdReader* const reader, SerdNode* const node)
{
SerdStatus st = SERD_SUCCESS;
@@ -239,6 +239,25 @@ read_IRIREF_suffix(SerdReader* const reader, SerdNode* const node)
return st;
}
+// Note that read_IRI is used instead for NTriples, but this is used by Turtle
+SerdStatus
+read_IRIREF(SerdReader* const reader, SerdNode** const dest)
+{
+ SerdStatus st = SERD_SUCCESS;
+ TRY(st, eat_byte_check(reader, '<'));
+
+ if (!(*dest = push_node_head(reader, SERD_URI))) {
+ return SERD_BAD_STACK;
+ }
+
+ st = read_IRIREF_suffix(reader, *dest);
+ if (!tolerate_status(reader, st)) {
+ return st;
+ }
+
+ return push_node_tail(reader);
+}
+
/**
Read an absolute IRI.
diff --git a/src/read_ntriples.h b/src/read_ntriples.h
index 58daae0c..23934375 100644
--- a/src/read_ntriples.h
+++ b/src/read_ntriples.h
@@ -48,12 +48,12 @@ SerdStatus
read_EOL(SerdReader* reader);
/**
- Read an IRI reference suffix into an existing node.
+ Read a complete IRI reference.
RDF 1.1 NTriples: [8] IRIREF
*/
SerdStatus
-read_IRIREF_suffix(SerdReader* reader, SerdNode* node);
+read_IRIREF(SerdReader* reader, SerdNode** dest);
/**
Read a string that is single-quoted with the given character.
diff --git a/src/read_turtle.c b/src/read_turtle.c
index a041e873..e8e57dfc 100644
--- a/src/read_turtle.c
+++ b/src/read_turtle.c
@@ -360,23 +360,15 @@ resolve_IRIREF(SerdReader* const reader,
}
static SerdStatus
-read_IRIREF(SerdReader* const reader, SerdNode** const dest)
+read_IRI(SerdReader* const reader, SerdNode** const dest)
{
SerdStatus st = SERD_SUCCESS;
- TRY(st, eat_byte_check(reader, '<'));
- if (!(*dest = push_node_head(reader, SERD_URI))) {
- return SERD_BAD_STACK;
- }
-
- const size_t string_start_offset = reader->stack.size;
+ const size_t node_start_offset = reader->stack.size;
- st = read_IRIREF_suffix(reader, *dest);
- if (!tolerate_status(reader, st)) {
- return st;
- }
+ TRY(st, read_IRIREF(reader, dest));
- TRY(st, push_node_tail(reader));
+ const size_t string_start_offset = node_start_offset + sizeof(SerdNode);
return (reader->flags & SERD_READ_RELATIVE)
? st
@@ -516,7 +508,7 @@ read_turtle_iri(SerdReader* const reader,
bool* const ate_dot)
{
if (peek_byte(reader) == '<') {
- return read_IRIREF(reader, dest);
+ return read_IRI(reader, dest);
}
if (!(*dest = push_node_head(reader, SERD_LITERAL))) {
@@ -572,7 +564,7 @@ read_verb(SerdReader* reader, SerdNode** const dest)
case '?':
return read_Var(reader, dest);
case '<':
- return read_IRIREF(reader, dest);
+ return read_IRI(reader, dest);
}
/* Either a qname, or "a". Read the prefix first, and if it is in fact
@@ -747,7 +739,7 @@ read_object(SerdReader* const reader,
st = read_BLANK_NODE_LABEL(reader, &o, ate_dot);
break;
case '<':
- st = read_IRIREF(reader, &o);
+ st = read_IRI(reader, &o);
break;
case ':':
st = read_turtle_iri(reader, &o, ate_dot);
@@ -989,7 +981,7 @@ read_turtle_base(SerdReader* const reader, const bool sparql, const bool token)
read_turtle_ws_star(reader);
SerdNode* uri = NULL;
- TRY(st, read_IRIREF(reader, &uri));
+ TRY(st, read_IRI(reader, &uri));
if (reader->stack.size + sizeof(SerdNode) > reader->stack.buf_size) {
return SERD_BAD_STACK;
@@ -1035,7 +1027,7 @@ read_turtle_prefixID(SerdReader* const reader,
// Read URI node
SerdNode* uri = NULL;
- TRY(st, read_IRIREF(reader, &uri));
+ TRY(st, read_IRI(reader, &uri));
TRY(st,
serd_env_set_prefix(