diff options
author | David Robillard <d@drobilla.net> | 2018-02-04 15:33:36 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:24 -0500 |
commit | b2b4fa05b73c6eee51ee9db59726fc404198111a (patch) | |
tree | ce2c1b9f0d6e460dde8d439d684598a6ebe1e703 /src/n3.c | |
parent | ecbc7584a09059ab5987dca95a998c88de8b479a (diff) | |
download | serd-b2b4fa05b73c6eee51ee9db59726fc404198111a.tar.gz serd-b2b4fa05b73c6eee51ee9db59726fc404198111a.tar.bz2 serd-b2b4fa05b73c6eee51ee9db59726fc404198111a.zip |
Make nodes opaque
Diffstat (limited to 'src/n3.c')
-rw-r--r-- | src/n3.c | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -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 |