aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-10-10 12:31:29 +0200
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:06 -0500
commitdc8831a4ebfee8a61975123f969f737845ad537f (patch)
tree3cb1e130571ef5808b06683d429e48d90276fd78
parentfc3e5a0a7c9c64d275fec498f0e80dc02444c12d (diff)
downloadserd-dc8831a4ebfee8a61975123f969f737845ad537f.tar.gz
serd-dc8831a4ebfee8a61975123f969f737845ad537f.tar.bz2
serd-dc8831a4ebfee8a61975123f969f737845ad537f.zip
Add SERD_READ_EXACT_BLANKS flag
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--include/serd/serd.h5
-rw-r--r--src/n3.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index b125bb3d..f3402dd1 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -304,8 +304,9 @@ typedef struct {
/// Reader options
typedef enum {
- SERD_READ_LAX = 1u << 0u, ///< Tolerate invalid input where possible
- SERD_READ_VARIABLES = 1u << 1u ///< Support variable nodes
+ SERD_READ_LAX = 1u << 0u, ///< Tolerate invalid input where possible
+ SERD_READ_VARIABLES = 1u << 1u, ///< Support variable nodes
+ SERD_READ_EXACT_BLANKS = 1u << 2u, ///< Allow clashes with generated blanks
} SerdReaderFlag;
/// Bitwise OR of SerdReaderFlag values
diff --git a/src/n3.c b/src/n3.c
index 1ae98a56..6036bc7f 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -1043,7 +1043,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