]> git.cworth.org Git - notmuch/commitdiff
cli/dump: define GZPUTS and use it in notmuch-dump
authorDavid Bremner <david@tethera.net>
Mon, 13 Apr 2020 01:59:12 +0000 (22:59 -0300)
committerDavid Bremner <david@tethera.net>
Mon, 13 Apr 2020 20:14:50 +0000 (17:14 -0300)
Similarly to GZPRINTF, this is a drop in replacement that can be
improved where needd.

notmuch-client.h
notmuch-dump.c

index 6cb8182090241b43d11749d3e45aab3fcbc286c8..ebd43e8d296ec775808f527b757b73c137528235 100644 (file)
@@ -500,6 +500,7 @@ print_status_gzbytes (const char *loc,
 /* the __location__ macro is defined in talloc.h */
 #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"
 
index 6c5c1433dbde7ebb5a3c96f154fac9755fa295a7..52a882837e41025335bdb6f3a5ac264c9d07ea91 100644 (file)
@@ -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)) {