aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-10 13:21:51 +0100
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:05 -0500
commita3c9577b876c5255c877fe42f12fd01fee5676a9 (patch)
treeeed5844a1f764fccf69ca3a29c504f85ea040812 /src/writer.c
parentaa76de1ebf17be90d37cfc471957a565165b29dc (diff)
downloadserd-a3c9577b876c5255c877fe42f12fd01fee5676a9.tar.gz
serd-a3c9577b876c5255c877fe42f12fd01fee5676a9.tar.bz2
serd-a3c9577b876c5255c877fe42f12fd01fee5676a9.zip
Add option for writing terse output without newlines
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/writer.c b/src/writer.c
index 2e4bcb6c..867b5020 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -482,16 +482,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);
}
}