aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-10-10 12:31:29 +0200
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:59 +0100
commit20e2f827282213714174e52ce7684e315545176c (patch)
treeeadbd103bb2d806dfce8dd0c4bfae8040509825b
parenta3dda1c84a9a258721e26ef57ac32d548a24c148 (diff)
downloadserd-20e2f827282213714174e52ce7684e315545176c.tar.gz
serd-20e2f827282213714174e52ce7684e315545176c.tar.bz2
serd-20e2f827282213714174e52ce7684e315545176c.zip
Add SERD_READ_EXACT_BLANKS flags
This allows suppressing the blank node ID clashing mechanism to read blank IDs exactly as they appear in the input, even if they match the scheme used to generate blank node IDs internally.
-rw-r--r--serd/serd.h5
-rw-r--r--src/n3.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 612d2438..bac74adc 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -265,8 +265,9 @@ typedef struct {
/// Reader options
typedef enum {
- SERD_READ_LAX = 1 << 0, ///< Tolerate invalid input where possible
- SERD_READ_VARIABLES = 1 << 1 ///< Support variable nodes
+ SERD_READ_LAX = 1 << 0, ///< Tolerate invalid input where possible
+ SERD_READ_VARIABLES = 1 << 1, ///< Support variable nodes
+ SERD_READ_EXACT_BLANKS = 1 << 2, ///< Allow clashes with generated blanks
} SerdReaderFlag;
/// Bitwise OR of SerdReaderFlag values
diff --git a/src/n3.c b/src/n3.c
index c521b239..1b1497a6 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -983,7 +983,7 @@ read_BLANK_NODE_LABEL(SerdReader* reader, SerdNode** dest, bool* ate_dot)
*ate_dot = true;
}
- if (fancy_syntax(reader)) {
+ if (fancy_syntax(reader) && !(reader->flags & SERD_READ_EXACT_BLANKS)) {
if (is_digit(buf[reader->bprefix_len + 1])) {
if ((buf[reader->bprefix_len]) == 'b') {
buf[reader->bprefix_len] = 'B'; // Prevent clash