[PATCH 4/5] cli/dump: define GZPUTS and use it in notmuch-dump

Subject: [PATCH 4/5] cli/dump: define GZPUTS and use it in notmuch-dump

Date: Sun, 12 Apr 2020 23:10:15 -0300

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: David Bremner


Similarly to GZPRINTF, this is a drop in replacement that can be
improved where needd.
---
 notmuch-client.h |  1 +
 notmuch-dump.c   | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 55d4d526..7efcb06f 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -499,6 +499,7 @@ print_status_gzbytes (const char *loc,
 
 #define ASSERT_GZBYTES(file, bytes) ( (print_status_gzbytes(__location__, file, bytes)) ?  exit(1) : 0 )
 #define GZPRINTF(file, fmt, ...) ASSERT_GZBYTES(file, gzprintf (file, fmt, ##__VA_ARGS__));
+#define GZPUTS(file, str) ASSERT_GZBYTES(file, gzputs (file, str));
 
 #include "command-line-arguments.h"
 
diff --git a/notmuch-dump.c b/notmuch-dump.c
index ca45d885..fb322237 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -76,7 +76,7 @@ print_dump_header (gzFile output, int output_format, int include)
 	      NOTMUCH_DUMP_VERSION);
 
     if (include & DUMP_INCLUDE_CONFIG) {
-	gzputs (output, "config");
+	GZPUTS (output, "config");
 	sep = ",";
     }
     if (include & DUMP_INCLUDE_PROPERTIES) {
@@ -86,7 +86,7 @@ print_dump_header (gzFile output, int output_format, int include)
     if (include & DUMP_INCLUDE_TAGS) {
 	GZPRINTF (output, "%stags", sep);
     }
-    gzputs (output, "\n");
+    GZPUTS (output, "\n");
 }
 
 static int
@@ -174,12 +174,12 @@ dump_tags_message (void *ctx,
 	const char *tag_str = notmuch_tags_get (tags);
 
 	if (! first)
-	    gzputs (output, " ");
+	    GZPUTS (output, " ");
 
 	first = 0;
 
 	if (output_format == DUMP_FORMAT_SUP) {
-	    gzputs (output, tag_str);
+	    GZPUTS (output, tag_str);
 	} else {
 	    if (hex_encode (ctx, tag_str,
 			    buffer_p, size_p) != HEX_SUCCESS) {
@@ -192,7 +192,7 @@ dump_tags_message (void *ctx,
     }
 
     if (output_format == DUMP_FORMAT_SUP) {
-	gzputs (output, ")\n");
+	GZPUTS (output, ")\n");
     } else {
 	if (make_boolean_term (ctx, "id", message_id,
 			       buffer_p, size_p)) {
-- 
2.25.1

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: