diff options
author | David Robillard <d@drobilla.net> | 2018-05-13 00:47:58 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:58 +0100 |
commit | c9a8125b1bce5edc40f67c4056362f0083ad10a9 (patch) | |
tree | 0de88d36d9ea51dd366bb7891b8dff71b5e16586 | |
parent | 255fc4d36518728e8367feafb4a154e14b2b35d0 (diff) | |
download | serd-c9a8125b1bce5edc40f67c4056362f0083ad10a9.tar.gz serd-c9a8125b1bce5edc40f67c4056362f0083ad10a9.tar.bz2 serd-c9a8125b1bce5edc40f67c4056362f0083ad10a9.zip |
Remove datatype and language from reader context
-rw-r--r-- | src/n3.c | 38 | ||||
-rw-r--r-- | src/reader.h | 2 |
2 files changed, 14 insertions, 26 deletions
@@ -769,7 +769,6 @@ read_0_9(SerdReader* reader, SerdNode* str, bool at_least_one) static SerdStatus read_number(SerdReader* reader, SerdNode** dest, - SerdNode** datatype, SerdNodeFlags* flags, bool* ate_dot) { @@ -821,17 +820,13 @@ read_number(SerdReader* reader, default: break; } TRY(st, read_0_9(reader, *dest, true)); - *datatype = push_node(reader, SERD_URI, - XSD_DOUBLE, sizeof(XSD_DOUBLE) - 1); + push_node(reader, SERD_URI, XSD_DOUBLE, sizeof(XSD_DOUBLE) - 1); + *flags |= SERD_HAS_DATATYPE; } else if (has_decimal) { - *datatype = push_node(reader, SERD_URI, - XSD_DECIMAL, sizeof(XSD_DECIMAL) - 1); + push_node(reader, SERD_URI, XSD_DECIMAL, sizeof(XSD_DECIMAL) - 1); + *flags |= SERD_HAS_DATATYPE; } else { - *datatype = push_node(reader, SERD_URI, - XSD_INTEGER, sizeof(XSD_INTEGER) - 1); - } - - if (*datatype) { + push_node(reader, SERD_URI, XSD_INTEGER, sizeof(XSD_INTEGER) - 1); *flags |= SERD_HAS_DATATYPE; } @@ -855,8 +850,6 @@ read_iri(SerdReader* reader, SerdNode** dest, bool* ate_dot) static SerdStatus read_literal(SerdReader* reader, SerdNode** dest, - SerdNode** datatype, - SerdNode** lang, SerdNodeFlags* flags, bool* ate_dot) { @@ -868,11 +861,13 @@ read_literal(SerdReader* reader, return st; } + SerdNode* datatype = NULL; + SerdNode* lang = NULL; switch (peek_byte(reader)) { case '@': eat_byte_safe(reader, '@'); *flags |= SERD_HAS_LANGUAGE; - if ((st = read_LANGTAG(reader, lang))) { + if ((st = read_LANGTAG(reader, &lang))) { return r_err(reader, st, "bad literal\n"); } break; @@ -880,7 +875,7 @@ read_literal(SerdReader* reader, eat_byte_safe(reader, '^'); eat_byte_check(reader, '^'); *flags |= SERD_HAS_DATATYPE; - if ((st = read_iri(reader, datatype, ate_dot))) { + if ((st = read_iri(reader, &datatype, ate_dot))) { return r_err(reader, st, "bad literal\n"); } break; @@ -1053,8 +1048,6 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) bool simple = (ctx->subject != 0); SerdNode* o = 0; - SerdNode* datatype = 0; - SerdNode* lang = 0; uint32_t flags = 0; const int c = peek_byte(reader); if (!fancy_syntax(reader)) { @@ -1084,11 +1077,11 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) break; case '+': case '-': case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - ret = read_number(reader, &o, &datatype, &flags, ate_dot); + ret = read_number(reader, &o, &flags, ate_dot); break; case '\"': case '\'': - ret = read_literal(reader, &o, &datatype, &lang, &flags, ate_dot); + ret = read_literal(reader, &o, &flags, ate_dot); break; default: /* Either a boolean literal, or a qname. Read the prefix first, and if @@ -1105,8 +1098,7 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) !memcmp(serd_node_string(o), "false", 5))) { flags = flags | SERD_HAS_DATATYPE; o->type = SERD_LITERAL; - datatype = push_node( - reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN); + push_node(reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN); ret = SERD_SUCCESS; } else if (read_PN_PREFIX_tail(reader, o) > SERD_FAILURE) { ret = SERD_ERR_BAD_SYNTAX; @@ -1126,8 +1118,6 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) ret = emit_statement(reader, *ctx, o); } else if (!ret && !emit) { ctx->object = o; - ctx->datatype = datatype; - ctx->lang = lang; return SERD_SUCCESS; } @@ -1472,7 +1462,7 @@ SerdStatus read_n3_statement(SerdReader* reader) { SerdStatementFlags flags = 0; - ReadContext ctx = { 0, 0, 0, 0, 0, 0, &flags }; + ReadContext ctx = { 0, 0, 0, 0, &flags }; bool ate_dot = false; int s_type = 0; SerdStatus st = SERD_SUCCESS; @@ -1579,7 +1569,7 @@ read_nquadsDoc(SerdReader* reader) const size_t orig_stack_size = reader->stack.size; SerdStatementFlags flags = 0; - ReadContext ctx = { 0, 0, 0, 0, 0, 0, &flags }; + ReadContext ctx = { 0, 0, 0, 0, &flags }; bool ate_dot = false; int s_type = 0; read_ws_star(reader); diff --git a/src/reader.h b/src/reader.h index eae96616..cfda66c8 100644 --- a/src/reader.h +++ b/src/reader.h @@ -46,8 +46,6 @@ typedef struct { SerdNode* subject; SerdNode* predicate; SerdNode* object; - SerdNode* datatype; - SerdNode* lang; SerdStatementFlags* flags; } ReadContext; |