$OpenBSD$

OpenBSD zlib is too old for gzclose_w

also gzerror's second argument cannot be NULL

XXX various problems in gzip-related regression tests. many of them die with
segfaults; suspect the naive s/gzclose_w/gzclose/ may result in use-after-free
with the second gzclose call. some hang and are disabled in the port Makefile
by TEST_FLAGS=NOTMUCH_SKIP_TESTS="[..]" - should be reenabled if testing any
fixes to this.

Index: notmuch-dump.c
--- notmuch-dump.c.orig
+++ notmuch-dump.c
@@ -287,6 +287,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
     int outfd = -1;
 
     int ret = -1;
+    int errnum;
 
     if (output_file_name) {
 	tempname = talloc_asprintf (notmuch, "%s.XXXXXX", output_file_name);
@@ -316,7 +317,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
 
     ret = gzflush (output, Z_FINISH);
     if (ret) {
-	fprintf (stderr, "Error flushing output: %s\n", gzerror (output, NULL));
+	fprintf (stderr, "Error flushing output: %s\n", gzerror (output, &errnum));
 	goto DONE;
     }
 
@@ -329,10 +330,10 @@ notmuch_database_dump (notmuch_database_t *notmuch,
 	}
     }
 
-    ret = gzclose_w (output);
+    ret = gzclose (output);
     if (ret) {
 	fprintf (stderr, "Error closing %s: %s\n", name_for_error,
-		 gzerror (output, NULL));
+		 gzerror (output, &errnum));
 	ret = EXIT_FAILURE;
 	output = NULL;
 	goto DONE;
@@ -350,7 +351,7 @@ notmuch_database_dump (notmuch_database_t *notmuch,
     }
  DONE:
     if (ret != EXIT_SUCCESS && output)
-	(void) gzclose_w (output);
+	(void) gzclose (output);
 
     if (ret != EXIT_SUCCESS && output_file_name)
 	(void) unlink (tempname);
