pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/archivers/libarchive/files/libarchive Merge 64333cef68...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b9c48e1d0d4d
branches:  trunk
changeset: 401682:b9c48e1d0d4d
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Sun Sep 22 10:03:51 2019 +0000

description:
Merge 64333cef68d7bcc67bef6ecf177fbeaa549b9139 from upstream to unbreak
build without zlib.

diffstat:

 archivers/libarchive/files/libarchive/archive_read_support_filter_gzip.c |  54 ++++++---
 1 files changed, 35 insertions(+), 19 deletions(-)

diffs (120 lines):

diff -r f49414c1e153 -r b9c48e1d0d4d archivers/libarchive/files/libarchive/archive_read_support_filter_gzip.c
--- a/archivers/libarchive/files/libarchive/archive_read_support_filter_gzip.c  Sun Sep 22 09:56:47 2019 +0000
+++ b/archivers/libarchive/files/libarchive/archive_read_support_filter_gzip.c  Sun Sep 22 10:03:51 2019 +0000
@@ -131,12 +131,20 @@
  */
 static ssize_t
 peek_at_header(struct archive_read_filter *filter, int *pbits,
-              struct private_data *state)
+#ifdef HAVE_ZLIB_H
+              struct private_data *state
+#else
+              void *state
+#endif
+             )
 {
        const unsigned char *p;
        ssize_t avail, len;
        int bits = 0;
        int header_flags;
+#ifndef HAVE_ZLIB_H
+       (void)state; /* UNUSED */
+#endif
 
        /* Start by looking at the first ten bytes of the header, which
         * is all fixed layout. */
@@ -153,8 +161,10 @@
        bits += 3;
        header_flags = p[3];
        /* Bytes 4-7 are mod time in little endian. */
+#ifdef HAVE_ZLIB_H
        if (state)
                state->mtime = archive_le32dec(p + 4);
+#endif
        /* Byte 8 is deflate flags. */
        /* XXXX TODO: return deflate flags back to consume_header for use
           in initializing the decompressor. */
@@ -171,7 +181,9 @@
 
        /* Null-terminated optional filename. */
        if (header_flags & 8) {
+#ifdef HAVE_ZLIB_H
                ssize_t file_start = len;
+#endif
                do {
                        ++len;
                        if (avail < len)
@@ -181,11 +193,13 @@
                                return (0);
                } while (p[len - 1] != 0);
 
+#ifdef HAVE_ZLIB_H
                if (state) {
                        /* Reset the name in case of repeat header reads. */
                        free(state->name);
                        state->name = strdup((const char *)&p[file_start]);
                }
+#endif
        }
 
        /* Null-terminated optional comment. */
@@ -236,24 +250,6 @@
        return (0);
 }
 
-static int
-gzip_read_header(struct archive_read_filter *self, struct archive_entry *entry)
-{
-       struct private_data *state;
-
-       state = (struct private_data *)self->data;
-
-       /* A mtime of 0 is considered invalid/missing. */
-       if (state->mtime != 0)
-               archive_entry_set_mtime(entry, state->mtime, 0);
-
-       /* If the name is available, extract it. */
-       if (state->name)
-               archive_entry_set_pathname(entry, state->name);
-
-       return (ARCHIVE_OK);
-}
-
 #ifndef HAVE_ZLIB_H
 
 /*
@@ -277,6 +273,24 @@
 
 #else
 
+static int
+gzip_read_header(struct archive_read_filter *self, struct archive_entry *entry)
+{
+       struct private_data *state;
+
+       state = (struct private_data *)self->data;
+
+       /* A mtime of 0 is considered invalid/missing. */
+       if (state->mtime != 0)
+               archive_entry_set_mtime(entry, state->mtime, 0);
+
+       /* If the name is available, extract it. */
+       if (state->name)
+               archive_entry_set_pathname(entry, state->name);
+
+       return (ARCHIVE_OK);
+}
+
 /*
  * Initialize the filter object.
  */
@@ -306,7 +320,9 @@
        self->read = gzip_filter_read;
        self->skip = NULL; /* not supported */
        self->close = gzip_filter_close;
+#ifdef HAVE_ZLIB_H
        self->read_header = gzip_read_header;
+#endif
 
        state->in_stream = 0; /* We're not actually within a stream yet. */
 



Home | Main Index | Thread Index | Old Index