aboutsummaryrefslogtreecommitdiffstats
path: root/src/n3.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-02-04 15:33:36 +0100
committerDavid Robillard <d@drobilla.net>2021-03-07 15:32:24 -0500
commitb2b4fa05b73c6eee51ee9db59726fc404198111a (patch)
treece2c1b9f0d6e460dde8d439d684598a6ebe1e703 /src/n3.c
parentecbc7584a09059ab5987dca95a998c88de8b479a (diff)
downloadserd-b2b4fa05b73c6eee51ee9db59726fc404198111a.tar.gz
serd-b2b4fa05b73c6eee51ee9db59726fc404198111a.tar.bz2
serd-b2b4fa05b73c6eee51ee9db59726fc404198111a.zip
Make nodes opaque
Diffstat (limited to 'src/n3.c')
-rw-r--r--src/n3.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/n3.c b/src/n3.c
index e64cfc50..d5ee2832 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -15,6 +15,7 @@
*/
#include "byte_source.h"
+#include "node.h"
#include "reader.h"
#include "serd_internal.h"
#include "stack.h"
@@ -634,7 +635,8 @@ read_PN_PREFIX_tail(SerdReader* reader, Ref dest)
}
const SerdNode* const n = deref(reader, dest);
- if (n->buf[n->n_bytes - 1] == '.' && read_PN_CHARS(reader, dest)) {
+ if (serd_node_string(n)[n->n_bytes - 1] == '.' &&
+ read_PN_CHARS(reader, dest)) {
return r_err(reader, SERD_ERR_BAD_SYNTAX, "prefix ends with `.'\n");
}
@@ -958,8 +960,8 @@ read_verb(SerdReader* reader, Ref* dest)
bool ate_dot = false;
SerdNode* node = deref(reader, *dest);
const int next = peek_byte(reader);
- if (!st && node->n_bytes == 1 && node->buf[0] == 'a' && next != ':' &&
- !is_PN_CHARS_BASE((uint32_t)next)) {
+ if (!st && node->n_bytes == 1 && serd_node_string(node)[0] == 'a' &&
+ next != ':' && !is_PN_CHARS_BASE((uint32_t)next)) {
pop_node(reader, *dest);
*dest = push_node(reader, SERD_URI, NS_RDF "type", 47);
return SERD_SUCCESS;
@@ -1001,8 +1003,9 @@ read_BLANK_NODE_LABEL(SerdReader* reader, Ref* dest, bool* ate_dot)
}
}
- SerdNode* n = deref(reader, ref);
- if (n->buf[n->n_bytes - 1] == '.' && read_PN_CHARS(reader, ref)) {
+ SerdNode* n = deref(reader, ref);
+ char* buf = serd_node_buffer(n);
+ if (buf[n->n_bytes - 1] == '.' && read_PN_CHARS(reader, ref)) {
// Ate trailing dot, pop it from stack/node and inform caller
--n->n_bytes;
serd_stack_pop(&reader->stack, 1);
@@ -1010,11 +1013,11 @@ read_BLANK_NODE_LABEL(SerdReader* reader, Ref* dest, bool* ate_dot)
}
if (fancy_syntax(reader)) {
- if (is_digit(n->buf[reader->bprefix_len + 1])) {
- if ((n->buf[reader->bprefix_len]) == 'b') {
- ((char*)n->buf)[reader->bprefix_len] = 'B'; // Prevent clash
- reader->seen_genid = true;
- } else if (reader->seen_genid && n->buf[reader->bprefix_len] == 'B') {
+ if (is_digit(buf[reader->bprefix_len + 1])) {
+ if ((buf[reader->bprefix_len]) == 'b') {
+ buf[reader->bprefix_len] = 'B'; // Prevent clash
+ reader->seen_genid = true;
+ } else if (reader->seen_genid && buf[reader->bprefix_len] == 'B') {
*dest = pop_node(reader, *dest);
return r_err(reader,
SERD_ERR_ID_CLASH,
@@ -1171,8 +1174,8 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot)
while (!read_PN_CHARS_BASE(reader, o)) {
}
node = deref(reader, o);
- if ((node->n_bytes == 4 && !memcmp(node->buf, "true", 4)) ||
- (node->n_bytes == 5 && !memcmp(node->buf, "false", 5))) {
+ if ((node->n_bytes == 4 && !memcmp(serd_node_string(node), "true", 4)) ||
+ (node->n_bytes == 5 && !memcmp(serd_node_string(node), "false", 5))) {
node->type = SERD_LITERAL;
datatype = push_node(reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN);
ret = SERD_SUCCESS;
@@ -1554,7 +1557,7 @@ tokcmp(SerdReader* reader, Ref ref, const char* tok, size_t n)
return -1;
}
- return serd_strncasecmp(node->buf, tok, n);
+ return serd_strncasecmp(serd_node_string(node), tok, n);
}
SerdStatus