Clean up the usage of z_const and respect const usage within zlib.

This patch allows zlib to compile cleanly with the -Wcast-qual gcc
warning enabled, but only if ZLIB_CONST is defined, which adds
const to next_in and msg in z_stream and in the in_func prototype.
A --const option is added to ./configure which adds -DZLIB_CONST
to the compile flags, and adds -Wcast-qual to the compile flags
when ZLIBGCCWARN is set in the environment.
Merge remote-tracking branch 'upstream/develop' into develop
Update examples/gun.c for proper z_const usage.
Fix example/gzappend.c for proper z_const usage.
Clean up examples/gzjoin.c for z_const usage.
Clean up examples/gzlog.[ch] comparisons of different types.
Avoid shift equal to bits in type (caused endless loop).

Also clean up comparisons between different types, and some odd
indentation problems that showed up somehow.

A new endless loop was introduced by the clang compiler, which
apparently does odd things when the right operand of << is equal to
or greater than the number of bits in the type.  The C standard in
fact states that the behavior of << is undefined in that case.  The
loop was rewritten to use single-bit shifts.
Fix unintialized value bug in gzputc() introduced by const patches.

Avoid the use of an uninitialized value when the write buffers have
not been initialized.  A recent change to avoid the use of strm->
next_in in order to resolve some const conflicts added the use of
state->in in its place.  This patch avoids the use of state->in
when it is not initialized.  Nothing bad would actually happen,
since two variables set to the same unintialized value are
subtracted.  However valgrind was rightly complaining.  So this
fixes that.
Merge remote-tracking branch 'upstream/develop' into develop
Fix memory allocation error in examples/zran.c [Nor].
Fix bug where gzopen(), gzclose() would write an empty file.

A gzopen() to write (mode "w") followed immediately by a gzclose()
would output an empty zero-length file.  What it should do is write
an empty gzip file, with the gzip header, empty deflate content,
and gzip trailer totalling 20 bytes.  This fixes it to do that.
Fix bug in gzclose() when gzwrite() runs out of memory.

If the deflateInit2() called for the first gzwrite() failed with a
Z_MEM_ERROR, then a subsequent gzclose() would try to free an
already freed pointer.  This fixes that.
Check for input buffer malloc failure in examples/gzappend.c.
Merge remote-tracking branch 'upstream/develop' into develop
Add note to contrib/blast to use binary mode in stdio.
Fix comparisons of differently signed integers in contrib/blast.
Check for invalid code length codes in contrib/puff.

Without this fix, it would be possible to construct inputs to puff
that would cause it to segfault.
Fix serious but very rare decompression bug in inftrees.c.

inftrees.c compared the number of used table entries to the maximum
allowed value using >= instead of >.  This patch fixes those to use
>.  The bug was discovered by Ignat Kolesnichenko of Yandex LC
where they have run petabytes of data through zlib.  Triggering the
bug is apparently very rare, seeing as how it has been out there in
the wild for almost three years before being discovered.  The bug
is instantiated only if the exact maximum number of decoding table
entries, ENOUGH_DISTS or ENOUGH_LENS is used by the block being
decoded, resulting in the false positive of overflowing the table.
Update inflateBack() comments, since inflate() can be faster.
Use underscored I/O function names for WINAPI_FAMILY.

Suggested by E. Timothy Uy.