From 28a419d25256b923652a122202de78ee9803b3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 9 Apr 2024 09:01:28 +0800 Subject: [PATCH] fastfetch: always provide trailing new line when generating JSON output --- src/fastfetch.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index 0109c2717..3959d7f8a 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -819,10 +819,7 @@ static void run(FFdata* data) ffPrintCommandOption(data, instance.state.resultDoc); if (instance.state.resultDoc) - { - yyjson_mut_write_fp(stdout, instance.state.resultDoc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL); - putchar('\n'); - } + yyjson_mut_write_fp(stdout, instance.state.resultDoc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES | YYJSON_WRITE_NEWLINE_AT_END, NULL, NULL); else ffFinish(); } @@ -841,11 +838,11 @@ static void writeConfigFile(FFdata* data, const FFstrbuf* filename) ffMigrateCommandOptionToJsonc(data, doc); if (ffStrbufEqualS(filename, "-")) - yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL); + yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES | YYJSON_WRITE_NEWLINE_AT_END, NULL, NULL); else { size_t len; - FF_AUTO_FREE const char* str = yyjson_mut_write(doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, &len); + FF_AUTO_FREE const char* str = yyjson_mut_write(doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES | YYJSON_WRITE_NEWLINE_AT_END, &len); if (!str) { printf("Error: failed to generate config file\n");