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>2020-10-27 13:13:58 +0100
commitb58e832527b850eca5e2c5a6f2157d307b0f45b5 (patch)
tree6470697a934e5d47d75a19622527b7ea7eb331fd /src/writer.c
parente5c5190771faec5bf3a81941d174763c2fda2a98 (diff)
downloadserd-b58e832527b850eca5e2c5a6f2157d307b0f45b5.tar.gz
serd-b58e832527b850eca5e2c5a6f2157d307b0f45b5.tar.bz2
serd-b58e832527b850eca5e2c5a6f2157d307b0f45b5.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 a0206578..a12f39b9 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -413,16 +413,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);
}
}