]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Style cleanup for inflate code
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 25 May 2015 21:00:54 +0000 (23:00 +0200)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 25 May 2015 21:00:54 +0000 (23:00 +0200)
infback.c
inffast.c
inffast.h
inflate.c
inflate.h
inftrees.c
inftrees.h

index 8581177efbcbd4434c12d70b13a8df01a45b4108..ce5431ae792b51905ea59edcc5291722a422f082 100644 (file)
--- a/infback.c
+++ b/infback.c
@@ -16,7 +16,7 @@
 #include "inffast.h"
 
 /* function prototypes */
-local void fixedtables (struct inflate_state *state);
+local void fixedtables(struct inflate_state *state);
 
 /*
    strm provides memory allocation functions in zalloc and zfree, or
@@ -26,15 +26,12 @@ local void fixedtables (struct inflate_state *state);
    window and output buffer that is 2**windowBits bytes.
  */
 int ZEXPORT inflateBackInit_(z_stream *strm, int windowBits, unsigned char *window,
-                              const char *version, int stream_size)
-{
+                              const char *version, int stream_size) {
     struct inflate_state *state;
 
-    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
-        stream_size != (int)(sizeof(z_stream)))
+    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream)))
         return Z_VERSION_ERROR;
-    if (strm == Z_NULL || window == Z_NULL ||
-        windowBits < 8 || windowBits > 15)
+    if (strm == Z_NULL || window == Z_NULL || windowBits < 8 || windowBits > 15)
         return Z_STREAM_ERROR;
     strm->msg = Z_NULL;                 /* in case we return an error */
     if (strm->zalloc == (alloc_func)0) {
@@ -42,10 +39,10 @@ int ZEXPORT inflateBackInit_(z_stream *strm, int windowBits, unsigned char *wind
         strm->opaque = NULL;
     }
     if (strm->zfree == (free_func)0)
-    strm->zfree = zcfree;
-    state = (struct inflate_state *)ZALLOC(strm, 1,
-                                               sizeof(struct inflate_state));
-    if (state == Z_NULL) return Z_MEM_ERROR;
+        strm->zfree = zcfree;
+    state = (struct inflate_state *)ZALLOC(strm, 1, sizeof(struct inflate_state));
+    if (state == Z_NULL)
+        return Z_MEM_ERROR;
     Tracev((stderr, "inflate: allocated\n"));
     strm->state = (struct internal_state *)state;
     state->dmax = 32768U;
@@ -67,8 +64,7 @@ int ZEXPORT inflateBackInit_(z_stream *strm, int windowBits, unsigned char *wind
    used for threaded applications, since the rewriting of the tables and virgin
    may not be thread-safe.
  */
-local void fixedtables(struct inflate_state *state)
-{
+local void fixedtables(struct inflate_state *state) {
 #ifdef BUILDFIXED
     static int virgin = 1;
     static code *lenfix, *distfix;
@@ -234,9 +230,7 @@ local void fixedtables(struct inflate_state *state)
    inflateBack() can also return Z_STREAM_ERROR if the input parameters
    are not correct, i.e. strm is Z_NULL or the state was not initialized.
  */
-int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
-                         out_func out, void *out_desc)
-{
+int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc) {
     struct inflate_state *state;
     const unsigned char *next;  /* next input */
     unsigned char *put;         /* next output */
@@ -284,19 +278,16 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             DROPBITS(1);
             switch (BITS(2)) {
             case 0:                             /* stored block */
-                Tracev((stderr, "inflate:     stored block%s\n",
-                        state->last ? " (last)" : ""));
+                Tracev((stderr, "inflate:     stored block%s\n", state->last ? " (last)" : ""));
                 state->mode = STORED;
                 break;
             case 1:                             /* fixed block */
                 fixedtables(state);
-                Tracev((stderr, "inflate:     fixed codes block%s\n",
-                        state->last ? " (last)" : ""));
+                Tracev((stderr, "inflate:     fixed codes block%s\n", state->last ? " (last)" : ""));
                 state->mode = LEN;              /* decode codes */
                 break;
             case 2:                             /* dynamic block */
-                Tracev((stderr, "inflate:     dynamic codes block%s\n",
-                        state->last ? " (last)" : ""));
+                Tracev((stderr, "inflate:     dynamic codes block%s\n", state->last ? " (last)" : ""));
                 state->mode = TABLE;
                 break;
             case 3:
@@ -316,8 +307,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
                 break;
             }
             state->length = (unsigned)hold & 0xffff;
-            Tracev((stderr, "inflate:       stored length %u\n",
-                    state->length));
+            Tracev((stderr, "inflate:       stored length %u\n", state->length));
             INITBITS();
 
             /* copy stored block from input to output */
@@ -325,8 +315,10 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
                 copy = state->length;
                 PULL();
                 ROOM();
-                if (copy > have) copy = have;
-                if (copy > left) copy = left;
+                if (copy > have)
+                    copy = have;
+                if (copy > left)
+                    copy = left;
                 memcpy(put, next, copy);
                 have -= copy;
                 next += copy;
@@ -368,8 +360,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             state->next = state->codes;
             state->lencode = (code const *)(state->next);
             state->lenbits = 7;
-            ret = inflate_table(CODES, state->lens, 19, &(state->next),
-                                &(state->lenbits), state->work);
+            ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work);
             if (ret) {
                 strm->msg = (char *)"invalid code lengths set";
                 state->mode = BAD;
@@ -382,14 +373,14 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             while (state->have < state->nlen + state->ndist) {
                 for (;;) {
                     here = state->lencode[BITS(state->lenbits)];
-                    if ((unsigned)(here.bits) <= bits) break;
+                    if ((unsigned)(here.bits) <= bits)
+                        break;
                     PULLBYTE();
                 }
                 if (here.val < 16) {
                     DROPBITS(here.bits);
                     state->lens[state->have++] = here.val;
-                }
-                else {
+                } else {
                     if (here.val == 16) {
                         NEEDBITS(here.bits + 2);
                         DROPBITS(here.bits);
@@ -401,15 +392,13 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
                         len = (unsigned)(state->lens[state->have - 1]);
                         copy = 3 + BITS(2);
                         DROPBITS(2);
-                    }
-                    else if (here.val == 17) {
+                    } else if (here.val == 17) {
                         NEEDBITS(here.bits + 3);
                         DROPBITS(here.bits);
                         len = 0;
                         copy = 3 + BITS(3);
                         DROPBITS(3);
-                    }
-                    else {
+                    } else {
                         NEEDBITS(here.bits + 7);
                         DROPBITS(here.bits);
                         len = 0;
@@ -427,7 +416,8 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             }
 
             /* handle error breaks in while */
-            if (state->mode == BAD) break;
+            if (state->mode == BAD)
+                break;
 
             /* check for end-of-block code (better have one) */
             if (state->lens[256] == 0) {
@@ -442,8 +432,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             state->next = state->codes;
             state->lencode = (code const *)(state->next);
             state->lenbits = 9;
-            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
-                                &(state->lenbits), state->work);
+            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work);
             if (ret) {
                 strm->msg = (char *)"invalid literal/lengths set";
                 state->mode = BAD;
@@ -452,7 +441,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             state->distcode = (code const *)(state->next);
             state->distbits = 6;
             ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
-                            &(state->next), &(state->distbits), state->work);
+                                &(state->next), &(state->distbits), state->work);
             if (ret) {
                 strm->msg = (char *)"invalid distances set";
                 state->mode = BAD;
@@ -475,7 +464,8 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             /* get a literal, length, or end-of-block code */
             for (;;) {
                 here = state->lencode[BITS(state->lenbits)];
-                if ((unsigned)(here.bits) <= bits) break;
+                if ((unsigned)(here.bits) <= bits)
+                    break;
                 PULLBYTE();
             }
             if (here.op && (here.op & 0xf0) == 0) {
@@ -483,7 +473,8 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
                 for (;;) {
                     here = state->lencode[last.val +
                             (BITS(last.bits + last.op) >> last.bits)];
-                    if ((unsigned)(last.bits + here.bits) <= bits) break;
+                    if ((unsigned)(last.bits + here.bits) <= bits)
+                        break;
                     PULLBYTE();
                 }
                 DROPBITS(last.bits);
@@ -529,15 +520,16 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
             /* get distance code */
             for (;;) {
                 here = state->distcode[BITS(state->distbits)];
-                if ((unsigned)(here.bits) <= bits) break;
+                if ((unsigned)(here.bits) <= bits)
+                    break;
                 PULLBYTE();
             }
             if ((here.op & 0xf0) == 0) {
                 last = here;
                 for (;;) {
-                    here = state->distcode[last.val +
-                            (BITS(last.bits + last.op) >> last.bits)];
-                    if ((unsigned)(last.bits + here.bits) <= bits) break;
+                    here = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)];
+                    if ((unsigned)(last.bits + here.bits) <= bits)
+                        break;
                     PULLBYTE();
                 }
                 DROPBITS(last.bits);
@@ -557,8 +549,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
                 state->offset += BITS(state->extra);
                 DROPBITS(state->extra);
             }
-            if (state->offset > state->wsize - (state->whave < state->wsize ?
-                                                left : 0)) {
+            if (state->offset > state->wsize - (state->whave < state->wsize ? left : 0)) {
                 strm->msg = (char *)"invalid distance too far back";
                 state->mode = BAD;
                 break;
@@ -572,12 +563,12 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
                 if (copy < left) {
                     from = put + copy;
                     copy = left - copy;
-                }
-                else {
+                } else {
                     from = put - state->offset;
                     copy = left;
                 }
-                if (copy > state->length) copy = state->length;
+                if (copy > state->length)
+                    copy = state->length;
                 state->length -= copy;
                 left -= copy;
                 do {
@@ -611,8 +602,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc,
     return ret;
 }
 
-int ZEXPORT inflateBackEnd(z_stream *strm)
-{
+int ZEXPORT inflateBackEnd(z_stream *strm) {
     if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
         return Z_STREAM_ERROR;
     ZFREE(strm, strm->state);
index 1ccaeae039b63a1c6c04817697d02144b9f61e54..7c5040eab5da6f96b650f291a56d3357e24089f1 100644 (file)
--- a/inffast.c
+++ b/inffast.c
@@ -73,8 +73,7 @@
       requires strm->avail_out >= 258 for each loop to avoid checking for
       output space.
  */
-void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start)
-{
+void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) {
     /* start: inflate()'s starting value for strm->avail_out */
     struct inflate_state *state;
     const unsigned char *in;    /* local strm->next_in */
@@ -141,8 +140,7 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start)
                     "inflate:         literal '%c'\n" :
                     "inflate:         literal 0x%02x\n", here.val));
             PUP(out) = (unsigned char)(here.val);
-        }
-        else if (op & 16) {                     /* length base */
+        } else if (op & 16) {                     /* length base */
             len = (unsigned)(here.val);
             op &= 15;                           /* number of extra bits */
             if (op) {
@@ -190,8 +188,7 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start)
                     op = dist - op;             /* distance back in window */
                     if (op > whave) {
                         if (state->sane) {
-                            strm->msg =
-                                (char *)"invalid distance too far back";
+                            strm->msg = (char *)"invalid distance too far back";
                             state->mode = BAD;
                             break;
                         }
@@ -225,8 +222,7 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start)
                             } while (--op);
                             from = out - dist;  /* rest from output */
                         }
-                    }
-                    else if (wnext < op) {      /* wrap around window */
+                    } else if (wnext < op) {      /* wrap around window */
                         from += wsize + wnext - op;
                         op -= wnext;
                         if (op < len) {         /* some from end of window */
@@ -244,8 +240,7 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start)
                                 from = out - dist;      /* rest from output */
                             }
                         }
-                    }
-                    else {                      /* contiguous in window */
+                    } else {                      /* contiguous in window */
                         from += wnext - op;
                         if (op < len) {         /* some from window */
                             len -= op;
@@ -266,8 +261,7 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start)
                         if (len > 1)
                             PUP(out) = PUP(from);
                     }
-                }
-                else {
+                } else {
                     from = out - dist;          /* copy direct from output */
                     do {                        /* minimum length is three */
                         PUP(out) = PUP(from);
@@ -281,27 +275,22 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start)
                             PUP(out) = PUP(from);
                     }
                 }
-            }
-            else if ((op & 64) == 0) {          /* 2nd level distance code */
+            } else if ((op & 64) == 0) {          /* 2nd level distance code */
                 here = dcode[here.val + BITS(op)];
                 goto dodist;
-            }
-            else {
+            } else {
                 strm->msg = (char *)"invalid distance code";
                 state->mode = BAD;
                 break;
             }
-        }
-        else if ((op & 64) == 0) {              /* 2nd level length code */
+        } else if ((op & 64) == 0) {              /* 2nd level length code */
             here = lcode[here.val + BITS(op)];
             goto dolen;
-        }
-        else if (op & 32) {                     /* end-of-block */
+        } else if (op & 32) {                     /* end-of-block */
             Tracevv((stderr, "inflate:         end of block\n"));
             state->mode = TYPE;
             break;
-        }
-        else {
+        } else {
             strm->msg = (char *)"invalid literal/length code";
             state->mode = BAD;
             break;
@@ -318,8 +307,7 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start)
     strm->next_in = in + OFF;
     strm->next_out = out + OFF;
     strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
-    strm->avail_out = (unsigned)(out < end ?
-                                 257 + (end - out) : 257 - (out - end));
+    strm->avail_out = (unsigned)(out < end ? 257 + (end - out) : 257 - (out - end));
     state->hold = hold;
     state->bits = bits;
     return;
index 5b8a1f6643de6d9e6a2d61a9a5af7212d4b41f4f..47a218ca73dfe135d327b1fce62fa49147a3bed8 100644 (file)
--- a/inffast.h
+++ b/inffast.h
@@ -1,3 +1,5 @@
+#ifndef INFFAST_H_
+#define INFFAST_H_
 /* inffast.h -- header to use inffast.c
  * Copyright (C) 1995-2003, 2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
@@ -8,4 +10,6 @@
    subject to change. Applications should only use zlib.h.
  */
 
-void ZLIB_INTERNAL inflate_fast (z_stream *strm, unsigned start);
+void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start);
+
+#endif /* INFFAST_H_ */
index 2d9aa1c28d98a4237b8e1b5f2b43f3a34a5cb470..73958d16849a75cff9dcd5f73fe5e9f8b98108d7 100644 (file)
--- a/inflate.c
+++ b/inflate.c
 #endif
 
 /* function prototypes */
-local void fixedtables (struct inflate_state *state);
-local int updatewindow (z_stream *strm, const unsigned char *end, unsigned copy);
+local void fixedtables(struct inflate_state *state);
+local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy);
 #ifdef BUILDFIXED
-   void makefixed (void);
+    void makefixed(void);
 #endif
-local unsigned syncsearch (unsigned *have, const unsigned char *buf, unsigned len);
+local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len);
 
-int ZEXPORT inflateResetKeep(z_stream *strm)
-{
+int ZEXPORT inflateResetKeep(z_stream *strm) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     strm->total_in = strm->total_out = state->total = 0;
     strm->msg = Z_NULL;
@@ -123,11 +123,11 @@ int ZEXPORT inflateResetKeep(z_stream *strm)
     return Z_OK;
 }
 
-int ZEXPORT inflateReset(z_stream *strm)
-{
+int ZEXPORT inflateReset(z_stream *strm) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     state->wsize = 0;
     state->whave = 0;
@@ -135,21 +135,20 @@ int ZEXPORT inflateReset(z_stream *strm)
     return inflateResetKeep(strm);
 }
 
-int ZEXPORT inflateReset2(z_stream *strm, int windowBits)
-{
+int ZEXPORT inflateReset2(z_stream *strm, int windowBits) {
     int wrap;
     struct inflate_state *state;
 
     /* get the state */
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
 
     /* extract wrap request from windowBits parameter */
     if (windowBits < 0) {
         wrap = 0;
         windowBits = -windowBits;
-    }
-    else {
+    } else {
         wrap = (windowBits >> 4) + 1;
 #ifdef GUNZIP
         if (windowBits < 48)
@@ -171,16 +170,14 @@ int ZEXPORT inflateReset2(z_stream *strm, int windowBits)
     return inflateReset(strm);
 }
 
-int ZEXPORT inflateInit2_(z_stream *strm, int windowBits, const char *version,
-                           int stream_size)
-{
+int ZEXPORT inflateInit2_(z_stream *strm, int windowBits, const char *version, int stream_size) {
     int ret;
     struct inflate_state *state;
 
-    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
-        stream_size != (int)(sizeof(z_stream)))
+    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream)))
         return Z_VERSION_ERROR;
-    if (strm == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL)
+        return Z_STREAM_ERROR;
     strm->msg = Z_NULL;                 /* in case we return an error */
     if (strm->zalloc == (alloc_func)0) {
         strm->zalloc = zcalloc;
@@ -188,9 +185,9 @@ int ZEXPORT inflateInit2_(z_stream *strm, int windowBits, const char *version,
     }
     if (strm->zfree == (free_func)0)
         strm->zfree = zcfree;
-    state = (struct inflate_state *)
-            ZALLOC(strm, 1, sizeof(struct inflate_state));
-    if (state == Z_NULL) return Z_MEM_ERROR;
+    state = (struct inflate_state *) ZALLOC(strm, 1, sizeof(struct inflate_state));
+    if (state == Z_NULL)
+        return Z_MEM_ERROR;
     Tracev((stderr, "inflate: allocated\n"));
     strm->state = (struct internal_state *)state;
     state->window = Z_NULL;
@@ -202,23 +199,23 @@ int ZEXPORT inflateInit2_(z_stream *strm, int windowBits, const char *version,
     return ret;
 }
 
-int ZEXPORT inflateInit_(z_stream *strm, const char *version, int stream_size)
-{
+int ZEXPORT inflateInit_(z_stream *strm, const char *version, int stream_size) {
     return inflateInit2_(strm, DEF_WBITS, version, stream_size);
 }
 
-int ZEXPORT inflatePrime(z_stream *strm, int bits, int value)
-{
+int ZEXPORT inflatePrime(z_stream *strm, int bits, int value) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     if (bits < 0) {
         state->hold = 0;
         state->bits = 0;
         return Z_OK;
     }
-    if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
+    if (bits > 16 || state->bits + bits > 32)
+        return Z_STREAM_ERROR;
     value &= (1L << bits) - 1;
     state->hold += value << state->bits;
     state->bits += bits;
@@ -235,8 +232,7 @@ int ZEXPORT inflatePrime(z_stream *strm, int bits, int value)
    used for threaded applications, since the rewriting of the tables and virgin
    may not be thread-safe.
  */
-local void fixedtables(struct inflate_state *state)
-{
+local void fixedtables(struct inflate_state *state) {
 #ifdef BUILDFIXED
     static int virgin = 1;
     static code *lenfix, *distfix;
@@ -298,8 +294,7 @@ local void fixedtables(struct inflate_state *state)
 
     a.out > inffixed.h
  */
-void makefixed()
-{
+void makefixed(void) {
     unsigned low, size;
     struct inflate_state state;
 
@@ -317,10 +312,12 @@ void makefixed()
     printf("    static const code lenfix[%u] = {", size);
     low = 0;
     for (;;) {
-        if ((low % 7) == 0) printf("\n        ");
+        if ((low % 7) == 0)
+            printf("\n        ");
         printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
-               state.lencode[low].bits, state.lencode[low].val);
-        if (++low == size) break;
+            state.lencode[low].bits, state.lencode[low].val);
+        if (++low == size)
+            break;
         putchar(',');
     }
     puts("\n    };");
@@ -328,10 +325,11 @@ void makefixed()
     printf("\n    static const code distfix[%u] = {", size);
     low = 0;
     for (;;) {
-        if ((low % 6) == 0) printf("\n        ");
-        printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
-               state.distcode[low].val);
-        if (++low == size) break;
+        if ((low % 6) == 0)
+            printf("\n        ");
+        printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, state.distcode[low].val);
+        if (++low == size)
+            break;
         putchar(',');
     }
     puts("\n    };");
@@ -352,8 +350,7 @@ void makefixed()
    output will fall in the output data, making match copies simpler and faster.
    The advantage may be dependent on the size of the processor's data caches.
  */
-local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy)
-{
+local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy) {
     struct inflate_state *state;
     unsigned dist;
 
@@ -361,10 +358,9 @@ local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy)
 
     /* if it hasn't been done already, allocate space for the window */
     if (state->window == Z_NULL) {
-        state->window = (unsigned char *)
-                        ZALLOC(strm, 1U << state->wbits,
-                               sizeof(unsigned char));
-        if (state->window == Z_NULL) return 1;
+        state->window = (unsigned char *) ZALLOC(strm, 1U << state->wbits, sizeof(unsigned char));
+        if (state->window == Z_NULL)
+            return 1;
     }
 
     /* if window not in use yet, initialize */
@@ -379,21 +375,22 @@ local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy)
         memcpy(state->window, end - state->wsize, state->wsize);
         state->wnext = 0;
         state->whave = state->wsize;
-    }
-    else {
+    } else {
         dist = state->wsize - state->wnext;
-        if (dist > copy) dist = copy;
+        if (dist > copy)
+            dist = copy;
         memcpy(state->window + state->wnext, end - copy, dist);
         copy -= dist;
         if (copy) {
             memcpy(state->window, end - copy, copy);
             state->wnext = copy;
             state->whave = state->wsize;
-        }
-        else {
+        } else {
             state->wnext += dist;
-            if (state->wnext == state->wsize) state->wnext = 0;
-            if (state->whave < state->wsize) state->whave += dist;
+            if (state->wnext == state->wsize)
+                state->wnext = 0;
+            if (state->whave < state->wsize)
+                state->whave += dist;
         }
     }
     return 0;
@@ -575,8 +572,7 @@ local int updatewindow(z_stream *strm, const unsigned char *end, unsigned copy)
    will return Z_BUF_ERROR if it has not reached the end of the stream.
  */
 
-int ZEXPORT inflate(z_stream *strm, int flush)
-{
+int ZEXPORT inflate(z_stream *strm, int flush) {
     struct inflate_state *state;
     const unsigned char *next;    /* next input */
     unsigned char *put;         /* next output */
@@ -601,7 +597,8 @@ int ZEXPORT inflate(z_stream *strm, int flush)
         return Z_STREAM_ERROR;
 
     state = (struct inflate_state *)strm->state;
-    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
+    if (state->mode == TYPE)      /* skip check */
+        state->mode = TYPEDO;
     LOAD();
     in = have;
     out = left;
@@ -641,9 +638,9 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             }
             DROPBITS(4);
             len = BITS(4) + 8;
-            if (state->wbits == 0)
+            if (state->wbits == 0) {
                 state->wbits = len;
-            else if (len > state->wbits) {
+            else if (len > state->wbits) {
                 strm->msg = (char *)"invalid window size";
                 state->mode = BAD;
                 break;
@@ -670,14 +667,16 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             }
             if (state->head != Z_NULL)
                 state->head->text = (int)((hold >> 8) & 1);
-            if (state->flags & 0x0200) CRC2(state->check, hold);
+            if (state->flags & 0x0200)
+                CRC2(state->check, hold);
             INITBITS();
             state->mode = TIME;
         case TIME:
             NEEDBITS(32);
             if (state->head != Z_NULL)
                 state->head->time = hold;
-            if (state->flags & 0x0200) CRC4(state->check, hold);
+            if (state->flags & 0x0200)
+                CRC4(state->check, hold);
             INITBITS();
             state->mode = OS;
         case OS:
@@ -686,7 +685,8 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                 state->head->xflags = (int)(hold & 0xff);
                 state->head->os = (int)(hold >> 8);
             }
-            if (state->flags & 0x0200) CRC2(state->check, hold);
+            if (state->flags & 0x0200)
+                CRC2(state->check, hold);
             INITBITS();
             state->mode = EXLEN;
         case EXLEN:
@@ -695,16 +695,18 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                 state->length = (unsigned)(hold);
                 if (state->head != Z_NULL)
                     state->head->extra_len = (unsigned)hold;
-                if (state->flags & 0x0200) CRC2(state->check, hold);
+                if (state->flags & 0x0200)
+                    CRC2(state->check, hold);
                 INITBITS();
-            }
-            else if (state->head != Z_NULL)
+            } else if (state->head != Z_NULL) {
                 state->head->extra = Z_NULL;
+            }
             state->mode = EXTRA;
         case EXTRA:
             if (state->flags & 0x0400) {
                 copy = state->length;
-                if (copy > have) copy = have;
+                if (copy > have)
+                    copy = have;
                 if (copy) {
                     if (state->head != Z_NULL &&
                         state->head->extra != Z_NULL) {
@@ -719,7 +721,8 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                     next += copy;
                     state->length -= copy;
                 }
-                if (state->length) goto inf_leave;
+                if (state->length)
+                    goto inf_leave;
             }
             state->length = 0;
             state->mode = NAME;
@@ -729,19 +732,18 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                 copy = 0;
                 do {
                     len = (unsigned)(next[copy++]);
-                    if (state->head != Z_NULL &&
-                            state->head->name != Z_NULL &&
-                            state->length < state->head->name_max)
+                    if (state->head != Z_NULL && state->head->name != Z_NULL && state->length < state->head->name_max)
                         state->head->name[state->length++] = len;
                 } while (len && copy < have);
                 if (state->flags & 0x0200)
                     state->check = crc32(state->check, next, copy);
                 have -= copy;
                 next += copy;
-                if (len) goto inf_leave;
-            }
-            else if (state->head != Z_NULL)
+                if (len)
+                    goto inf_leave;
+            } else if (state->head != Z_NULL) {
                 state->head->name = Z_NULL;
+            }
             state->length = 0;
             state->mode = COMMENT;
         case COMMENT:
@@ -750,19 +752,19 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                 copy = 0;
                 do {
                     len = (unsigned)(next[copy++]);
-                    if (state->head != Z_NULL &&
-                            state->head->comment != Z_NULL &&
-                            state->length < state->head->comm_max)
+                    if (state->head != Z_NULL && state->head->comment != Z_NULL
+                        && state->length < state->head->comm_max)
                         state->head->comment[state->length++] = len;
                 } while (len && copy < have);
                 if (state->flags & 0x0200)
                     state->check = crc32(state->check, next, copy);
                 have -= copy;
                 next += copy;
-                if (len) goto inf_leave;
-            }
-            else if (state->head != Z_NULL)
+                if (len)
+                    goto inf_leave;
+            } else if (state->head != Z_NULL) {
                 state->head->comment = Z_NULL;
+            }
             state->mode = HCRC;
         case HCRC:
             if (state->flags & 0x0200) {
@@ -795,7 +797,8 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             strm->adler = state->check = adler32(0L, Z_NULL, 0);
             state->mode = TYPE;
         case TYPE:
-            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
+            if (flush == Z_BLOCK || flush == Z_TREES)
+                goto inf_leave;
         case TYPEDO:
             if (state->last) {
                 BYTEBITS();
@@ -807,14 +810,12 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             DROPBITS(1);
             switch (BITS(2)) {
             case 0:                             /* stored block */
-                Tracev((stderr, "inflate:     stored block%s\n",
-                        state->last ? " (last)" : ""));
+                Tracev((stderr, "inflate:     stored block%s\n", state->last ? " (last)" : ""));
                 state->mode = STORED;
                 break;
             case 1:                             /* fixed block */
                 fixedtables(state);
-                Tracev((stderr, "inflate:     fixed codes block%s\n",
-                        state->last ? " (last)" : ""));
+                Tracev((stderr, "inflate:     fixed codes block%s\n", state->last ? " (last)" : ""));
                 state->mode = LEN_;             /* decode codes */
                 if (flush == Z_TREES) {
                     DROPBITS(2);
@@ -822,8 +823,7 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                 }
                 break;
             case 2:                             /* dynamic block */
-                Tracev((stderr, "inflate:     dynamic codes block%s\n",
-                        state->last ? " (last)" : ""));
+                Tracev((stderr, "inflate:     dynamic codes block%s\n", state->last ? " (last)" : ""));
                 state->mode = TABLE;
                 break;
             case 3:
@@ -841,11 +841,11 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                 break;
             }
             state->length = (unsigned)hold & 0xffff;
-            Tracev((stderr, "inflate:       stored length %u\n",
-                    state->length));
+            Tracev((stderr, "inflate:       stored length %u\n", state->length));
             INITBITS();
             state->mode = COPY_;
-            if (flush == Z_TREES) goto inf_leave;
+            if (flush == Z_TREES)
+                goto inf_leave;
         case COPY_:
             state->mode = COPY;
         case COPY:
@@ -894,8 +894,7 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             state->next = state->codes;
             state->lencode = (const code *)(state->next);
             state->lenbits = 7;
-            ret = inflate_table(CODES, state->lens, 19, &(state->next),
-                                &(state->lenbits), state->work);
+            ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work);
             if (ret) {
                 strm->msg = (char *)"invalid code lengths set";
                 state->mode = BAD;
@@ -914,8 +913,7 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                 if (here.val < 16) {
                     DROPBITS(here.bits);
                     state->lens[state->have++] = here.val;
-                }
-                else {
+                } else {
                     if (here.val == 16) {
                         NEEDBITS(here.bits + 2);
                         DROPBITS(here.bits);
@@ -927,15 +925,13 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                         len = state->lens[state->have - 1];
                         copy = 3 + BITS(2);
                         DROPBITS(2);
-                    }
-                    else if (here.val == 17) {
+                    } else if (here.val == 17) {
                         NEEDBITS(here.bits + 3);
                         DROPBITS(here.bits);
                         len = 0;
                         copy = 3 + BITS(3);
                         DROPBITS(3);
-                    }
-                    else {
+                    } else {
                         NEEDBITS(here.bits + 7);
                         DROPBITS(here.bits);
                         len = 0;
@@ -953,7 +949,8 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             }
 
             /* handle error breaks in while */
-            if (state->mode == BAD) break;
+            if (state->mode == BAD)
+                break;
 
             /* check for end-of-block code (better have one) */
             if (state->lens[256] == 0) {
@@ -968,8 +965,7 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             state->next = state->codes;
             state->lencode = (const code *)(state->next);
             state->lenbits = 9;
-            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
-                                &(state->lenbits), state->work);
+            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work);
             if (ret) {
                 strm->msg = (char *)"invalid literal/lengths set";
                 state->mode = BAD;
@@ -986,7 +982,8 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             }
             Tracev((stderr, "inflate:       codes ok\n"));
             state->mode = LEN_;
-            if (flush == Z_TREES) goto inf_leave;
+            if (flush == Z_TREES)
+                goto inf_leave;
         case LEN_:
             state->mode = LEN;
         case LEN:
@@ -1001,15 +998,16 @@ int ZEXPORT inflate(z_stream *strm, int flush)
             state->back = 0;
             for (;;) {
                 here = state->lencode[BITS(state->lenbits)];
-                if ((unsigned)(here.bits) <= bits) break;
+                if ((unsigned)(here.bits) <= bits)
+                    break;
                 PULLBYTE();
             }
             if (here.op && (here.op & 0xf0) == 0) {
                 last = here;
                 for (;;) {
-                    here = state->lencode[last.val +
-                            (BITS(last.bits + last.op) >> last.bits)];
-                    if ((unsigned)(last.bits + here.bits) <= bits) break;
+                    here = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)];
+                    if ((unsigned)(last.bits + here.bits) <= bits)
+                        break;
                     PULLBYTE();
                 }
                 DROPBITS(last.bits);
@@ -1051,15 +1049,16 @@ int ZEXPORT inflate(z_stream *strm, int flush)
         case DIST:
             for (;;) {
                 here = state->distcode[BITS(state->distbits)];
-                if ((unsigned)(here.bits) <= bits) break;
+                if ((unsigned)(here.bits) <= bits)
+                    break;
                 PULLBYTE();
             }
             if ((here.op & 0xf0) == 0) {
                 last = here;
                 for (;;) {
-                    here = state->distcode[last.val +
-                            (BITS(last.bits + last.op) >> last.bits)];
-                    if ((unsigned)(last.bits + here.bits) <= bits) break;
+                    here = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)];
+                    if ((unsigned)(last.bits + here.bits) <= bits)
+                        break;
                     PULLBYTE();
                 }
                 DROPBITS(last.bits);
@@ -1105,39 +1104,45 @@ int ZEXPORT inflate(z_stream *strm, int flush)
 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
                     Trace((stderr, "inflate.c too far\n"));
                     copy -= state->whave;
-                    if (copy > state->length) copy = state->length;
-                    if (copy > left) copy = left;
+                    if (copy > state->length)
+                        copy = state->length;
+                    if (copy > left)
+                        copy = left;
                     left -= copy;
                     state->length -= copy;
                     do {
                         *put++ = 0;
                     } while (--copy);
-                    if (state->length == 0) state->mode = LEN;
+                    if (state->length == 0)
+                        state->mode = LEN;
                     break;
 #endif
                 }
                 if (copy > state->wnext) {
                     copy -= state->wnext;
                     from = state->window + (state->wsize - copy);
-                }
-                else
+                } else {
                     from = state->window + (state->wnext - copy);
-                if (copy > state->length) copy = state->length;
-            }
-            else {                              /* copy from output */
+                }
+                if (copy > state->length)
+                    copy = state->length;
+            } else {                             /* copy from output */
                 from = put - state->offset;
                 copy = state->length;
             }
-            if (copy > left) copy = left;
+            if (copy > left)
+                copy = left;
             left -= copy;
             state->length -= copy;
             do {
                 *put++ = *from++;
             } while (--copy);
-            if (state->length == 0) state->mode = LEN;
+            if (state->length == 0)
+                state->mode = LEN;
             break;
         case LIT:
-            if (left == 0) goto inf_leave;
+            if (left == 0)
+                goto inf_leave;
             *put++ = (unsigned char)(state->length);
             left--;
             state->mode = LEN;
@@ -1149,8 +1154,7 @@ int ZEXPORT inflate(z_stream *strm, int flush)
                 strm->total_out += out;
                 state->total += out;
                 if (out)
-                    strm->adler = state->check =
-                        UPDATE(state->check, put - out, out);
+                    strm->adler = state->check = UPDATE(state->check, put - out, out);
                 out = left;
                 if ((
 #ifdef GUNZIP
@@ -1200,69 +1204,65 @@ int ZEXPORT inflate(z_stream *strm, int flush)
      */
   inf_leave:
     RESTORE();
-    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
-            (state->mode < CHECK || flush != Z_FINISH)))
+    if (state->wsize || (out != strm->avail_out && state->mode < BAD && (state->mode < CHECK || flush != Z_FINISH))) {
         if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
             state->mode = MEM;
             return Z_MEM_ERROR;
         }
+    }
     in -= strm->avail_in;
     out -= strm->avail_out;
     strm->total_in += in;
     strm->total_out += out;
     state->total += out;
     if (state->wrap && out)
-        strm->adler = state->check =
-            UPDATE(state->check, strm->next_out - out, out);
+        strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out);
     strm->data_type = state->bits + (state->last ? 64 : 0) +
-                      (state->mode == TYPE ? 128 : 0) +
-                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
+                      (state->mode == TYPE ? 128 : 0) + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
     if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
         ret = Z_BUF_ERROR;
     return ret;
 }
 
-int ZEXPORT inflateEnd(z_stream *strm)
-{
+int ZEXPORT inflateEnd(z_stream *strm) {
     struct inflate_state *state;
     if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
         return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
-    if (state->window != Z_NULL) ZFREE(strm, state->window);
+    if (state->window != Z_NULL)
+        ZFREE(strm, state->window);
     ZFREE(strm, strm->state);
     strm->state = Z_NULL;
     Tracev((stderr, "inflate: end\n"));
     return Z_OK;
 }
 
-int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, uInt *dictLength)
-{
+int ZEXPORT inflateGetDictionary(z_stream *strm, unsigned char *dictionary, uInt *dictLength) {
     struct inflate_state *state;
 
     /* check state */
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
 
     /* copy dictionary */
     if (state->whave && dictionary != Z_NULL) {
-        memcpy(dictionary, state->window + state->wnext,
-                state->whave - state->wnext);
-        memcpy(dictionary + state->whave - state->wnext,
-                state->window, state->wnext);
+        memcpy(dictionary, state->window + state->wnext, state->whave - state->wnext);
+        memcpy(dictionary + state->whave - state->wnext, state->window, state->wnext);
     }
     if (dictLength != Z_NULL)
         *dictLength = state->whave;
     return Z_OK;
 }
 
-int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, uInt dictLength)
-{
+int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary, uInt dictLength) {
     struct inflate_state *state;
     uint32_t dictid;
     int ret;
 
     /* check state */
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     if (state->wrap != 0 && state->mode != DICT)
         return Z_STREAM_ERROR;
@@ -1287,14 +1287,15 @@ int ZEXPORT inflateSetDictionary(z_stream *strm, const unsigned char *dictionary
     return Z_OK;
 }
 
-int ZEXPORT inflateGetHeader(z_stream *strm, gz_headerp head)
-{
+int ZEXPORT inflateGetHeader(z_stream *strm, gz_headerp head) {
     struct inflate_state *state;
 
     /* check state */
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
-    if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
+    if ((state->wrap & 2) == 0)
+        return Z_STREAM_ERROR;
 
     /* save header structure */
     state->head = head;
@@ -1313,8 +1314,7 @@ int ZEXPORT inflateGetHeader(z_stream *strm, gz_headerp head)
    called again with more data and the *have state.  *have is initialized to
    zero for the first call.
  */
-local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len)
-{
+local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len) {
     unsigned got;
     unsigned next;
 
@@ -1333,17 +1333,18 @@ local unsigned syncsearch(unsigned *have, const unsigned char *buf, unsigned len
     return next;
 }
 
-int ZEXPORT inflateSync(z_stream *strm)
-{
+int ZEXPORT inflateSync(z_stream *strm) {
     unsigned len;               /* number of bytes to look at or looked at */
     size_t in, out;             /* temporary to save total_in and total_out */
     unsigned char buf[4];       /* to restore bit buffer to byte string */
     struct inflate_state *state;
 
     /* check parameters */
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
-    if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
+    if (strm->avail_in == 0 && state->bits < 8)
+        return Z_BUF_ERROR;
 
     /* if first time, start search in bit buffer */
     if (state->mode != SYNC) {
@@ -1367,10 +1368,13 @@ int ZEXPORT inflateSync(z_stream *strm)
     strm->total_in += len;
 
     /* return no joy or set up to restart inflate() on a new block */
-    if (state->have != 4) return Z_DATA_ERROR;
-    in = strm->total_in;  out = strm->total_out;
+    if (state->have != 4)
+        return Z_DATA_ERROR;
+    in = strm->total_in;
+    out = strm->total_out;
     inflateReset(strm);
-    strm->total_in = in;  strm->total_out = out;
+    strm->total_in = in;
+    strm->total_out = out;
     state->mode = TYPE;
     return Z_OK;
 }
@@ -1383,17 +1387,16 @@ int ZEXPORT inflateSync(z_stream *strm)
    block. When decompressing, PPP checks that at the end of input packet,
    inflate is waiting for these length bytes.
  */
-int ZEXPORT inflateSyncPoint(z_stream *strm)
-{
+int ZEXPORT inflateSyncPoint(z_stream *strm) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     return state->mode == STORED && state->bits == 0;
 }
 
-int ZEXPORT inflateCopy(z_stream *dest, z_stream *source)
-{
+int ZEXPORT inflateCopy(z_stream *dest, z_stream *source) {
     struct inflate_state *state;
     struct inflate_state *copy;
     unsigned char *window;
@@ -1408,11 +1411,11 @@ int ZEXPORT inflateCopy(z_stream *dest, z_stream *source)
     /* allocate space */
     copy = (struct inflate_state *)
            ZALLOC(source, 1, sizeof(struct inflate_state));
-    if (copy == Z_NULL) return Z_MEM_ERROR;
+    if (copy == Z_NULL)
+        return Z_MEM_ERROR;
     window = Z_NULL;
     if (state->window != Z_NULL) {
-        window = (unsigned char *)
-                 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
+        window = (unsigned char *) ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
         if (window == Z_NULL) {
             ZFREE(source, copy);
             return Z_MEM_ERROR;
@@ -1422,8 +1425,7 @@ int ZEXPORT inflateCopy(z_stream *dest, z_stream *source)
     /* copy state */
     memcpy((void *)dest, (void *)source, sizeof(z_stream));
     memcpy((void *)copy, (void *)state, sizeof(struct inflate_state));
-    if (state->lencode >= state->codes &&
-        state->lencode <= state->codes + ENOUGH - 1) {
+    if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) {
         copy->lencode = copy->codes + (state->lencode - state->codes);
         copy->distcode = copy->codes + (state->distcode - state->codes);
     }
@@ -1437,11 +1439,11 @@ int ZEXPORT inflateCopy(z_stream *dest, z_stream *source)
     return Z_OK;
 }
 
-int ZEXPORT inflateUndermine(z_stream *strm, int subvert)
-{
+int ZEXPORT inflateUndermine(z_stream *strm, int subvert) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return Z_STREAM_ERROR;
     state = (struct inflate_state *)strm->state;
     state->sane = !subvert;
 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
@@ -1452,13 +1454,12 @@ int ZEXPORT inflateUndermine(z_stream *strm, int subvert)
 #endif
 }
 
-long ZEXPORT inflateMark(z_stream *strm)
-{
+long ZEXPORT inflateMark(z_stream *strm) {
     struct inflate_state *state;
 
-    if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
+    if (strm == Z_NULL || strm->state == Z_NULL)
+        return -1L << 16;
     state = (struct inflate_state *)strm->state;
-    return ((long)(state->back) << 16) +
-        (state->mode == COPY ? state->length :
+    return ((long)(state->back) << 16) + (state->mode == COPY ? state->length :
             (state->mode == MATCH ? state->was - state->length : 0));
 }
index 5e640c705b5c497c1250999f02c3416fe6d4debb..df58e56e237b78e9a9fe2a5567b89cb5876a738b 100644 (file)
--- a/inflate.h
+++ b/inflate.h
@@ -8,6 +8,9 @@
    subject to change. Applications should only use zlib.h.
  */
 
+#ifndef INFLATE_H_
+#define INFLATE_H_
+
 /* define NO_GZIP when compiling if you want to disable gzip header and
    trailer decoding by inflate().  NO_GZIP would be used to avoid linking in
    the crc code when it is not needed.  For shared libraries, gzip decoding
@@ -120,3 +123,5 @@ struct inflate_state {
     int back;                   /* bits back of last unprocessed length/lit */
     unsigned was;               /* initial length of match */
 };
+
+#endif /* INFLATE_H_ */
index bd651808bed0bc1936bd505fbc3fc4e87d3eba77..e02272cf8642425b78ad05fdd31cab0f543f4cfd 100644 (file)
@@ -8,8 +8,7 @@
 
 #define MAXBITS 15
 
-const char inflate_copyright[] =
-   " inflate 1.2.8.f Copyright 1995-2013 Mark Adler ";
+const char inflate_copyright[] = " inflate 1.2.8.f Copyright 1995-2013 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -30,8 +29,7 @@ const char inflate_copyright[] =
    longest code or if it is less than the shortest code.
  */
 int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes,
-                                code * *table, unsigned *bits, uint16_t  *work)
-{
+                                code * *table, unsigned *bits, uint16_t  *work) {
     unsigned len;               /* a code's length in bits */
     unsigned sym;               /* index of code symbols */
     unsigned min, max;          /* minimum and maximum code lengths */
@@ -214,12 +212,10 @@ int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes,
         if ((int)(work[sym]) < end) {
             here.op = (unsigned char)0;
             here.val = work[sym];
-        }
-        else if ((int)(work[sym]) > end) {
+        } else if ((int)(work[sym]) > end) {
             here.op = (unsigned char)(extra[work[sym]]);
             here.val = base[work[sym]];
-        }
-        else {
+        } else {
             here.op = (unsigned char)(32 + 64);         /* end of block */
             here.val = 0;
         }
@@ -240,14 +236,15 @@ int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes,
         if (incr != 0) {
             huff &= incr - 1;
             huff += incr;
-        }
-        else
+        } else {
             huff = 0;
+        }
 
         /* go to next symbol, update count, len */
         sym++;
         if (--(count[len]) == 0) {
-            if (len == max) break;
+            if (len == max)
+                break;
             len = lens[work[sym]];
         }
 
@@ -265,15 +262,15 @@ int ZLIB_INTERNAL inflate_table(codetype type, uint16_t *lens, unsigned codes,
             left = (int)(1 << curr);
             while (curr + drop < max) {
                 left -= count[curr + drop];
-                if (left <= 0) break;
+                if (left <= 0)
+                    break;
                 curr++;
                 left <<= 1;
             }
 
             /* check for enough space */
             used += 1U << curr;
-            if ((type == LENS && used > ENOUGH_LENS) ||
-                (type == DISTS && used > ENOUGH_DISTS))
+            if ((type == LENS && used > ENOUGH_LENS) || (type == DISTS && used > ENOUGH_DISTS))
                 return 1;
 
             /* point entry in root table to sub-table */
index f266235ba78e892a9af390965e97d098704930fd..eaf3df1ca660b8013a58b531e76dff27d409357b 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef INFTREES_H_
+#define INFTREES_H_
+
 /* inftrees.h -- header to use inftrees.c
  * Copyright (C) 1995-2005, 2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
@@ -59,3 +62,5 @@ typedef enum {
 
 int ZLIB_INTERNAL inflate_table (codetype type, uint16_t *lens, unsigned codes,
                                   code * *table, unsigned *bits, uint16_t *work);
+
+#endif /* INFTREES_H_ */