diff options
author | David Robillard <d@drobilla.net> | 2023-03-28 12:10:35 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-04-05 09:45:15 -0400 |
commit | bd2d7f510576c2185ddb0e9b8872079dba2a05c7 (patch) | |
tree | ab02e921f11db296fc77ffbbd981bad51e9648bf /src/writer.c | |
parent | e970e63146fb5d8de511104eba7aef5319e8653b (diff) | |
download | serd-bd2d7f510576c2185ddb0e9b8872079dba2a05c7.tar.gz serd-bd2d7f510576c2185ddb0e9b8872079dba2a05c7.tar.bz2 serd-bd2d7f510576c2185ddb0e9b8872079dba2a05c7.zip |
Fix pretty-printing of anonymous subjects
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/writer.c b/src/writer.c index 3433a924..27a6df83 100644 --- a/src/writer.c +++ b/src/writer.c @@ -43,6 +43,7 @@ typedef enum { SEP_S_P, ///< Between a subject and predicate (whitespace) SEP_P_O, ///< Between a predicate and object (whitespace) SEP_ANON_BEGIN, ///< Start of anonymous node ('[') + SEP_ANON_S_P, ///< Between anonymous subject and predicate (whitespace) SEP_ANON_END, ///< End of anonymous node (']') SEP_LIST_BEGIN, ///< Start of list ('(') SEP_LIST_SEP, ///< List separator (whitespace) @@ -68,6 +69,7 @@ static const SepRule rules[] = {{NULL, 0, 0, 0, 0}, {NULL, 0, 0, 1, 0}, {" ", 1, 0, 0, 0}, {"[", 1, 0, 1, 1}, + {NULL, 0, 0, 0, 0}, {"]", 1, 1, 0, 0}, {"(", 1, 0, 0, 0}, {NULL, 0, 0, 1, 0}, @@ -692,7 +694,6 @@ write_blank(SerdWriter* const writer, assert(writer->list_depth == 0); copy_node(&writer->list_subj, node); ++writer->list_depth; - ++writer->indent; return write_sep(writer, SEP_LIST_BEGIN); } @@ -892,8 +893,13 @@ serd_writer_write_statement(SerdWriter* writer, } write_node(writer, subject, NULL, NULL, FIELD_SUBJECT, flags); - ++writer->indent; - write_sep(writer, SEP_S_P); + if ((flags & SERD_ANON_S_BEGIN)) { + write_sep(writer, SEP_ANON_S_P); + } else { + ++writer->indent; + write_sep(writer, SEP_S_P); + } + } else { ++writer->indent; } |