diff options
author | David Robillard <d@drobilla.net> | 2021-08-12 12:56:03 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-28 21:57:07 -0500 |
commit | 4339b6f9cb0da8a9d6519077f4a0ecc385cc382c (patch) | |
tree | aad416437aaac4b0bb47354da7cd2070912f8050 /src | |
parent | 90828959c762b0e6d2c318032e714ca39e8e6edb (diff) | |
download | serd-4339b6f9cb0da8a9d6519077f4a0ecc385cc382c.tar.gz serd-4339b6f9cb0da8a9d6519077f4a0ecc385cc382c.tar.bz2 serd-4339b6f9cb0da8a9d6519077f4a0ecc385cc382c.zip |
Add a reader flag to disable generated blank label avoidance
Diffstat (limited to 'src')
-rw-r--r-- | src/node_syntax.c | 9 | ||||
-rw-r--r-- | src/read_ntriples.c | 6 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/node_syntax.c b/src/node_syntax.c index 0c45e33a..edf5cbf5 100644 --- a/src/node_syntax.c +++ b/src/node_syntax.c @@ -55,8 +55,13 @@ serd_node_from_syntax_in(const char* const str, SerdSink* const sink = serd_sink_new(&object, on_node_string_event, NULL); SerdByteSource* const source = serd_byte_source_new_string(doc, NULL); - SerdReader* const reader = serd_reader_new( - world, syntax, SERD_READ_VERBATIM, env, sink, 1024 + doc_len); + SerdReader* const reader = + serd_reader_new(world, + syntax, + SERD_READ_VERBATIM | SERD_READ_GENERATED, + env, + sink, + 1024 + doc_len); serd_reader_start(reader, source); serd_reader_read_document(reader); diff --git a/src/read_ntriples.c b/src/read_ntriples.c index aa8f5468..08c489fe 100644 --- a/src/read_ntriples.c +++ b/src/read_ntriples.c @@ -256,13 +256,15 @@ read_STRING_LITERAL(SerdReader* const reader, static SerdStatus adjust_blank_id(SerdReader* const reader, char* const buf) { - if (!(reader->flags & SERD_READ_VERBATIM) && + if (!(reader->flags & SERD_READ_GENERATED) && is_digit(buf[reader->bprefix_len + 1])) { const char tag = buf[reader->bprefix_len]; if (tag == 'b') { - buf[reader->bprefix_len] = 'B'; // Prevent clash + // Presumably generated ID like b123 in the input, adjust to B123 + buf[reader->bprefix_len] = 'B'; reader->seen_genid = true; } else if (tag == 'B' && reader->seen_genid) { + // We've seen both b123 and B123 styles, abort due to possible clashes return r_err(reader, SERD_ERR_ID_CLASH, "found both `b' and `B' blank IDs, prefix required"); |