[master] 86105f6 Update libvgz and neuter the adler32 bits we do not use.
Poul-Henning Kamp
phk at FreeBSD.org
Thu Nov 16 11:03:07 UTC 2017
commit 86105f6981f3c774ae14c871ad8f61dc9ec1d3af
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Nov 16 11:02:12 2017 +0000
Update libvgz and neuter the adler32 bits we do not use.
diff --git a/lib/libvgz/adler32.c b/lib/libvgz/adler32.c
index d0be438..5f5e0de 100644
--- a/lib/libvgz/adler32.c
+++ b/lib/libvgz/adler32.c
@@ -7,6 +7,7 @@
#include "zutil.h"
+#ifdef NOVGZ
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#define BASE 65521U /* largest prime smaller than 65536 */
@@ -184,3 +185,15 @@ uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
{
return adler32_combine_(adler1, adler2, len2);
}
+#else
+uLong ZEXPORT adler32(adler, buf, len)
+ uLong adler;
+ const Bytef *buf;
+ uInt len;
+{
+ (void)adler;
+ (void)buf;
+ (void)len;
+ abort();
+}
+#endif
diff --git a/lib/libvgz/deflate.c b/lib/libvgz/deflate.c
index 4fce32a..0b300c7 100644
--- a/lib/libvgz/deflate.c
+++ b/lib/libvgz/deflate.c
@@ -511,7 +511,7 @@ int ZEXPORT deflateResetKeep (strm)
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
#endif
adler32(0L, Z_NULL, 0);
- s->last_flush = Z_NO_FLUSH;
+ s->last_flush = -2;
_tr_init(s);
@@ -606,12 +606,12 @@ int ZEXPORT deflateParams(strm, level, strategy)
func = configuration_table[s->level].func;
if ((strategy != s->strategy || func != configuration_table[level].func) &&
- s->high_water) {
+ s->last_flush != -2) {
/* Flush the last buffer: */
int err = deflate(strm, Z_BLOCK);
if (err == Z_STREAM_ERROR)
return err;
- if (strm->avail_out == 0)
+ if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead)
return Z_BUF_ERROR;
}
if (s->level != level) {
diff --git a/lib/libvgz/trees.c b/lib/libvgz/trees.c
index 92a50f2..a11cd0d 100644
--- a/lib/libvgz/trees.c
+++ b/lib/libvgz/trees.c
@@ -122,13 +122,13 @@ struct static_tree_desc_s {
int max_length; /* max bit length for the codes */
};
-local static_tree_desc static_l_desc =
+local const static_tree_desc static_l_desc =
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-local static_tree_desc static_d_desc =
+local const static_tree_desc static_d_desc =
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-local static_tree_desc static_bl_desc =
+local const static_tree_desc static_bl_desc =
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
/* ===========================================================================
diff --git a/lib/libvgz/vgz.h b/lib/libvgz/vgz.h
index dc3e126..86831ee 100644
--- a/lib/libvgz/vgz.h
+++ b/lib/libvgz/vgz.h
@@ -716,11 +716,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy.
If the compression approach (which is a function of the level) or the
- strategy is changed, and if any input has been consumed in a previous
- deflate() call, then the input available so far is compressed with the old
- level and strategy using deflate(strm, Z_BLOCK). There are three approaches
- for the compression levels 0, 1..3, and 4..9 respectively. The new level
- and strategy will take effect at the next call of deflate().
+ strategy is changed, and if there have been any deflate() calls since the
+ state was initialized or reset, then the input available so far is
+ compressed with the old level and strategy using deflate(strm, Z_BLOCK).
+ There are three approaches for the compression levels 0, 1..3, and 4..9
+ respectively. The new level and strategy will take effect at the next call
+ of deflate().
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
not have enough output space to complete, then the parameter change will not
diff --git a/tools/cmp_libz.sh b/tools/cmp_libz.sh
new file mode 100644
index 0000000..b9c5c6b
--- /dev/null
+++ b/tools/cmp_libz.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# This script compares libvgz to zlib in FreeBSD source tree
+
+LZ=/usr/src/contrib/zlib
+
+if [ ! -d lib/libvgz ] ; then
+ echo "Run this from to of tree" 1>&2
+ exit 2
+fi
+
+for i in lib/libvgz/*.[ch]
+do
+ b=`basename $i`
+ if [ "$b" == "vgz.h" ] ; then
+ b="zlib.h"
+ fi
+ if [ -f ${LZ}/$b ] ; then
+ echo "==== $b"
+ sed '
+ s/vgz.h/zlib.h/
+ /strm->msg =/s/"/(char *)"/
+ ' $i |
+ diff -u ${LZ}/$b -
+ else
+ echo "#### $b #### NOT FOUND ####"
+ fi
+done
More information about the varnish-commit
mailing list