diff options
author | David Robillard <d@drobilla.net> | 2019-03-10 13:21:51 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-04-13 19:48:23 +0200 |
commit | 9a3c3f9cd9c664cbe9a9b397761192b9a744975e (patch) | |
tree | a73b663889dd50e5d275f475713c10d99da49bf8 /src/writer.c | |
parent | c8e1af98cab4726124a0c9ee7afbbe63fc8fc6f9 (diff) | |
download | serd-9a3c3f9cd9c664cbe9a9b397761192b9a744975e.tar.gz serd-9a3c3f9cd9c664cbe9a9b397761192b9a744975e.tar.bz2 serd-9a3c3f9cd9c664cbe9a9b397761192b9a744975e.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 46d485c3..e2abf5a8 100644 --- a/src/writer.c +++ b/src/writer.c @@ -382,16 +382,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); } } |