diff options
author | David Robillard <d@drobilla.net> | 2019-03-10 13:21:51 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-13 23:04:06 -0500 |
commit | 5142013daed72b5a01944fd9dff17594f23029b2 (patch) | |
tree | f863455bd0c647ec228a20bdc57f4671018db631 /src/writer.c | |
parent | 20fc410ace9616df9b7d8444d747aaa700f4f6c8 (diff) | |
download | serd-5142013daed72b5a01944fd9dff17594f23029b2.tar.gz serd-5142013daed72b5a01944fd9dff17594f23029b2.tar.bz2 serd-5142013daed72b5a01944fd9dff17594f23029b2.zip |
Add option for writing terse output without newlines
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/writer.c b/src/writer.c index b682f6a8..60746c0a 100644 --- a/src/writer.c +++ b/src/writer.c @@ -474,16 +474,20 @@ uri_sink(const void* buf, size_t size, size_t nmemb, void* stream) static void write_newline(SerdWriter* writer) { - sink("\n", 1, writer); - for (int i = 0; i < writer->indent; ++i) { - sink("\t", 1, writer); + if (writer->flags & SERD_WRITE_TERSE) { + sink(" ", 1, writer); + } else { + sink("\n", 1, writer); + for (int i = 0; i < writer->indent; ++i) { + sink("\t", 1, writer); + } } } static void write_top_level_sep(SerdWriter* writer) { - if (!writer->empty) { + if (!writer->empty && !(writer->flags & SERD_WRITE_TERSE)) { write_newline(writer); } } |