aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-05-04 11:32:35 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commitfa4c14acdeeabaf7aee0304a57ae7878ecea1776 (patch)
tree5b43e86ecac55c9cee0056a2ce7a94c0f01aecbc /src
parentfac7901dca0b4821582c6062600d37ac987082d9 (diff)
downloadserd-fa4c14acdeeabaf7aee0304a57ae7878ecea1776.tar.gz
serd-fa4c14acdeeabaf7aee0304a57ae7878ecea1776.tar.bz2
serd-fa4c14acdeeabaf7aee0304a57ae7878ecea1776.zip
Add a reader flag to disable generated blank label avoidance
Diffstat (limited to 'src')
-rw-r--r--src/read_ntriples.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/read_ntriples.c b/src/read_ntriples.c
index 7a43e4c2..57b1e7be 100644
--- a/src/read_ntriples.c
+++ b/src/read_ntriples.c
@@ -17,7 +17,6 @@
#include "serd/caret.h"
#include "serd/sink.h"
#include "serd/statement.h"
-#include "serd/syntax.h"
#include <assert.h>
#include <stdbool.h>
@@ -237,22 +236,18 @@ read_STRING_LITERAL(SerdReader* const reader,
return tolerate_status(reader, st) ? SERD_SUCCESS : st;
}
-static bool
-avoid_blank_clashes(const SerdReader* const reader)
-{
- return (reader->syntax == SERD_TURTLE || reader->syntax == SERD_TRIG) &&
- !(reader->flags & SERD_READ_VERBATIM);
-}
-
static SerdStatus
adjust_blank_id(SerdReader* const reader, char* const buf)
{
- if (avoid_blank_clashes(reader) && is_digit(buf[reader->bprefix_len + 1])) {
+ 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_BAD_LABEL,
"found both 'b' and 'B' blank IDs, prefix required");