diff options
author | David Robillard <d@drobilla.net> | 2023-04-05 08:58:15 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | a1b677851274b7e5295962658e723cab007f9b85 (patch) | |
tree | bb9de8a1addaa32f0e973e382b16b4c46b64e0de /src | |
parent | b5956c4dc6b065d664908104d5fc6752a87e3364 (diff) | |
download | serd-a1b677851274b7e5295962658e723cab007f9b85.tar.gz serd-a1b677851274b7e5295962658e723cab007f9b85.tar.bz2 serd-a1b677851274b7e5295962658e723cab007f9b85.zip |
Add SERD_READ_ORDERED to preserve blank node ordering in models
Diffstat (limited to 'src')
-rw-r--r-- | src/reader.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/reader.c b/src/reader.c index 5ce81962..ce87a6f0 100644 --- a/src/reader.c +++ b/src/reader.c @@ -68,16 +68,22 @@ set_blank_id(SerdReader* const reader, SerdNode* const node, const size_t buf_size) { - char* const buf = (char*)(node + 1); - - node->length = (size_t)snprintf( - buf, buf_size, "%sb%u", reader->bprefix, reader->next_id++); + char* const buf = (char*)(node + 1); + const unsigned id = reader->next_id++; + + if ((reader->flags & SERD_READ_ORDERED)) { + node->length = + (size_t)snprintf(buf, buf_size, "%sb%09u", reader->bprefix, id); + } else { + node->length = + (size_t)snprintf(buf, buf_size, "%sb%u", reader->bprefix, id); + } } size_t genid_length(const SerdReader* const reader) { - return reader->bprefix_len + 10; // + "b" + UINT32_MAX + return reader->bprefix_len + 11; } bool |