summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure22
-rw-r--r--gzread.c8
-rw-r--r--gzwrite.c23
-rw-r--r--zconf.h11
-rw-r--r--zconf.h.cmakein11
-rw-r--r--zconf.h.in11
6 files changed, 19 insertions, 67 deletions
diff --git a/configure b/configure
index e0c07b7..e974d1f 100755
--- a/configure
+++ b/configure
@@ -465,23 +465,8 @@ fi
465 465
466echo >> configure.log 466echo >> configure.log
467 467
468# check for ssize_t
469cat > $test.c <<EOF
470#include <sys/types.h>
471ssize_t dummy = 0;
472EOF
473if try $CC -c $CFLAGS $test.c; then
474 echo "Checking for ssize_t... Yes." | tee -a configure.log
475 need_ssizet=0
476else
477 echo "Checking for ssize_t... No." | tee -a configure.log
478 need_ssizet=1
479fi
480
481echo >> configure.log
482
483# find the size_t integer type, if needed 468# find the size_t integer type, if needed
484if test $need_sizet -eq 1 -o $need_ssizet -eq 1; then 469if test $need_sizet -eq 1; then
485 cat > $test.c <<EOF 470 cat > $test.c <<EOF
486long long dummy = 0; 471long long dummy = 0;
487EOF 472EOF
@@ -521,11 +506,6 @@ if test $need_sizet -eq 1; then
521 SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}" 506 SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
522fi 507fi
523 508
524if test $need_ssizet -eq 1; then
525 CFLAGS="${CFLAGS} -DNO_SSIZE_T=${sizet}"
526 SFLAGS="${SFLAGS} -DNO_SSIZE_T=${sizet}"
527fi
528
529echo >> configure.log 509echo >> configure.log
530 510
531# check for large file support, and if none, check for fseeko() 511# check for large file support, and if none, check for fseeko()
diff --git a/gzread.c b/gzread.c
index 3811157..deea79b 100644
--- a/gzread.c
+++ b/gzread.c
@@ -24,11 +24,15 @@ local int gz_load(state, buf, len, have)
24 unsigned len; 24 unsigned len;
25 unsigned *have; 25 unsigned *have;
26{ 26{
27 z_ssize_t ret; 27 int ret;
28 unsigned get, max = ((unsigned)-1 >> 2) + 1;
28 29
29 *have = 0; 30 *have = 0;
30 do { 31 do {
31 ret = read(state->fd, buf + *have, len - *have); 32 get = len - *have;
33 if (get > max)
34 get = max;
35 ret = read(state->fd, buf + *have, get);
32 if (ret <= 0) 36 if (ret <= 0)
33 break; 37 break;
34 *have += (unsigned)ret; 38 *have += (unsigned)ret;
diff --git a/gzwrite.c b/gzwrite.c
index c29308b..b866251 100644
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -74,9 +74,8 @@ local int gz_comp(state, flush)
74 gz_statep state; 74 gz_statep state;
75 int flush; 75 int flush;
76{ 76{
77 int ret; 77 int ret, writ;
78 z_ssize_t got; 78 unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
79 unsigned have;
80 z_streamp strm = &(state->strm); 79 z_streamp strm = &(state->strm);
81 80
82 /* allocate memory if this is the first time through */ 81 /* allocate memory if this is the first time through */
@@ -86,13 +85,14 @@ local int gz_comp(state, flush)
86 /* write directly if requested */ 85 /* write directly if requested */
87 if (state->direct) { 86 if (state->direct) {
88 while (strm->avail_in) { 87 while (strm->avail_in) {
89 got = write(state->fd, strm->next_in, strm->avail_in); 88 put = strm->avail_in > max ? max : strm->avail_in;
90 if (got < 0) { 89 writ = write(state->fd, strm->next_in, put);
90 if (writ < 0) {
91 gz_error(state, Z_ERRNO, zstrerror()); 91 gz_error(state, Z_ERRNO, zstrerror());
92 return -1; 92 return -1;
93 } 93 }
94 strm->avail_in -= (unsigned)got; 94 strm->avail_in -= (unsigned)writ;
95 strm->next_in += got; 95 strm->next_in += writ;
96 } 96 }
97 return 0; 97 return 0;
98 } 98 }
@@ -105,13 +105,14 @@ local int gz_comp(state, flush)
105 if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && 105 if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
106 (flush != Z_FINISH || ret == Z_STREAM_END))) { 106 (flush != Z_FINISH || ret == Z_STREAM_END))) {
107 while (strm->next_out > state->x.next) { 107 while (strm->next_out > state->x.next) {
108 got = write(state->fd, state->x.next, 108 put = strm->next_out - state->x.next > (int)max ? max :
109 (unsigned long)(strm->next_out - state->x.next)); 109 (unsigned)(strm->next_out - state->x.next);
110 if (got < 0) { 110 writ = write(state->fd, state->x.next, put);
111 if (writ < 0) {
111 gz_error(state, Z_ERRNO, zstrerror()); 112 gz_error(state, Z_ERRNO, zstrerror());
112 return -1; 113 return -1;
113 } 114 }
114 state->x.next += got; 115 state->x.next += writ;
115 } 116 }
116 if (strm->avail_out == 0) { 117 if (strm->avail_out == 0) {
117 strm->avail_out = state->size; 118 strm->avail_out = state->size;
diff --git a/zconf.h b/zconf.h
index f6481d1..dc7209a 100644
--- a/zconf.h
+++ b/zconf.h
@@ -237,17 +237,6 @@
237# include <stddef.h> 237# include <stddef.h>
238 typedef size_t z_size_t; 238 typedef size_t z_size_t;
239# endif 239# endif
240# ifdef NO_SSIZE_T
241 typedef NO_SSIZE_T z_ssize_t;
242# else
243# include <stddef.h>
244# include <sys/types.h>
245# ifdef _MSC_VER
246 typedef intptr_t z_ssize_t;
247# else
248 typedef ssize_t z_ssize_t;
249# endif
250# endif
251# undef z_longlong 240# undef z_longlong
252#endif 241#endif
253 242
diff --git a/zconf.h.cmakein b/zconf.h.cmakein
index 843aeb4..31619f3 100644
--- a/zconf.h.cmakein
+++ b/zconf.h.cmakein
@@ -239,17 +239,6 @@
239# include <stddef.h> 239# include <stddef.h>
240 typedef size_t z_size_t; 240 typedef size_t z_size_t;
241# endif 241# endif
242# ifdef NO_SSIZE_T
243 typedef NO_SSIZE_T z_ssize_t;
244# else
245# include <stddef.h>
246# include <sys/types.h>
247# ifdef _MSC_VER
248 typedef intptr_t z_ssize_t;
249# else
250 typedef ssize_t z_ssize_t;
251# endif
252# endif
253# undef z_longlong 242# undef z_longlong
254#endif 243#endif
255 244
diff --git a/zconf.h.in b/zconf.h.in
index f6481d1..dc7209a 100644
--- a/zconf.h.in
+++ b/zconf.h.in
@@ -237,17 +237,6 @@
237# include <stddef.h> 237# include <stddef.h>
238 typedef size_t z_size_t; 238 typedef size_t z_size_t;
239# endif 239# endif
240# ifdef NO_SSIZE_T
241 typedef NO_SSIZE_T z_ssize_t;
242# else
243# include <stddef.h>
244# include <sys/types.h>
245# ifdef _MSC_VER
246 typedef intptr_t z_ssize_t;
247# else
248 typedef ssize_t z_ssize_t;
249# endif
250# endif
251# undef z_longlong 240# undef z_longlong
252#endif 241#endif
253 242