]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fixed formatting, 4 spaces for code intent, 2 spaces for preprocessor indent, initial...
authorNathan Moinvaziri <nathan@nathanm.com>
Wed, 8 Jan 2020 03:09:34 +0000 (19:09 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 7 Feb 2020 09:44:20 +0000 (10:44 +0100)
44 files changed:
arch/arm/armfeature.c
arch/arm/insert_string_acle.c
arch/s390/dfltcc_common.c
arch/s390/dfltcc_deflate.c
arch/s390/dfltcc_detail.h
arch/s390/dfltcc_inflate.c
arch/x86/crc_folding.c
arch/x86/deflate_quick.c
arch/x86/fill_window_sse.c
arch/x86/insert_string_sse.c
arch/x86/x86.h
cmake/archdetect.cmake
compress.c
crc32.c
deflate.c
deflate.h
deflate_medium.c
deflate_p.h
fallback_builtins.h
functable.c
gzguts.h
gzread.c
infback.c
inffast.c
inflate.c
inftrees.c
match_p.h
memcopy.h
test/example.c
test/fuzz/checksum_fuzzer.c
test/fuzz/example_dict_fuzzer.c
test/fuzz/minigzip_fuzzer.c
test/infcover.c
test/minigzip.c
test/switchlevels.c
tools/maketrees.c
trees.c
trees.h
uncompr.c
zendian.h
zlib-ng.h
zlib.h
zutil.c
zutil.h

index 7c4758b6ee11ddeeea364f1bb87cdab00111ce99..9ad9eed6387d07b160b0b9392f6d9bd5d07035f5 100644 (file)
@@ -1,39 +1,38 @@
 #include "../../zutil.h"
 
 #if defined(__linux__)
-# include <sys/auxv.h>
-# include <asm/hwcap.h>
+#  include <sys/auxv.h>
+#  include <asm/hwcap.h>
 #elif defined(_WIN32)
-# include <winapifamily.h>
+#  include <winapifamily.h>
 #endif
 
 static int arm_has_crc32() {
 #if defined(__linux__) && defined(HWCAP2_CRC32)
-  return (getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0 ? 1 : 0;
+    return (getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0 ? 1 : 0;
 #elif defined(ARM_NOCHECK_ACLE)
-  return 1;
+    return 1;
 #else
-  return 0;
+    return 0;
 #endif
 }
 
 /* AArch64 has neon. */
 #if !defined(__aarch64__) && !defined(_M_ARM64)
-static inline int arm_has_neon()
-{
- #if defined(__linux__) && defined(HWCAP_NEON)
+static inline int arm_has_neon() {
+#if defined(__linux__) && defined(HWCAP_NEON)
     return (getauxval(AT_HWCAP) & HWCAP_NEON) != 0 ? 1 : 0;
- #elif defined(_M_ARM) && defined(WINAPI_FAMILY_PARTITION)
-  #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
+#elif defined(_M_ARM) && defined(WINAPI_FAMILY_PARTITION)
+#  if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
     return 1; /* Always supported */
-  #endif
- #endif
+#  endif
+#endif
 
- #if defined(ARM_NOCHECK_NEON)
+#if defined(ARM_NOCHECK_NEON)
     return 1;
- #else
+#else
     return 0;
- #endif
+#endif
 }
 #endif
 
@@ -42,9 +41,9 @@ ZLIB_INTERNAL int arm_cpu_has_crc32;
 
 void ZLIB_INTERNAL arm_check_features(void) {
 #if defined(__aarch64__) || defined(_M_ARM64)
-  arm_cpu_has_neon = 1; /* always available */
+    arm_cpu_has_neon = 1; /* always available */
 #else
-  arm_cpu_has_neon = arm_has_neon();
+    arm_cpu_has_neon = arm_has_neon();
 #endif
-  arm_cpu_has_crc32 = arm_has_crc32();
+    arm_cpu_has_crc32 = arm_has_crc32();
 }
index 363f050b041c208a258fc752f5fdb50648d14933..b6ddc070e6cbc81fab4c8726cef5df9ea629df89 100644 (file)
@@ -43,9 +43,9 @@ Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned int count
             s->prev[p & s->w_mask] = head;
             s->head[hm] = p;
             if (p == lp)
-              ret = head;
+                ret = head;
         } else if (p == lp) {
-          ret = p;
+            ret = p;
         }
     }
     return ret;
index c662f1de2d2cf60be3735e59ee4718958840ecaf..364825e3324a60d891a4fbdccc067782382bbd3f 100644 (file)
@@ -12,8 +12,7 @@
    `posix_memalign' is not an option. Thus, we overallocate and take the
    aligned portion of the buffer.
 */
-static inline int is_dfltcc_enabled(void)
-{
+static inline int is_dfltcc_enabled(void) {
     uint64_t facilities[(DFLTCC_FACILITY / 64) + 1];
     register uint8_t r0 __asm__("r0");
 
@@ -31,8 +30,7 @@ static inline int is_dfltcc_enabled(void)
     return is_bit_set((const char *)facilities, DFLTCC_FACILITY);
 }
 
-void ZLIB_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size)
-{
+void ZLIB_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size) {
     struct dfltcc_state *dfltcc_state = (struct dfltcc_state *)((char *)strm->state + ALIGN_UP(size, 8));
     struct dfltcc_qaf_param *param = (struct dfltcc_qaf_param *)&dfltcc_state->param;
 
@@ -55,20 +53,17 @@ void ZLIB_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size)
     dfltcc_state->param.ribm = DFLTCC_RIBM;
 }
 
-void ZLIB_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size)
-{
+void ZLIB_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size) {
     return ZALLOC(strm, ALIGN_UP(items * size, 8) + sizeof(struct dfltcc_state), sizeof(unsigned char));
 }
 
-void ZLIB_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size)
-{
+void ZLIB_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size) {
     memcpy(dst, src, ALIGN_UP(size, 8) + sizeof(struct dfltcc_state));
 }
 
 static const int PAGE_ALIGN = 0x1000;
 
-void ZLIB_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size)
-{
+void ZLIB_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size) {
     void *p;
     void *w;
 
@@ -83,8 +78,7 @@ void ZLIB_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt
     return w;
 }
 
-void ZLIB_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w)
-{
+void ZLIB_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w) {
     if (w)
         ZFREE(strm, *(void **)((unsigned char *)w - sizeof(void *)));
 }
index 454a0bb3abc72e97e604a9a9042916ed0c65b137..27fc8e39454d017efe2ec3d792b98d09e2d2c648 100644 (file)
@@ -20,8 +20,7 @@
 #include "dfltcc_detail.h"
 
 static inline int dfltcc_are_params_ok(int level, uInt window_bits, int strategy, uint16_t level_mask,
-                                       int reproducible)
-{
+                                       int reproducible) {
     return (level_mask & ((uint16_t)1 << level)) != 0 &&
         (window_bits == HB_BITS) &&
         (strategy == Z_FIXED || strategy == Z_DEFAULT_STRATEGY) &&
@@ -29,8 +28,7 @@ static inline int dfltcc_are_params_ok(int level, uInt window_bits, int strategy
 }
 
 
-int ZLIB_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm)
-{
+int ZLIB_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 
@@ -48,8 +46,7 @@ int ZLIB_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm)
     return 1;
 }
 
-static inline void dfltcc_gdht(PREFIX3(streamp) strm)
-{
+static inline void dfltcc_gdht(PREFIX3(streamp) strm) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
     size_t avail_in = strm->avail_in;
@@ -57,8 +54,7 @@ static inline void dfltcc_gdht(PREFIX3(streamp) strm)
     dfltcc(DFLTCC_GDHT, param, NULL, NULL, &strm->next_in, &avail_in, NULL);
 }
 
-static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm)
-{
+static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
     size_t avail_in = strm->avail_in;
@@ -75,8 +71,7 @@ static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm)
     return cc;
 }
 
-static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0 *param)
-{
+static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0 *param) {
     deflate_state *state = (deflate_state *)strm->state;
 
     send_bits(state, bi_reverse(param->eobs >> (15 - param->eobl), param->eobl), param->eobl, state->bi_buf, state->bi_valid);
@@ -96,8 +91,7 @@ static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0
 #endif
 }
 
-int ZLIB_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result)
-{
+int ZLIB_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     struct dfltcc_param_v0 *param = &dfltcc_state->param;
@@ -280,16 +274,14 @@ again:
    fly with deflateParams, we need to convert between hardware and software
    window formats.
 */
-static int dfltcc_was_deflate_used(PREFIX3(streamp) strm)
-{
+static int dfltcc_was_deflate_used(PREFIX3(streamp) strm) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
 
     return strm->total_in > 0 || param->nt == 0 || param->hl > 0;
 }
 
-int ZLIB_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy)
-{
+int ZLIB_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     int could_deflate = dfltcc_can_deflate(strm);
@@ -308,8 +300,7 @@ int ZLIB_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int st
     return Z_STREAM_ERROR;
 }
 
-int ZLIB_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reproducible)
-{
+int ZLIB_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reproducible) {
     deflate_state *state = (deflate_state *)strm->state;
 
     return reproducible != state->reproducible && !dfltcc_was_deflate_used(strm);
@@ -318,8 +309,7 @@ int ZLIB_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reprodu
 /*
    Preloading history.
 */
-static void append_history(struct dfltcc_param_v0 *param, unsigned char *history, const unsigned char *buf, uInt count)
-{
+static void append_history(struct dfltcc_param_v0 *param, unsigned char *history, const unsigned char *buf, uInt count) {
     size_t offset;
     size_t n;
 
@@ -350,8 +340,7 @@ static void append_history(struct dfltcc_param_v0 *param, unsigned char *history
 }
 
 int ZLIB_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm,
-                                                const unsigned char *dictionary, uInt dict_length)
-{
+                                                const unsigned char *dictionary, uInt dict_length) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     struct dfltcc_param_v0 *param = &dfltcc_state->param;
@@ -361,8 +350,7 @@ int ZLIB_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm,
     return Z_OK;
 }
 
-int ZLIB_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt *dict_length)
-{
+int ZLIB_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt *dict_length) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     struct dfltcc_param_v0 *param = &dfltcc_state->param;
index 513aa954facc78a8d7b684c2ea52970e69b4abda..7c5c0945108789c843a1baecc52ebaad268e6fea 100644 (file)
@@ -46,8 +46,7 @@ typedef enum {
 #define DFLTCC_FACILITY 151
 
 static inline dfltcc_cc dfltcc(int fn, void *param,
-                               unsigned char **op1, size_t *len1, const unsigned char **op2, size_t *len2, void *hist)
-{
+                               unsigned char **op1, size_t *len1, const unsigned char **op2, size_t *len2, void *hist) {
     unsigned char *t2 = op1 ? *op1 : NULL;
     size_t t3 = len1 ? *len1 : 0;
     const unsigned char *t4 = op2 ? *op2 : NULL;
@@ -108,13 +107,11 @@ struct dfltcc_qaf_param {
 
 static_assert(sizeof(struct dfltcc_qaf_param) == 32, sizeof_struct_dfltcc_qaf_param_is_32);
 
-static inline int is_bit_set(const char *bits, int n)
-{
+static inline int is_bit_set(const char *bits, int n) {
     return bits[n / 8] & (1 << (7 - (n % 8)));
 }
 
-static inline void clear_bit(char *bits, int n)
-{
+static inline void clear_bit(char *bits, int n) {
     bits[n / 8] &= ~(1 << (7 - (n % 8)));
 }
 
@@ -175,8 +172,7 @@ struct dfltcc_param_v0 {
 
 static_assert(sizeof(struct dfltcc_param_v0) == 1536, sizeof_struct_dfltcc_param_v0_is_1536);
 
-static inline const char *oesc_msg(char *buf, int oesc)
-{
+static inline const char *oesc_msg(char *buf, int oesc) {
     if (oesc == 0x00)
         return NULL; /* Successful completion */
     else {
index 4bd73719ee0b8ac2e45d792076c0d7afa42ab43d..ad17fe88bfb10e3b7a0044f34c5bc85598ecb6a1 100644 (file)
@@ -20,8 +20,7 @@
 #include "dfltcc_inflate.h"
 #include "dfltcc_detail.h"
 
-int ZLIB_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm)
-{
+int ZLIB_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 
@@ -33,8 +32,7 @@ int ZLIB_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm)
     return is_bit_set(dfltcc_state->af.fns, DFLTCC_XPND) && is_bit_set(dfltcc_state->af.fmts, DFLTCC_FMT0);
 }
 
-static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm)
-{
+static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
     size_t avail_in = strm->avail_in;
@@ -49,8 +47,7 @@ static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm)
     return cc;
 }
 
-dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret)
-{
+dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     struct dfltcc_param_v0 *param = &dfltcc_state->param;
@@ -115,16 +112,14 @@ dfltcc_inflate_action ZLIB_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int fl
         DFLTCC_INFLATE_BREAK : DFLTCC_INFLATE_CONTINUE;
 }
 
-int ZLIB_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm)
-{
+int ZLIB_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
 
     return !param->nt;
 }
 
-int ZLIB_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm)
-{
+int ZLIB_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 
index eae7d28c312df7258de6a9cecd9842af8ff9fb45..4c63b6abf1cc494d0c341d307369fc7c0d34e18a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ 
+ * Compute the CRC32 using a parallelized folding approach with the PCLMULQDQ
  * instruction.
  *
  * A white paper describing this algorithm can be found at:
index 333be3e6c25ebde9d838697d3f3628596c589758..0934913891555ebd10bd105e7dcebca00b4ebb50 100644 (file)
@@ -93,11 +93,11 @@ static inline long compare258(const unsigned char *const src0, const unsigned ch
         "cmp        $256 + 16, %[ax]\n\t"
         "jb         1b\n\t"
 
-# if !defined(__x86_64__)
+#  if !defined(__x86_64__)
         "movzwl     -16(%[src0], %[ax]), %[dx]\n\t"
-# else
+#  else
         "movzwq     -16(%[src0], %[ax]), %[dx]\n\t"
-# endif
+#  endif
         "xorw       -16(%[src1], %[ax]), %%dx\n\t"
         "jnz        3f\n\t"
 
@@ -134,19 +134,19 @@ static inline void quick_send_bits(deflate_state *const s,
     /* Concatenate the new bits with the bits currently in the buffer */
     unsigned out = s->bi_buf | (value1 << s->bi_valid);
     if (width < 32) {
-      out |= (value2 << offset2);
-      /* Shift out the valid LSBs written out. */
-      s->bi_buf = out >> (bytes_out * 8);
-    } else /* width => 32 */ {
-      unsigned bits_that_fit = 32 - offset2;
-      unsigned mask = (1 << bits_that_fit) - 1;
-      /* Zero out the high bits of value2 such that the shift by offset2 will
-         not cause undefined behavior. */
-      out |= ((value2 & mask) << offset2);
+        out |= (value2 << offset2);
+        /* Shift out the valid LSBs written out. */
+        s->bi_buf = out >> (bytes_out * 8);
+    } else { /* width => 32 */
+        unsigned bits_that_fit = 32 - offset2;
+        unsigned mask = (1 << bits_that_fit) - 1;
+        /* Zero out the high bits of value2 such that the shift by offset2 will
+           not cause undefined behavior. */
+        out |= ((value2 & mask) << offset2);
 
-      /* Save in s->bi_buf the bits of value2 that do not fit: they will be
-         written in a next full byte. */
-      s->bi_buf = (width == 32) ? 0 : value2 >> bits_that_fit;
+        /* Save in s->bi_buf the bits of value2 that do not fit: they will be
+           written in a next full byte. */
+        s->bi_buf = (width == 32) ? 0 : value2 >> bits_that_fit;
     }
 
     s->bi_valid = width - (bytes_out * 8);
index 4a4f5fa2bedc43a083893f800c5bb076073b9df3..275a2d11c0706dfe6bf5a26fa4b328bb11d34b9a 100644 (file)
@@ -95,9 +95,9 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) {
             }
 #else
             unsigned int count;
-            if (UNLIKELY(s->lookahead == 1)){
+            if (UNLIKELY(s->lookahead == 1)) {
                 count = s->insert - 1;
-            }else{
+            } else {
                 count = s->insert;
             }
             functable.insert_string(s, str, count);
index b0cc92dd495329852f200c0883445fe09c453697..8f4e75d028b707f44e8e22926a1950b52065aa35 100644 (file)
@@ -61,9 +61,9 @@ ZLIB_INTERNAL Pos insert_string_sse(deflate_state *const s, const Pos str, unsig
             s->prev[(str+idx) & s->w_mask] = head;
             s->head[h & s->hash_mask] = str+idx;
             if (idx == count-1)
-              ret = head;
+                ret = head;
         } else if (idx == count - 1) {
-          ret = str + idx;
+            ret = str + idx;
         }
     }
     return ret;
index 860e64154aef59b218ad86dd9989cf5c048425ac..9d6f37569e4b2300d4740736a91e9d745e299288 100644 (file)
@@ -1,7 +1,7 @@
- /* cpu.h -- check for CPU features
- * Copyright (C) 2013 Intel Corporation Jim Kukunas
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
+/* cpu.h -- check for CPU features
+* Copyright (C) 2013 Intel Corporation Jim Kukunas
+* For conditions of distribution and use, see copyright notice in zlib.h
+*/
 
 #ifndef CPU_H_
 #define CPU_H_
index 9a8b9881e2d9907b787dad53ad36787d1b458fcd..3c87fddfd6a554170e159661623a8419c9a5e2dc 100644 (file)
@@ -45,7 +45,6 @@ else()
     message(STATUS "Arch detected: '${ARCH}'")
 endif()
 
-
 # Base arch detection
 if("${ARCH}" MATCHES "(x86_64|AMD64|i[3-6]86)")
     set(BASEARCH "x86")
index 6b493fda50afa63211b53f0bde1901b8882a9f0f..5adcf653c202d5c9a705703a463edd9361788378 100644 (file)
@@ -8,9 +8,9 @@
 #define ZLIB_INTERNAL
 #include "zbuild.h"
 #if defined(ZLIB_COMPAT)
-# include "zlib.h"
+#  include "zlib.h"
 #else
-# include "zlib-ng.h"
+#  include "zlib-ng.h"
 #endif
 
 /* ===========================================================================
diff --git a/crc32.c b/crc32.c
index 557067e4bed02166d9147d9c1134ed39420eea38..5570b585e8c9cf556199ff54efd9974c89dbab68 100644 (file)
--- a/crc32.c
+++ b/crc32.c
@@ -42,8 +42,7 @@ uint32_t ZEXPORT PREFIX(crc32_z)(uint32_t crc, const unsigned char *buf, size_t
 #define DO4 DO1; DO1; DO1; DO1
 
 /* ========================================================================= */
-ZLIB_INTERNAL uint32_t crc32_generic(uint32_t crc, const unsigned char *buf, uint64_t len)
-{
+ZLIB_INTERNAL uint32_t crc32_generic(uint32_t crc, const unsigned char *buf, uint64_t len) {
     crc = crc ^ 0xffffffff;
 
 #ifdef UNROLL_MORE
@@ -224,8 +223,8 @@ ZLIB_INTERNAL void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsi
 }
 
 /* ========================================================================= */
-static void crc32_combine_gen_(uint32_t *op, z_off64_t len2)
-{
+
+static void crc32_combine_gen_(uint32_t *op, z_off64_t len2) {
     uint32_t row;
     int j;
     unsigned i;
@@ -267,18 +266,16 @@ static void crc32_combine_gen_(uint32_t *op, z_off64_t len2)
 }
 
 /* ========================================================================= */
-void ZEXPORT PREFIX(crc32_combine_gen)(uint32_t *op, z_off_t len2)
-{
+
+void ZEXPORT PREFIX(crc32_combine_gen)(uint32_t *op, z_off_t len2) {
     crc32_combine_gen_(op, len2);
 }
 
-void ZEXPORT PREFIX(crc32_combine_gen64)(uint32_t *op, z_off64_t len2)
-{
+void ZEXPORT PREFIX(crc32_combine_gen64)(uint32_t *op, z_off64_t len2) {
     crc32_combine_gen_(op, len2);
 }
 
 /* ========================================================================= */
-uint32_t ZEXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t *op)
-{
+uint32_t ZEXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t *op) {
     return gf2_matrix_times(op, crc1) ^ crc2;
 }
index 61c51f6f7d8ad7a266b0429140b6a95629955676..40f037fd73deeb4e2fb83e77303078a4b6ee1fab 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -203,52 +203,52 @@ ZLIB_INTERNAL void slide_hash_c(deflate_state *s) {
     n = s->hash_size;
     p = &s->head[n];
 #ifdef NOT_TWEAK_COMPILER
-            do {
-                unsigned m;
-                m = *--p;
-                *p = (Pos)(m >= wsize ? m-wsize : NIL);
-            } while (--n);
+    do {
+        unsigned m;
+        m = *--p;
+        *p = (Pos)(m >= wsize ? m-wsize : NIL);
+    } while (--n);
 #else
-            /* As of I make this change, gcc (4.8.*) isn't able to vectorize
-             * this hot loop using saturated-subtraction on x86-64 architecture.
-             * To avoid this defect, we can change the loop such that
-             *    o. the pointer advance forward, and
-             *    o. demote the variable 'm' to be local to the loop, and
-             *       choose type "Pos" (instead of 'unsigned int') for the
-             *       variable to avoid unncessary zero-extension.
-             */
-            {
-                unsigned int i;
-                Pos *q = p - n;
-                for (i = 0; i < n; i++) {
-                    Pos m = *q;
-                    Pos t = wsize;
-                    *q++ = (Pos)(m >= t ? m-t: NIL);
-                }
-            }
+    /* As of I make this change, gcc (4.8.*) isn't able to vectorize
+     * this hot loop using saturated-subtraction on x86-64 architecture.
+     * To avoid this defect, we can change the loop such that
+     *    o. the pointer advance forward, and
+     *    o. demote the variable 'm' to be local to the loop, and
+     *       choose type "Pos" (instead of 'unsigned int') for the
+     *       variable to avoid unncessary zero-extension.
+     */
+    {
+        unsigned int i;
+        Pos *q = p - n;
+        for (i = 0; i < n; i++) {
+            Pos m = *q;
+            Pos t = wsize;
+            *q++ = (Pos)(m >= t ? m-t: NIL);
+        }
+    }
 
 #endif /* NOT_TWEAK_COMPILER */
-            n = wsize;
-            p = &s->prev[n];
+    n = wsize;
+    p = &s->prev[n];
 #ifdef NOT_TWEAK_COMPILER
-            do {
-                unsigned m;
-                m = *--p;
-                *p = (Pos)(m >= wsize ? m-wsize : NIL);
-                /* If n is not on any hash chain, prev[n] is garbage but
-                 * its value will never be used.
-                 */
-            } while (--n);
+    do {
+        unsigned m;
+        m = *--p;
+        *p = (Pos)(m >= wsize ? m-wsize : NIL);
+        /* If n is not on any hash chain, prev[n] is garbage but
+         * its value will never be used.
+         */
+    } while (--n);
 #else
-            {
-                unsigned int i;
-                Pos *q = p - n;
-                for (i = 0; i < n; i++) {
-                    Pos m = *q;
-                    Pos t = wsize;
-                    *q++ = (Pos)(m >= t ? m-t: NIL);
-                }
-            }
+    {
+        unsigned int i;
+        Pos *q = p - n;
+        for (i = 0; i < n; i++) {
+            Pos m = *q;
+            Pos t = wsize;
+            *q++ = (Pos)(m >= t ? m-t: NIL);
+        }
+    }
 #endif /* NOT_TWEAK_COMPILER */
 }
 
@@ -498,7 +498,7 @@ int ZEXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const unsigned c
 }
 
 /* ========================================================================= */
-int ZEXPORT PREFIX(deflateGetDictionary)(PREFIX3(stream) *strm, unsigned char *dictionary, unsigned int  *dictLength) {
+int ZEXPORT PREFIX(deflateGetDictionary)(PREFIX3(stream) *strm, unsigned char *dictionary, unsigned int *dictLength) {
     deflate_state *s;
     unsigned int len;
 
@@ -825,10 +825,10 @@ int ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int flush) {
             return Z_OK;
         }
 
-    /* Make sure there is something to do and avoid duplicate consecutive
-     * flushes. For repeated and useless calls with Z_FINISH, we keep
-     * returning Z_STREAM_END instead of Z_BUF_ERROR.
-     */
+        /* Make sure there is something to do and avoid duplicate consecutive
+         * flushes. For repeated and useless calls with Z_FINISH, we keep
+         * returning Z_STREAM_END instead of Z_BUF_ERROR.
+         */
     } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
                flush != Z_FINISH) {
         ERR_RETURN(strm, Z_BUF_ERROR);
@@ -900,8 +900,7 @@ int ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int flush) {
                 s->last_flush = -1;
                 return Z_OK;
             }
-        }
-        else {
+        } else {
             put_byte(s, (s->gzhead->text ? 1 : 0) +
                      (s->gzhead->hcrc ? 2 : 0) +
                      (s->gzhead->extra == NULL ? 0 : 4) +
@@ -1069,8 +1068,8 @@ int ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int flush) {
             }
             flush_pending(strm);
             if (strm->avail_out == 0) {
-              s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
-              return Z_OK;
+                s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
+                return Z_OK;
             }
         }
     }
@@ -1335,9 +1334,9 @@ void ZLIB_INTERNAL fill_window_c(deflate_state *s) {
             }
 #else
             unsigned int count;
-            if (UNLIKELY(s->lookahead == 1)){
+            if (UNLIKELY(s->lookahead == 1)) {
                 count = s->insert - 1;
-            }else{
+            } else {
                 count = s->insert;
             }
             functable.insert_string(s,str,count);
@@ -1499,8 +1498,7 @@ static block_state deflate_stored(deflate_state *s, int flush) {
             memcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
             s->strstart = s->w_size;
             s->insert = s->strstart;
-        }
-        else {
+        } else {
             if (s->window_size - s->strstart <= used) {
                 /* Slide the window down. */
                 s->strstart -= s->w_size;
index f8ae93585b6d50ce8f361d73d4526267abe830b9..2806d92ad3e271e5c8b125a52ac80b88aa1e705b 100644 (file)
--- a/deflate.h
+++ b/deflate.h
@@ -154,9 +154,9 @@ typedef struct internal_state {
     unsigned int  hash_bits;         /* log2(hash_size) */
     unsigned int  hash_mask;         /* hash_size-1 */
 
-    #if !defined(__x86_64__) && !defined(_M_X64) && !defined(__i386) && !defined(_M_IX86)
+#if !defined(__x86_64__) && !defined(_M_X64) && !defined(__i386) && !defined(_M_IX86)
     unsigned int  hash_shift;
-    #endif
+#endif
     /* Number of bits by which ins_h must be shifted at each input
      * step. It must be such that after MIN_MATCH steps, the oldest
      * byte no longer takes part in the hash key, that is:
@@ -300,7 +300,9 @@ typedef enum {
 /* Output a byte on the stream.
  * IN assertion: there is enough room in pending_buf.
  */
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (unsigned char)(c);}
+#define put_byte(s, c) { \
+    s->pending_buf[s->pending++] = (unsigned char)(c); \
+}
 
 /* ===========================================================================
  * Output a short LSB first on the stream.
@@ -308,10 +310,10 @@ typedef enum {
  */
 static inline void put_short(deflate_state *s, uint16_t w) {
 #if BYTE_ORDER == BIG_ENDIAN
-  w = ZSWAP16(w);
+    w = ZSWAP16(w);
 #endif
-  memcpy(&(s->pending_buf[s->pending]), &w, sizeof(uint16_t));
-  s->pending += 2;
+    memcpy(&(s->pending_buf[s->pending]), &w, sizeof(uint16_t));
+    s->pending += 2;
 }
 
 #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
@@ -352,10 +354,10 @@ void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm);
 #ifndef ZLIB_DEBUG
 /* Inline versions of _tr_tally for speed: */
 
-  extern const unsigned char ZLIB_INTERNAL zng_length_code[];
-  extern const unsigned char ZLIB_INTERNAL zng_dist_code[];
+extern const unsigned char ZLIB_INTERNAL zng_length_code[];
+extern const unsigned char ZLIB_INTERNAL zng_dist_code[];
 
-# define zng_tr_tally_lit(s, c, flush) \
+#  define zng_tr_tally_lit(s, c, flush) \
   { unsigned char cc = (c); \
     s->sym_buf[s->sym_next++] = 0; \
     s->sym_buf[s->sym_next++] = 0; \
@@ -363,7 +365,7 @@ void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm);
     s->dyn_ltree[cc].Freq++; \
     flush = (s->sym_next == s->sym_end); \
   }
-# define zng_tr_tally_dist(s, distance, length, flush) \
+#  define zng_tr_tally_dist(s, distance, length, flush) \
   { unsigned char len = (unsigned char)(length); \
     unsigned dist = (unsigned)(distance); \
     s->sym_buf[s->sym_next++] = dist; \
@@ -375,8 +377,8 @@ void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm);
     flush = (s->sym_next == s->sym_end); \
   }
 #else
-#   define zng_tr_tally_lit(s, c, flush) flush = zng_tr_tally(s, 0, c)
-#   define zng_tr_tally_dist(s, distance, length, flush) \
+#  define zng_tr_tally_lit(s, c, flush) flush = zng_tr_tally(s, 0, c)
+#  define zng_tr_tally_dist(s, distance, length, flush) \
               flush = zng_tr_tally(s, (unsigned)(distance), (unsigned)(length))
 #endif
 
@@ -388,13 +390,13 @@ void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm);
  */
 
 #ifdef NOT_TWEAK_COMPILER
-#define TRIGGER_LEVEL 6
+#  define TRIGGER_LEVEL 6
 #else
-#define TRIGGER_LEVEL 5
+#  define TRIGGER_LEVEL 5
 #endif
 
 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
-#define UPDATE_HASH(s, h, i) \
+#  define UPDATE_HASH(s, h, i) \
     do {\
         if (s->level < TRIGGER_LEVEL) \
             h = (3483 * (s->window[i]) +\
@@ -407,30 +409,32 @@ void ZLIB_INTERNAL flush_pending(PREFIX3(streamp) strm);
                  25811* (s->window[i+2])) & s->hash_mask;\
     } while (0)
 #else
-#   define UPDATE_HASH(s, h, i) (h = (((h) << s->hash_shift) ^ (s->window[i + (MIN_MATCH-1)])) & s->hash_mask)
+#  define UPDATE_HASH(s, h, i) \
+    (h = (((h) << s->hash_shift) ^ (s->window[i + (MIN_MATCH-1)])) & s->hash_mask)
 #endif
 
 #ifdef ZLIB_DEBUG
-    #define send_code(s, c, tree, bit_buf, bits_valid) { \
+#  define send_code(s, c, tree, bit_buf, bits_valid) { \
         if (z_verbose > 2) { \
            fprintf(stderr, "\ncd %3d ", (c)); \
         } \
         send_bits(s, tree[c].Code, tree[c].Len, bit_buf, bits_valid); \
     }
 #else /* ZLIB_DEBUG */
-    /* Send a code of the given tree. c and tree must not have side effects */
-    #define send_code(s, c, tree, bit_buf, bits_valid) send_bits(s, tree[c].Code, tree[c].Len, bit_buf, bits_valid)
+/* Send a code of the given tree. c and tree must not have side effects */
+#  define send_code(s, c, tree, bit_buf, bits_valid) \
+        send_bits(s, tree[c].Code, tree[c].Len, bit_buf, bits_valid)
 #endif
 
 
 #ifdef ZLIB_DEBUG
-    #define send_debug_trace(s, value, length) {\
+#  define send_debug_trace(s, value, length) {\
         Tracevv((stderr, " l %2d v %4x ", length, value));\
         Assert(length > 0 && length <= 15, "invalid length");\
         s->bits_sent += (unsigned long)length;\
     }
 #else
-    #define send_debug_trace(s, value, length) {}
+#  define send_debug_trace(s, value, length) {}
 #endif
 
 /* If not enough room in bit_buf, use (valid) bits from bit_buf and
index f320c3c8fa6080c160cfef74b1bd58dc655c4f47..f694facdd6f14ba6568430edfadbcdf8ef4b346f 100644 (file)
@@ -129,9 +129,9 @@ static void insert_match(deflate_state *s, struct match match) {
 #warning    Call insert_string() MIN_MATCH-3 more times
 #endif
 #endif
-    /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
-     * matter since it will be recomputed at next deflate call.
-     */
+        /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
+         * matter since it will be recomputed at next deflate call.
+         */
     }
 }
 
index b282baece5e5af2138fa2926695fac53479a34bc..1e0b34dc062168e3036a03ba089662af78897344 100644 (file)
@@ -36,12 +36,12 @@ static inline Pos insert_string_c(deflate_state *const s, const Pos str, unsigne
 
         Pos head = s->head[s->ins_h];
         if (head != str+idx) {
-          s->prev[(str+idx) & s->w_mask] = head;
-          s->head[s->ins_h] = str+idx;
-          if (idx == count - 1)
-            ret = head;
+            s->prev[(str+idx) & s->w_mask] = head;
+            s->head[s->ins_h] = str+idx;
+            if (idx == count - 1)
+                ret = head;
         } else if (idx == count - 1) {
-          ret = str + idx;
+            ret = str + idx;
         }
     }
     return ret;
index 3f7005ce4de738fda8d50c2077eacbbb50b431b8..3598b7c913d3f946293abaafc82f4895f74ea349 100644 (file)
@@ -3,15 +3,14 @@
 
 #include <intrin.h>
 #ifdef X86_CPUID
-# include "arch/x86/x86.h"
+#  include "arch/x86/x86.h"
 #endif
 
 #if defined(_MSC_VER) && !defined(__clang__)
 /* This is not a general purpose replacement for __builtin_ctzl. The function expects that value is != 0
  * Because of that assumption trailing_zero is not initialized and the return value of _BitScanForward is not checked
  */
-static __forceinline unsigned long __builtin_ctzl(unsigned long value)
-{
+static __forceinline unsigned long __builtin_ctzl(unsigned long value) {
 #ifdef X86_CPUID
     if (x86_cpu_has_tzcnt)
         return _tzcnt_u32(value);
index fcdd34cd9bca584dedfbf3541e500ba68228586a..2519744d1bebce580498e04759117d72867a173e 100644 (file)
@@ -62,78 +62,77 @@ ZLIB_INTERNAL void slide_hash_stub(deflate_state *s);
 
 /* functable init */
 ZLIB_INTERNAL __thread struct functable_s functable = {
-                                            fill_window_stub,
-                                            insert_string_stub,
-                                            adler32_stub,
-                                            crc32_stub,
-                                            slide_hash_stub
-                                          };
+    fill_window_stub,
+    insert_string_stub,
+    adler32_stub,
+    crc32_stub,
+    slide_hash_stub
+};
 
 
 /* stub functions */
 ZLIB_INTERNAL Pos insert_string_stub(deflate_state *const s, const Pos str, unsigned int count) {
     // Initialize default
-    functable.insert_string=&insert_string_c;
+    functable.insert_string = &insert_string_c;
 
-    #ifdef X86_SSE42_CRC_HASH
+#ifdef X86_SSE42_CRC_HASH
     if (x86_cpu_has_sse42)
-        functable.insert_string=&insert_string_sse;
-    #elif defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH)
+        functable.insert_string = &insert_string_sse;
+#elif defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH)
     if (arm_cpu_has_crc32)
-        functable.insert_string=&insert_string_acle;
-    #endif
+        functable.insert_string = &insert_string_acle;
+#endif
 
     return functable.insert_string(s, str, count);
 }
 
 ZLIB_INTERNAL void fill_window_stub(deflate_state *s) {
     // Initialize default
-    functable.fill_window=&fill_window_c;
+    functable.fill_window = &fill_window_c;
 
-    #if defined(X86_SSE2)
-    # if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2)
+#if defined(X86_SSE2)
+# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2)
     if (x86_cpu_has_sse2)
-    # endif
-        functable.fill_window=&fill_window_sse;
-    #elif defined(ARM_GETAUXVAL)
-        functable.fill_window=&fill_window_arm;
-    #endif
+# endif
+        functable.fill_window = &fill_window_sse;
+#elif defined(ARM_GETAUXVAL)
+    functable.fill_window = &fill_window_arm;
+#endif
 
     functable.fill_window(s);
 }
 
 ZLIB_INTERNAL void slide_hash_stub(deflate_state *s) {
     // Initialize default
-    functable.slide_hash=&slide_hash_c;
+    functable.slide_hash = &slide_hash_c;
 
-    #ifdef X86_SSE2
-    # if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2)
+#ifdef X86_SSE2
+# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2)
     if (x86_cpu_has_sse2)
-    # endif
-        functable.slide_hash=&slide_hash_sse2;
-    #endif
+# endif
+        functable.slide_hash = &slide_hash_sse2;
+#endif
 
     functable.slide_hash(s);
 }
 
 ZLIB_INTERNAL uint32_t adler32_stub(uint32_t adler, const unsigned char *buf, size_t len) {
     // Initialize default
-    functable.adler32=&adler32_c;
+    functable.adler32 = &adler32_c;
 
-    #if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && defined(ARM_NEON_ADLER32)
+#if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && defined(ARM_NEON_ADLER32)
     if (arm_cpu_has_neon)
-        functable.adler32=&adler32_neon;
-    #endif
+        functable.adler32 = &adler32_neon;
+#endif
 
     return functable.adler32(adler, buf, len);
 }
 
 ZLIB_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64_t len) {
 
-
-   Assert(sizeof(uint64_t) >= sizeof(size_t),
-          "crc32_z takes size_t but internally we have a uint64_t len");
-/* return a function pointer for optimized arches here after a capability test */
+    Assert(sizeof(uint64_t) >= sizeof(size_t),
+           "crc32_z takes size_t but internally we have a uint64_t len");
+    /* return a function pointer for optimized arches here after a capability test */
 
 #ifdef DYNAMIC_CRC_TABLE
     if (crc_table_empty)
@@ -142,18 +141,18 @@ ZLIB_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64
 
     if (sizeof(void *) == sizeof(ptrdiff_t)) {
 #if BYTE_ORDER == LITTLE_ENDIAN
-      functable.crc32=crc32_little;
+        functable.crc32 = crc32_little;
 #  if defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH)
-      if (arm_cpu_has_crc32)
-        functable.crc32=crc32_acle;
+        if (arm_cpu_has_crc32)
+            functable.crc32 = crc32_acle;
 #  endif
 #elif BYTE_ORDER == BIG_ENDIAN
-        functable.crc32=crc32_big;
+        functable.crc32 = crc32_big;
 #else
 #  error No endian defined
 #endif
     } else {
-        functable.crc32=crc32_generic;
+        functable.crc32 = crc32_generic;
     }
 
     return functable.crc32(crc, buf, len);
index 066617fe9acd3e5c29934ca141461504148442a7..0529a70a77d7ee9362dea889f9262e3743c62a81 100644 (file)
--- a/gzguts.h
+++ b/gzguts.h
@@ -29,9 +29,9 @@
 #include <fcntl.h>
 
 #if defined(ZLIB_COMPAT)
-# include "zlib.h"
+#  include "zlib.h"
 #else
-# include "zlib-ng.h"
+#  include "zlib-ng.h"
 #endif
 
 #ifdef WIN32
@@ -99,9 +99,9 @@
 /* default i/o buffer size -- double this for output when reading (this and
    twice this must be able to fit in an unsigned type) */
 #if defined(S390_DFLTCC_DEFLATE) || defined(S390_DFLTCC_INFLATE)
-#define GZBUFSIZE 262144  /* DFLTCC works faster with larger buffers */
+#  define GZBUFSIZE 262144  /* DFLTCC works faster with larger buffers */
 #else
-#define GZBUFSIZE 8192
+#  define GZBUFSIZE 8192
 #endif
 
 /* gzip modes, also provide a little integrity check on the passed structure */
index e041a38170e5b89acd55565075ea83291569dcaa..7b1030266ef361237664bc289417bd3c62405695 100644 (file)
--- a/gzread.c
+++ b/gzread.c
@@ -519,29 +519,31 @@ char * ZEXPORT PREFIX(gzgets)(gzFile file, char *buf, int len) {
        the contents, let the user worry about that) */
     str = buf;
     left = (unsigned)len - 1;
-    if (left) do {
-        /* assure that something is in the output buffer */
-        if (state->x.have == 0 && gz_fetch(state) == -1)
-            return NULL;                /* error */
-        if (state->x.have == 0) {       /* end of file */
-            state->past = 1;            /* read past end */
-            break;                      /* return what we have */
-        }
-
-        /* look for end-of-line in current output buffer */
-        n = state->x.have > left ? left : state->x.have;
-        eol = (unsigned char *)memchr(state->x.next, '\n', n);
-        if (eol != NULL)
-            n = (unsigned)(eol - state->x.next) + 1;
-
-        /* copy through end-of-line, or remainder if not found */
-        memcpy(buf, state->x.next, n);
-        state->x.have -= n;
-        state->x.next += n;
-        state->x.pos += n;
-        left -= n;
-        buf += n;
-    } while (left && eol == NULL);
+    if (left) {
+        do {
+            /* assure that something is in the output buffer */
+            if (state->x.have == 0 && gz_fetch(state) == -1)
+                return NULL;                /* error */
+            if (state->x.have == 0) {       /* end of file */
+                state->past = 1;            /* read past end */
+                break;                      /* return what we have */
+            }
+
+            /* look for end-of-line in current output buffer */
+            n = state->x.have > left ? left : state->x.have;
+            eol = (unsigned char *)memchr(state->x.next, '\n', n);
+            if (eol != NULL)
+                n = (unsigned)(eol - state->x.next) + 1;
+
+            /* copy through end-of-line, or remainder if not found */
+            memcpy(buf, state->x.next, n);
+            state->x.have -= n;
+            state->x.next += n;
+            state->x.pos += n;
+            left -= n;
+            buf += n;
+        } while (left && eol == NULL);
+    }
 
     /* return terminated string, or if nothing, end of file */
     if (buf == str)
index 50478812cdbf74358a48b77da447e9a778266e45..a98e05a35c3afede7f5eba8292c5bab235dc52c1 100644 (file)
--- a/infback.c
+++ b/infback.c
@@ -119,7 +119,7 @@ int ZEXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int windowBits, unsi
    in() should return zero on failure.  out() should return non-zero on
    failure.  If either in() or out() fails, than inflateBack() returns a
    Z_BUF_ERROR.  strm->next_in can be checked for NULL to see whether it
-   was in() or out() that caused in the error.  Otherwise,  inflateBack()
+   was in() or out() that caused in the error.  Otherwise, inflateBack()
    returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
    error, or Z_MEM_ERROR if it could not allocate memory for the state.
    inflateBack() can also return Z_STREAM_ERROR if the input parameters
index 62cb9513afdc1e6aa11004c5f1c80e7393147709..1f74967f5e1b133693257287b53b06208cfd17f9 100644 (file)
--- a/inffast.c
+++ b/inffast.c
@@ -313,11 +313,11 @@ void ZLIB_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start)
                         out = chunkmemset(out, dist, len);
 #else
                     if (len < sizeof(uint64_t))
-                      out = set_bytes(out, out - dist, dist, len);
+                        out = set_bytes(out, out - dist, dist, len);
                     else if (dist == 1)
-                      out = byte_memset(out, len);
+                        out = byte_memset(out, len);
                     else
-                      out = chunk_memset(out, out - dist, dist, len);
+                        out = chunk_memset(out, out - dist, dist, len);
 #endif
                 }
             } else if ((op & 64) == 0) {          /* 2nd level distance code */
index 2ba094798f8e78d1664d52b3db5cc918edeaee45..bfaf85fa4efdd74065c18a0b40234613fca4aecb 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -200,8 +200,7 @@ void ZLIB_INTERNAL fixedtables(struct inflate_state *state) {
     state->distbits = 5;
 }
 
-int ZLIB_INTERNAL inflate_ensure_window(struct inflate_state *state)
-{
+int ZLIB_INTERNAL inflate_ensure_window(struct inflate_state *state) {
     /* if it hasn't been done already, allocate space for the window */
     if (state->window == NULL) {
 #ifdef INFFAST_CHUNKSIZE
index 6415f79d297b0990897ed9d186db883415a1dd91..b7c0e3cb76fdfb151cb1d9c458eaa2b1f513f445 100644 (file)
@@ -30,7 +30,7 @@ const char zng_inflate_copyright[] = " inflate 1.2.11.f Copyright 1995-2016 Mark
    longest code or if it is less than the shortest code.
  */
 int ZLIB_INTERNAL zng_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 */
index 742100ac939b3c81ddb6e7149db93f36ef77449b..ab41aa29d14c64aba5a0b07952e1f6a3b5035025 100644 (file)
--- a/match_p.h
+++ b/match_p.h
@@ -33,9 +33,9 @@
 
 
 #if defined(_MSC_VER) && !defined(__clang__)
-# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) ||  defined(_M_ARM) || defined(_M_ARM64)
-#  include "fallback_builtins.h"
-# endif
+#  if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) ||  defined(_M_ARM) || defined(_M_ARM64)
+#    include "fallback_builtins.h"
+#  endif
 #endif
 
 
@@ -89,7 +89,7 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
     Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead");
     do {
         if (cur_match >= s->strstart) {
-          break;
+            break;
         }
         match = s->window + cur_match;
 
@@ -210,7 +210,7 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
     do {
         unsigned char *match;
         if (cur_match >= s->strstart) {
-          break;
+            break;
         }
         match = s->window + cur_match;
 
@@ -253,28 +253,28 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
             memcpy(&mval, match, sizeof(mval));
             memcpy(&sval, scan, sizeof(sval));
             if (mval != sval)
-              break;
+                break;
             match += sizeof(mval);
             scan += sizeof(sval);
 
             memcpy(&mval, match, sizeof(mval));
             memcpy(&sval, scan, sizeof(sval));
             if (mval != sval)
-              break;
+                break;
             match += sizeof(mval);
             scan += sizeof(sval);
 
             memcpy(&mval, match, sizeof(mval));
             memcpy(&sval, scan, sizeof(sval));
             if (mval != sval)
-              break;
+                break;
             match += sizeof(mval);
             scan += sizeof(sval);
 
             memcpy(&mval, match, sizeof(mval));
             memcpy(&sval, scan, sizeof(sval));
             if (mval != sval)
-              break;
+                break;
             match += sizeof(mval);
             scan += sizeof(sval);
         } while (scan < strend);
@@ -418,7 +418,7 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
 
     do {
         if (cur_match >= strstart) {
-          break;
+            break;
         }
 
         /* Skip to next match if the match length cannot increase
index 192fbd42b6d5438d531feda790e1455597c756df..47bfbdac78eef38cfece3ee4a01a3c44efd6ba21 100644 (file)
--- a/memcopy.h
+++ b/memcopy.h
@@ -2,35 +2,35 @@
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 #ifndef MEMCOPY_H_
- #define MEMCOPY_H_
+#define MEMCOPY_H_
 
- #include "zendian.h"
+#include "zendian.h"
 
 /* Load 64 bits from IN and place the bytes at offset BITS in the result. */
 static inline uint64_t load_64_bits(const unsigned char *in, unsigned bits) {
-  uint64_t chunk;
-  memcpy(&chunk, in, sizeof(chunk));
-
- #if BYTE_ORDER == LITTLE_ENDIAN
-  return chunk << bits;
- #else
-  return ZSWAP64(chunk) << bits;
- #endif
+    uint64_t chunk;
+    memcpy(&chunk, in, sizeof(chunk));
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+    return chunk << bits;
+#else
+    return ZSWAP64(chunk) << bits;
+#endif
 }
 
- #if defined(__ARM_NEON__) || defined(__ARM_NEON)
-  #include <arm_neon.h>
+#if defined(__ARM_NEON__) || defined(__ARM_NEON)
+#include <arm_neon.h>
 typedef uint8x16_t inffast_chunk_t;
-  #define INFFAST_CHUNKSIZE sizeof(inffast_chunk_t)
- #endif
+#define INFFAST_CHUNKSIZE sizeof(inffast_chunk_t)
+#endif
 
- #if defined(X86_SSE2)
-  #include <immintrin.h>
+#if defined(X86_SSE2)
+#include <immintrin.h>
 typedef __m128i inffast_chunk_t;
-  #define INFFAST_CHUNKSIZE sizeof(inffast_chunk_t)
- #endif
+#define INFFAST_CHUNKSIZE sizeof(inffast_chunk_t)
+#endif
 
- #ifdef INFFAST_CHUNKSIZE
+#ifdef INFFAST_CHUNKSIZE
 /*
    Ask the compiler to perform a wide, unaligned load with an machine
    instruction appropriate for the inffast_chunk_t type.
@@ -127,46 +127,46 @@ static inline unsigned char* chunkunroll(unsigned char *out, unsigned *dist, uns
 }
 
 static inline inffast_chunk_t chunkmemset_1(unsigned char *from) {
-  #if defined(X86_SSE2)
+#if defined(X86_SSE2)
     int8_t c;
     memcpy(&c, from, sizeof(c));
     return _mm_set1_epi8(c);
-  #elif defined(__ARM_NEON__) || defined(__ARM_NEON)
+#elif defined(__ARM_NEON__) || defined(__ARM_NEON)
     return vld1q_dup_u8(from);
-  #endif
+#endif
 }
 
 static inline inffast_chunk_t chunkmemset_2(unsigned char *from) {
     int16_t c;
     memcpy(&c, from, sizeof(c));
-  #if defined(X86_SSE2)
+#if defined(X86_SSE2)
     return _mm_set1_epi16(c);
-  #elif defined(__ARM_NEON__) || defined(__ARM_NEON)
+#elif defined(__ARM_NEON__) || defined(__ARM_NEON)
     return vreinterpretq_u8_s16(vdupq_n_s16(c));
-  #endif
+#endif
 }
 
 static inline inffast_chunk_t chunkmemset_4(unsigned char *from) {
     int32_t c;
     memcpy(&c, from, sizeof(c));
-  #if defined(X86_SSE2)
+#if defined(X86_SSE2)
     return _mm_set1_epi32(c);
-  #elif defined(__ARM_NEON__) || defined(__ARM_NEON)
+#elif defined(__ARM_NEON__) || defined(__ARM_NEON)
     return vreinterpretq_u8_s32(vdupq_n_s32(c));
-  #endif
+#endif
 }
 
 static inline inffast_chunk_t chunkmemset_8(unsigned char *from) {
-  #if defined(X86_SSE2)
+#if defined(X86_SSE2)
     int64_t c;
     memcpy(&c, from, sizeof(c));
     return _mm_set1_epi64x(c);
-  #elif defined(__ARM_NEON__) || defined(__ARM_NEON)
+#elif defined(__ARM_NEON__) || defined(__ARM_NEON)
     return vcombine_u8(vld1_u8(from), vld1_u8(from));
-  #endif
+#endif
 }
 
-  #if defined(__ARM_NEON__) || defined(__ARM_NEON)
+#if defined(__ARM_NEON__) || defined(__ARM_NEON)
 static inline unsigned char *chunkmemset_3(unsigned char *out, unsigned char *from, unsigned dist, unsigned len) {
     uint8x8x3_t chunks;
     unsigned sz = sizeof(chunks);
@@ -197,9 +197,9 @@ static inline unsigned char *chunkmemset_3(unsigned char *out, unsigned char *fr
     out = chunkunroll(out, &dist, &rem);
     return chunkcopy(out, out - dist, rem);
 }
-  #endif
+#endif
 
-  #if defined(__aarch64__) || defined(_M_ARM64)
+#if defined(__aarch64__) || defined(_M_ARM64)
 static inline unsigned char *chunkmemset_6(unsigned char *out, unsigned char *from, unsigned dist, unsigned len) {
     uint16x8x3_t chunks;
     unsigned sz = sizeof(chunks);
@@ -230,11 +230,11 @@ static inline unsigned char *chunkmemset_6(unsigned char *out, unsigned char *fr
     out = chunkunroll(out, &dist, &rem);
     return chunkcopy(out, out - dist, rem);
 }
-  #endif
+#endif
 
 /* Copy DIST bytes from OUT - DIST into OUT + DIST * k, for 0 <= k < LEN/DIST. Return OUT + LEN. */
 static inline unsigned char *chunkmemset(unsigned char *out, unsigned dist, unsigned len) {
-    /* Debug performance related issues when len < sizeof(uint64_t): 
+    /* Debug performance related issues when len < sizeof(uint64_t):
        Assert(len >= sizeof(uint64_t), "chunkmemset should be called on larger chunks"); */
     Assert(dist > 0, "cannot have a distance 0");
 
@@ -258,18 +258,18 @@ static inline unsigned char *chunkmemset(unsigned char *out, unsigned dist, unsi
         chunk = chunkmemset_2(from);
         break;
     }
-  #if defined(__ARM_NEON__) || defined(__ARM_NEON)
+#if defined(__ARM_NEON__) || defined(__ARM_NEON)
     case 3:
-      return chunkmemset_3(out, from, dist, len);
-  #endif
+        return chunkmemset_3(out, from, dist, len);
+#endif
     case 4: {
         chunk = chunkmemset_4(from);
         break;
     }
-  #if defined(__aarch64__) || defined(_M_ARM64)
+#if defined(__aarch64__) || defined(_M_ARM64)
     case 6:
         return chunkmemset_6(out, from, dist, len);
-  #endif
+#endif
     case 8: {
         chunk = chunkmemset_8(from);
         break;
@@ -301,9 +301,9 @@ static inline unsigned char *chunkmemset(unsigned char *out, unsigned dist, unsi
 static inline unsigned char* chunkmemsetsafe(unsigned char *out, unsigned dist, unsigned len, unsigned left) {
     if (left < (unsigned)(3 * INFFAST_CHUNKSIZE)) {
         while (len > 0) {
-          *out = *(out - dist);
-          out++;
-          --len;
+            *out = *(out - dist);
+            out++;
+            --len;
         }
         return out;
     }
@@ -311,7 +311,7 @@ static inline unsigned char* chunkmemsetsafe(unsigned char *out, unsigned dist,
     return chunkmemset(out, dist, len);
 }
 
- #else /* INFFAST_CHUNKSIZE */
+#else /* INFFAST_CHUNKSIZE */
 
 static inline unsigned char *copy_1_bytes(unsigned char *out, unsigned char *from) {
     *out++ = *from;
@@ -366,12 +366,12 @@ static inline unsigned char *copy_8_bytes(unsigned char *out, unsigned char *fro
 static inline unsigned char *copy_bytes(unsigned char *out, unsigned char *from, unsigned len) {
     Assert(len < 8, "copy_bytes should be called with less than 8 bytes");
 
- #ifndef UNALIGNED_OK
+#ifndef UNALIGNED_OK
     while (len--) {
         *out++ = *from++;
     }
     return out;
- #else
+#else
     switch (len) {
     case 7:
         return copy_7_bytes(out, from);
@@ -394,20 +394,20 @@ static inline unsigned char *copy_bytes(unsigned char *out, unsigned char *from,
     }
 
     return out;
- #endif /* UNALIGNED_OK */
+#endif /* UNALIGNED_OK */
 }
 
 /* Copy LEN bytes (7 or fewer) from FROM into OUT. Return OUT + LEN. */
 static inline unsigned char *set_bytes(unsigned char *out, unsigned char *from, unsigned dist, unsigned len) {
     Assert(len < 8, "set_bytes should be called with less than 8 bytes");
 
- #ifndef UNALIGNED_OK
+#ifndef UNALIGNED_OK
     (void)dist;
     while (len--) {
         *out++ = *from++;
     }
     return out;
- #else
+#else
     if (dist >= len)
         return copy_bytes(out, from, len);
 
@@ -498,7 +498,7 @@ static inline unsigned char *set_bytes(unsigned char *out, unsigned char *from,
         }
     }
     return out;
- #endif /* UNALIGNED_OK */
+#endif /* UNALIGNED_OK */
 }
 
 /* Byte by byte semantics: copy LEN bytes from OUT + DIST and write them to OUT. Return OUT + LEN. */
@@ -671,5 +671,5 @@ static inline unsigned char *chunk_copy(unsigned char *out, unsigned char *from,
 
     return chunk_memcpy(out, from, len);
 }
- #endif /* INFFAST_CHUNKSIZE */
+#endif /* INFFAST_CHUNKSIZE */
 #endif /* MEMCOPY_H_ */
index 8309178e0d009eeab8cacdb2e5e665397a790594..0714a291e44312f03b5eac75dc189cdff3110737 100644 (file)
@@ -56,8 +56,7 @@ static free_func zfree = NULL;
 /* ===========================================================================
  * Test compress() and uncompress()
  */
-void test_compress(unsigned char *compr, z_size_t comprLen, unsigned char *uncompr, z_size_t uncomprLen)
-{
+void test_compress(unsigned char *compr, z_size_t comprLen, unsigned char *uncompr, z_size_t uncomprLen) {
     int err;
     size_t len = strlen(hello)+1;
 
@@ -80,8 +79,7 @@ void test_compress(unsigned char *compr, z_size_t comprLen, unsigned char *uncom
 /* ===========================================================================
  * Test read/write of .gz files
  */
-void test_gzio(const char *fname, unsigned char *uncompr, z_size_t uncomprLen)
-{
+void test_gzio(const char *fname, unsigned char *uncompr, z_size_t uncomprLen) {
 #ifdef NO_GZCOMPRESS
     fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
 #else
@@ -161,8 +159,7 @@ void test_gzio(const char *fname, unsigned char *uncompr, z_size_t uncomprLen)
 /* ===========================================================================
  * Test deflate() with small buffers
  */
-void test_deflate(unsigned char *compr, size_t comprLen)
-{
+void test_deflate(unsigned char *compr, size_t comprLen) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
     size_t len = strlen(hello)+1;
@@ -199,8 +196,7 @@ void test_deflate(unsigned char *compr, size_t comprLen)
 /* ===========================================================================
  * Test inflate() with small buffers
  */
-void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
-{
+void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) {
     int err;
     PREFIX3(stream) d_stream; /* decompression stream */
 
@@ -242,8 +238,7 @@ static unsigned int diff;
 /* ===========================================================================
  * Test deflate() with large buffers and dynamic change of compression level
  */
-void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen, int zng_params)
-{
+void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen, int zng_params) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
 #ifndef ZLIB_COMPAT
@@ -346,8 +341,7 @@ void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *un
 /* ===========================================================================
  * Test inflate() with large buffers
  */
-void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
-{
+void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) {
     int err;
     PREFIX3(stream) d_stream; /* decompression stream */
 
@@ -387,8 +381,7 @@ void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *un
 /* ===========================================================================
  * Test deflate() with full flush
  */
-void test_flush(unsigned char *compr, z_size_t *comprLen)
-{
+void test_flush(unsigned char *compr, z_size_t *comprLen) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
     unsigned int len = (unsigned int)strlen(hello)+1;
@@ -423,8 +416,7 @@ void test_flush(unsigned char *compr, z_size_t *comprLen)
 /* ===========================================================================
  * Test inflateSync()
  */
-void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
-{
+void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) {
     int err;
     PREFIX3(stream) d_stream; /* decompression stream */
 
@@ -464,8 +456,7 @@ void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, si
 /* ===========================================================================
  * Test deflate() with preset dictionary
  */
-void test_dict_deflate(unsigned char *compr, size_t comprLen)
-{
+void test_dict_deflate(unsigned char *compr, size_t comprLen) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
 
@@ -500,8 +491,7 @@ void test_dict_deflate(unsigned char *compr, size_t comprLen)
 /* ===========================================================================
  * Test inflate() with a preset dictionary
  */
-void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
-{
+void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) {
     int err;
     PREFIX3(stream) d_stream; /* decompression stream */
 
@@ -548,8 +538,7 @@ void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *unc
 /* ===========================================================================
  * Test deflateBound() with small buffers
  */
-void test_deflate_bound(void)
-{
+void test_deflate_bound(void) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
     unsigned int len = (unsigned int)strlen(hello)+1;
@@ -594,8 +583,7 @@ void test_deflate_bound(void)
 /* ===========================================================================
  * Test deflateCopy() with small buffers
  */
-void test_deflate_copy(unsigned char *compr, size_t comprLen)
-{
+void test_deflate_copy(unsigned char *compr, size_t comprLen) {
     PREFIX3(stream) c_stream, c_stream_copy; /* compression stream */
     int err;
     size_t len = strlen(hello)+1;
@@ -643,8 +631,7 @@ void test_deflate_copy(unsigned char *compr, size_t comprLen)
 /* ===========================================================================
  * Test deflateGetDictionary() with small buffers
  */
-void test_deflate_get_dict(unsigned char *compr, size_t comprLen)
-{
+void test_deflate_get_dict(unsigned char *compr, size_t comprLen) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
     unsigned char *dictNew = NULL;
@@ -689,8 +676,7 @@ void test_deflate_get_dict(unsigned char *compr, size_t comprLen)
 /* ===========================================================================
  * Test deflatePending() with small buffers
  */
-void test_deflate_pending(unsigned char *compr, size_t comprLen)
-{
+void test_deflate_pending(unsigned char *compr, size_t comprLen) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
     int *bits = calloc(256, 1);
@@ -741,8 +727,7 @@ void test_deflate_pending(unsigned char *compr, size_t comprLen)
 /* ===========================================================================
  * Test deflatePrime() with small buffers
  */
-void test_deflate_prime(unsigned char *compr, size_t comprLen)
-{
+void test_deflate_prime(unsigned char *compr, size_t comprLen) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
     int bits = 0;
@@ -789,8 +774,7 @@ void test_deflate_prime(unsigned char *compr, size_t comprLen)
 /* ===========================================================================
  * Test deflateSetHeader() with small buffers
  */
-void test_deflate_set_header(unsigned char *compr, size_t comprLen)
-{
+void test_deflate_set_header(unsigned char *compr, size_t comprLen) {
     PREFIX(gz_header) *head = calloc(256, 1);
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
@@ -838,8 +822,7 @@ void test_deflate_set_header(unsigned char *compr, size_t comprLen)
 /* ===========================================================================
  * Test deflateTune() with small buffers
  */
-void test_deflate_tune(unsigned char *compr, size_t comprLen)
-{
+void test_deflate_tune(unsigned char *compr, size_t comprLen) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
     int good_length = 3;
@@ -886,8 +869,7 @@ void test_deflate_tune(unsigned char *compr, size_t comprLen)
 /* ===========================================================================
  * Usage:  example [output.gz  [input.gz]]
  */
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
     unsigned char *compr, *uncompr;
     z_size_t comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
     z_size_t uncomprLen = comprLen;
index 34163e4c973e9b1c99522dff3c32cff7c7868964..18bebc32e2a4a76d738906ea8d3c106684fda5e6 100644 (file)
 #endif
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataLen) {
-  uint32_t crc0 = PREFIX(crc32)(0L, NULL, 0);
-  uint32_t crc1 = crc0;
-  uint32_t crc2 = crc0;
-  uint32_t adler0 = PREFIX(adler32)(0L, NULL, 0);
-  uint32_t adler1 = adler0;
-  uint32_t adler2 = adler0;
-  uint32_t combine1, combine2;
-  /* Checksum with a buffer of size equal to the first byte in the input. */
-  uint32_t buffSize = data[0];
-  uint32_t offset = 0;
-  uint32_t op[32];
+    uint32_t crc0 = PREFIX(crc32)(0L, NULL, 0);
+    uint32_t crc1 = crc0;
+    uint32_t crc2 = crc0;
+    uint32_t adler0 = PREFIX(adler32)(0L, NULL, 0);
+    uint32_t adler1 = adler0;
+    uint32_t adler2 = adler0;
+    uint32_t combine1, combine2;
+    /* Checksum with a buffer of size equal to the first byte in the input. */
+    uint32_t buffSize = data[0];
+    uint32_t offset = 0;
+    uint32_t op[32];
 
-  /* Discard inputs larger than 1Mb. */
-  static size_t kMaxSize = 1024 * 1024;
-  if (dataLen < 1 || dataLen > kMaxSize)
-    return 0;
+    /* Discard inputs larger than 1Mb. */
+    static size_t kMaxSize = 1024 * 1024;
+    if (dataLen < 1 || dataLen > kMaxSize)
+        return 0;
 
-  /* Make sure the buffer has at least a byte. */
-  if (buffSize == 0)
-    ++buffSize;
+    /* Make sure the buffer has at least a byte. */
+    if (buffSize == 0)
+        ++buffSize;
 
-  /* CRC32 */
-  PREFIX(crc32_combine_gen)(op, buffSize);
-  for (offset = 0; offset + buffSize <= dataLen; offset += buffSize) {
-    uint32_t crc3 = PREFIX(crc32_z)(crc0, data + offset, buffSize);
-    uint32_t crc4 = PREFIX(crc32_combine_op)(crc1, crc3, op);
-    crc1 = PREFIX(crc32_z)(crc1, data + offset, buffSize);
-    assert(crc1 == crc4);
-    (void)crc1;
-    (void)crc4;
-  }
-  crc1 = PREFIX(crc32_z)(crc1, data + offset, dataLen % buffSize);
+    /* CRC32 */
+    PREFIX(crc32_combine_gen)(op, buffSize);
+    for (offset = 0; offset + buffSize <= dataLen; offset += buffSize) {
+        uint32_t crc3 = PREFIX(crc32_z)(crc0, data + offset, buffSize);
+        uint32_t crc4 = PREFIX(crc32_combine_op)(crc1, crc3, op);
+        crc1 = PREFIX(crc32_z)(crc1, data + offset, buffSize);
+        assert(crc1 == crc4);
+        (void)crc1;
+        (void)crc4;
+    }
+    crc1 = PREFIX(crc32_z)(crc1, data + offset, dataLen % buffSize);
 
-  crc2 = PREFIX(crc32_z)(crc2, data, dataLen);
+    crc2 = PREFIX(crc32_z)(crc2, data, dataLen);
 
-  assert(crc1 == crc2);
-  (void)crc1;
-  (void)crc2;
-  combine1 = PREFIX(crc32_combine)(crc1, crc2, (z_off_t)dataLen);
-  combine2 = PREFIX(crc32_combine)(crc1, crc1, (z_off_t)dataLen);
-  assert(combine1 == combine2);
+    assert(crc1 == crc2);
+    (void)crc1;
+    (void)crc2;
+    combine1 = PREFIX(crc32_combine)(crc1, crc2, (z_off_t)dataLen);
+    combine2 = PREFIX(crc32_combine)(crc1, crc1, (z_off_t)dataLen);
+    assert(combine1 == combine2);
 
-  /* Fast CRC32 combine. */
-  PREFIX(crc32_combine_gen)(op, (z_off_t)dataLen);
-  combine1 = PREFIX(crc32_combine_op)(crc1, crc2, op);
-  combine2 = PREFIX(crc32_combine_op)(crc2, crc1, op);
-  assert(combine1 == combine2);
-  combine1 = PREFIX(crc32_combine)(crc1, crc2, (z_off_t)dataLen);
-  combine2 = PREFIX(crc32_combine_op)(crc2, crc1, op);
-  assert(combine1 == combine2);
+    /* Fast CRC32 combine. */
+    PREFIX(crc32_combine_gen)(op, (z_off_t)dataLen);
+    combine1 = PREFIX(crc32_combine_op)(crc1, crc2, op);
+    combine2 = PREFIX(crc32_combine_op)(crc2, crc1, op);
+    assert(combine1 == combine2);
+    combine1 = PREFIX(crc32_combine)(crc1, crc2, (z_off_t)dataLen);
+    combine2 = PREFIX(crc32_combine_op)(crc2, crc1, op);
+    assert(combine1 == combine2);
 
-  /* Adler32 */
-  for (offset = 0; offset + buffSize <= dataLen; offset += buffSize)
-    adler1 = PREFIX(adler32_z)(adler1, data + offset, buffSize);
-  adler1 = PREFIX(adler32_z)(adler1, data + offset, dataLen % buffSize);
+    /* Adler32 */
+    for (offset = 0; offset + buffSize <= dataLen; offset += buffSize)
+        adler1 = PREFIX(adler32_z)(adler1, data + offset, buffSize);
+    adler1 = PREFIX(adler32_z)(adler1, data + offset, dataLen % buffSize);
 
-  adler2 = PREFIX(adler32_z)(adler2, data, dataLen);
+    adler2 = PREFIX(adler32_z)(adler2, data, dataLen);
 
-  assert(adler1 == adler2);
-  (void)adler1;
-  (void)adler2;
-  combine1 = PREFIX(adler32_combine)(adler1, adler2, (z_off_t)dataLen);
-  combine2 = PREFIX(adler32_combine)(adler1, adler1, (z_off_t)dataLen);
-  assert(combine1 == combine2);
+    assert(adler1 == adler2);
+    (void)adler1;
+    (void)adler2;
+    combine1 = PREFIX(adler32_combine)(adler1, adler2, (z_off_t)dataLen);
+    combine2 = PREFIX(adler32_combine)(adler1, adler1, (z_off_t)dataLen);
+    assert(combine1 == combine2);
 
-  /* This function must return 0. */
-  return 0;
+    /* This function must return 0. */
+    return 0;
 }
index 86e8fb8a04fc1267806845fe143230a3d05345b6..3245c2b40a3ab6e25f14d6626808a2361d470e2f 100644 (file)
@@ -30,8 +30,7 @@ static unsigned long dictId; /* Adler32 value of the dictionary */
 /* ===========================================================================
  * Test deflate() with preset dictionary
  */
-void test_dict_deflate(unsigned char **compr, size_t *comprLen)
-{
+void test_dict_deflate(unsigned char **compr, size_t *comprLen) {
     PREFIX3(stream) c_stream; /* compression stream */
     int err;
     int level = data[0] % 11 - 1; /* [-1..9]
@@ -58,7 +57,7 @@ void test_dict_deflate(unsigned char **compr, size_t *comprLen)
 
     /* deflate would fail for no-compression or for speed levels. */
     if (level == 0 || level == 1)
-      level = -1;
+        level = -1;
 
     c_stream.zalloc = zalloc;
     c_stream.zfree = zfree;
index 1a99fd7aacb71833bf444b1d19b2aae891e7938d..321f99ccd4ceabbd97b5d60fd15c89718434b91d 100644 (file)
@@ -16,9 +16,9 @@
 
 #include "zbuild.h"
 #ifdef ZLIB_COMPAT
-# include "zlib.h"
+#  include "zlib.h"
 #else
-# include "zlib-ng.h"
+#  include "zlib-ng.h"
 #endif
 #include <stdio.h>
 #include <assert.h>
@@ -49,7 +49,7 @@
 
 #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
 #ifndef WIN32 /* unlink already in stdio.h for WIN32 */
-  extern int unlink (const char *);
+extern int unlink (const char *);
 #endif
 #endif
 
@@ -77,8 +77,7 @@ int  main             (int argc, char *argv[]);
 /* ===========================================================================
  * Display error message and exit
  */
-void error(const char *msg)
-{
+void error(const char *msg) {
     fprintf(stderr, "%s: %s\n", prog, msg);
     exit(1);
 }
@@ -87,8 +86,7 @@ void error(const char *msg)
  * Compress input to output then close both files.
  */
 
-void gz_compress(FILE *in, gzFile out)
-{
+void gz_compress(FILE *in, gzFile out) {
     char buf[BUFLEN];
     int len;
     int err;
@@ -121,8 +119,7 @@ void gz_compress(FILE *in, gzFile out)
 /* Try compressing the input file at once using mmap. Return Z_OK if
  * if success, Z_ERRNO otherwise.
  */
-int gz_compress_mmap(FILE *in, gzFile out)
-{
+int gz_compress_mmap(FILE *in, gzFile out) {
     int len;
     int err;
     int ifd = fileno(in);
@@ -154,8 +151,7 @@ int gz_compress_mmap(FILE *in, gzFile out)
 /* ===========================================================================
  * Uncompress input to output then close both files.
  */
-void gz_uncompress(gzFile in, FILE *out)
-{
+void gz_uncompress(gzFile in, FILE *out) {
     char buf[BUFLENW];
     int len;
     int err;
@@ -179,10 +175,9 @@ void gz_uncompress(gzFile in, FILE *out)
  * Compress the given file: create a corresponding .gz file and remove the
  * original.
  */
-void file_compress(char *file, char *mode)
-{
+void file_compress(char *file, char *mode) {
     char outfile[MAX_NAME_LEN];
-    FILE  *in;
+    FILE *in;
     gzFile out;
 
     if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) {
@@ -211,11 +206,10 @@ void file_compress(char *file, char *mode)
 /* ===========================================================================
  * Uncompress the given file and remove the original.
  */
-void file_uncompress(char *file)
-{
+void file_uncompress(char *file) {
     char buf[MAX_NAME_LEN];
     char *infile, *outfile;
-    FILE  *out;
+    FILE *out;
     gzFile in;
     size_t len = strlen(file);
 
index 2b8ff974a3d1eb5eb1f30ed2dbd43543e13c75b2..febbf13d9560ccc2d7afc647b7233932dccaba58 100644 (file)
@@ -67,8 +67,7 @@ struct mem_zone {
 };
 
 /* memory allocation routine to pass to zlib */
-static void *mem_alloc(void *mem, unsigned count, unsigned size)
-{
+static void *mem_alloc(void *mem, unsigned count, unsigned size) {
     void *ptr;
     struct mem_item *item;
     struct mem_zone *zone = mem;
@@ -108,8 +107,7 @@ static void *mem_alloc(void *mem, unsigned count, unsigned size)
 }
 
 /* memory free routine to pass to zlib */
-static void mem_free(void *mem, void *ptr)
-{
+static void mem_free(void *mem, void *ptr) {
     struct mem_item *item, *next;
     struct mem_zone *zone = mem;
 
@@ -154,8 +152,7 @@ static void mem_free(void *mem, void *ptr)
 
 /* set up a controlled memory allocation space for monitoring, set the stream
    parameters to the controlled routines, with opaque pointing to the space */
-static void mem_setup(z_stream *strm)
-{
+static void mem_setup(z_stream *strm) {
     struct mem_zone *zone;
 
     zone = malloc(sizeof(struct mem_zone));
@@ -172,32 +169,28 @@ static void mem_setup(z_stream *strm)
 }
 
 /* set a limit on the total memory allocation, or 0 to remove the limit */
-static void mem_limit(z_stream *strm, size_t limit)
-{
+static void mem_limit(z_stream *strm, size_t limit) {
     struct mem_zone *zone = strm->opaque;
 
     zone->limit = limit;
 }
 
 /* show the current total requested allocations in bytes */
-static void mem_used(z_stream *strm, char *prefix)
-{
+static void mem_used(z_stream *strm, char *prefix) {
     struct mem_zone *zone = strm->opaque;
 
     fprintf(stderr, "%s: %zu allocated\n", prefix, zone->total);
 }
 
 /* show the high water allocation in bytes */
-static void mem_high(z_stream *strm, char *prefix)
-{
+static void mem_high(z_stream *strm, char *prefix) {
     struct mem_zone *zone = strm->opaque;
 
     fprintf(stderr, "%s: %zu high water mark\n", prefix, zone->highwater);
 }
 
 /* release the memory allocation zone -- if there are any surprises, notify */
-static void mem_done(z_stream *strm, char *prefix)
-{
+static void mem_done(z_stream *strm, char *prefix) {
     int count = 0;
     struct mem_item *item, *next;
     struct mem_zone *zone = strm->opaque;
@@ -241,8 +234,7 @@ static void mem_done(z_stream *strm, char *prefix)
    by a delimiter, where that single digit writes a byte.  The returned data is
    allocated and must eventually be freed.  NULL is returned if out of memory.
    If the length is not needed, then len can be NULL. */
-static unsigned char *h2b(const char *hex, unsigned *len)
-{
+static unsigned char *h2b(const char *hex, unsigned *len) {
     unsigned char *in, *re;
     unsigned next, val;
 
@@ -280,8 +272,7 @@ static unsigned char *h2b(const char *hex, unsigned *len)
    header information is collected with inflateGetHeader().  If a zlib stream
    is looking for a dictionary, then an empty dictionary is provided.
    inflate() is run until all of the input data is consumed. */
-static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int err)
-{
+static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int err) {
     int ret;
     unsigned have;
     unsigned char *in, *out;
@@ -345,8 +336,7 @@ static void inf(char *hex, char *what, unsigned step, int win, unsigned len, int
 }
 
 /* cover all of the lines in inflate.c up to inflate() */
-static void cover_support(void)
-{
+static void cover_support(void) {
     int ret;
     z_stream strm;
 
@@ -383,8 +373,7 @@ static void cover_support(void)
 }
 
 /* cover all inflate() header and trailer cases and code after inflate() */
-static void cover_wrap(void)
-{
+static void cover_wrap(void) {
     int ret;
     z_stream strm, copy;
     unsigned char dict[257];
@@ -442,8 +431,7 @@ static void cover_wrap(void)
 }
 
 /* input and output functions for inflateBack() */
-static unsigned pull(void *desc, const unsigned char **buf)
-{
+static unsigned pull(void *desc, const unsigned char **buf) {
     static unsigned int next = 0;
     static unsigned char dat[] = {0x63, 0, 2, 0};
     struct inflate_state *state;
@@ -458,15 +446,13 @@ static unsigned pull(void *desc, const unsigned char **buf)
     return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0;
 }
 
-static int push(void *desc, unsigned char *buf, unsigned len)
-{
+static int push(void *desc, unsigned char *buf, unsigned len) {
     buf += len;
     return desc != NULL;        /* force error if desc not null */
 }
 
 /* cover inflateBack() up to common deflate data cases and after those */
-static void cover_back(void)
-{
+static void cover_back(void) {
     int ret;
     z_stream strm;
     unsigned char win[32768];
@@ -502,8 +488,7 @@ static void cover_back(void)
 }
 
 /* do a raw inflate of data in hexadecimal with both inflate and inflateBack */
-static int try(char *hex, char *id, int err)
-{
+static int try(char *hex, char *id, int err) {
     int ret;
     unsigned len, size;
     unsigned char *in, *out, *win;
@@ -576,8 +561,7 @@ static int try(char *hex, char *id, int err)
 }
 
 /* cover deflate data cases in both inflate() and inflateBack() */
-static void cover_inflate(void)
-{
+static void cover_inflate(void) {
     try("0 0 0 0 0", "invalid stored block lengths", 1);
     try("3 0", "fixed", 0);
     try("6", "invalid block type", 1);
@@ -612,8 +596,7 @@ static void cover_inflate(void)
 }
 
 /* cover remaining lines in inftrees.c */
-static void cover_trees(void)
-{
+static void cover_trees(void) {
     int ret;
     unsigned bits;
     uint16_t lens[16], work[16];
@@ -636,8 +619,7 @@ static void cover_trees(void)
 }
 
 /* cover remaining inffast.c decoding and window copying */
-static void cover_fast(void)
-{
+static void cover_fast(void) {
     inf("e5 e0 81 ad 6d cb b2 2c c9 01 1e 59 63 ae 7d ee fb 4d fd b5 35 41 68"
         " ff 7f 0f 0 0 0", "fast length extra bits", 0, -8, 258, Z_DATA_ERROR);
     inf("25 fd 81 b5 6d 59 b6 6a 49 ea af 35 6 34 eb 8c b9 f6 b9 1e ef 67 49"
@@ -656,8 +638,7 @@ static void cover_fast(void)
         Z_STREAM_END);
 }
 
-int main(void)
-{
+int main(void) {
     fprintf(stderr, "%s\n", zlibVersion());
     cover_support();
     cover_wrap();
index 935ebb9e1fec10a18caa030b57c1e0f374ffd42c..14b2e51657677bdd211f3be60cced45442ba7378 100644 (file)
@@ -19,9 +19,9 @@
 
 #include "zbuild.h"
 #ifdef ZLIB_COMPAT
-# include "zlib.h"
+#  include "zlib.h"
 #else
-# include "zlib-ng.h"
+#  include "zlib-ng.h"
 #endif
 #include <stdio.h>
 
@@ -52,7 +52,7 @@
 
 #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
 #ifndef WIN32 /* unlink already in stdio.h for WIN32 */
-  extern int unlink (const char *);
+extern int unlink (const char *);
 #endif
 #endif
 
@@ -62,9 +62,9 @@
 #define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)
 
 #if defined(S390_DFLTCC_DEFLATE) || defined(S390_DFLTCC_INFLATE)
-#define BUFLEN      262144       /* DFLTCC works faster with larger buffers */
+#  define BUFLEN      262144     /* DFLTCC works faster with larger buffers */
 #else
-#define BUFLEN      16384        /* read buffer size */
+#  define BUFLEN      16384      /* read buffer size */
 #endif
 #define BUFLENW     (BUFLEN * 3) /* write buffer size */
 #define MAX_NAME_LEN 1024
 static char *prog;
 
 void error            (const char *msg);
-void gz_compress      (FILE   *in, gzFile out);
+void gz_compress      (FILE *in, gzFile out);
 #ifdef USE_MMAP
-int  gz_compress_mmap (FILE   *in, gzFile out);
+int  gz_compress_mmap (FILE *in, gzFile out);
 #endif
-void gz_uncompress    (gzFile in, FILE   *out);
-void file_compress    (char  *file, char *mode);
-void file_uncompress  (char  *file);
+void gz_uncompress    (gzFile in, FILE *out);
+void file_compress    (char *file, char *mode);
+void file_uncompress  (char *file);
 int  main             (int argc, char *argv[]);
 
 /* ===========================================================================
  * Display error message and exit
  */
-void error(const char *msg)
-{
+void error(const char *msg) {
     fprintf(stderr, "%s: %s\n", prog, msg);
     exit(1);
 }
@@ -94,8 +93,7 @@ void error(const char *msg)
  * Compress input to output then close both files.
  */
 
-void gz_compress(FILE   *in, gzFile out)
-{
+void gz_compress(FILE *in, gzFile out) {
     char buf[BUFLEN];
     int len;
     int err;
@@ -128,8 +126,7 @@ void gz_compress(FILE   *in, gzFile out)
 /* Try compressing the input file at once using mmap. Return Z_OK if
  * if success, Z_ERRNO otherwise.
  */
-int gz_compress_mmap(FILE   *in, gzFile out)
-{
+int gz_compress_mmap(FILE *in, gzFile out) {
     int len;
     int err;
     int ifd = fileno(in);
@@ -161,8 +158,7 @@ int gz_compress_mmap(FILE   *in, gzFile out)
 /* ===========================================================================
  * Uncompress input to output then close both files.
  */
-void gz_uncompress(gzFile in, FILE   *out)
-{
+void gz_uncompress(gzFile in, FILE *out) {
     char buf[BUFLENW];
     int len;
     int err;
@@ -186,10 +182,9 @@ void gz_uncompress(gzFile in, FILE   *out)
  * Compress the given file: create a corresponding .gz file and remove the
  * original.
  */
-void file_compress(char  *file, char  *mode)
-{
+void file_compress(char *file, char *mode) {
     char outfile[MAX_NAME_LEN];
-    FILE  *in;
+    FILE *in;
     gzFile out;
 
     if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) {
@@ -218,11 +213,10 @@ void file_compress(char  *file, char  *mode)
 /* ===========================================================================
  * Uncompress the given file and remove the original.
  */
-void file_uncompress(char  *file)
-{
+void file_uncompress(char *file) {
     char buf[MAX_NAME_LEN];
     char *infile, *outfile;
-    FILE  *out;
+    FILE *out;
     gzFile in;
     size_t len = strlen(file);
 
@@ -272,8 +266,7 @@ void file_uncompress(char  *file)
  *   -0 to -9 : compression level
  */
 
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
     int copyout = 0;
     int uncompr = 0;
     int i = 0;
@@ -286,14 +279,14 @@ int main(int argc, char *argv[])
     prog = argv[i];
     bname = strrchr(argv[i], '/');
     if (bname)
-      bname++;
+        bname++;
     else
-      bname = argv[i];
+        bname = argv[i];
 
     if (!strcmp(bname, "gunzip"))
-      uncompr = 1;
+        uncompr = 1;
     else if (!strcmp(bname, "zcat"))
-      copyout = uncompr = 1;
+        copyout = uncompr = 1;
 
     for (i = 1; i < argc; i++) {
         if (strcmp(argv[i], "-c") == 0)
@@ -303,7 +296,7 @@ int main(int argc, char *argv[])
         else if (strcmp(argv[i], "-A") == 0)
             type = "";
         else if (argv[i][0] == '-' && (argv[i][1] == 'f' || argv[i][1] == 'h' ||
-                argv[i][1] == 'R' || argv[i][1] == 'F' || argv[i][1] == 'T') && argv[i][2] == 0)
+                 argv[i][1] == 'R' || argv[i][1] == 'F' || argv[i][1] == 'T') && argv[i][2] == 0)
             strategy = argv[i] + 1;
         else if (argv[i][0] == '-' && argv[i][1] >= '0' && argv[i][1] <= '9' && argv[i][2] == 0)
             level = argv[i] + 1;
index 67bb1524a01ca016378bd9394719f9fc8c97dca3..5c4770f8cdb14c98d044f4e14b70b0bff10f3593 100644 (file)
@@ -13,8 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-static int read_all(unsigned char *buf, size_t size)
-{
+static int read_all(unsigned char *buf, size_t size) {
     for (size_t total_read = 0; total_read < size;) {
         size_t n_read = fread(buf + total_read, 1, size - total_read, stdin);
         if (ferror(stdin)) {
@@ -30,8 +29,7 @@ static int read_all(unsigned char *buf, size_t size)
     return 0;
 }
 
-static int write_all(unsigned char *buf, size_t size)
-{
+static int write_all(unsigned char *buf, size_t size) {
     for (size_t total_written = 0; total_written < size;) {
         size_t n_written = fwrite(buf + total_written, 1, size - total_written, stdout);
         if (ferror(stdout)) {
@@ -43,8 +41,7 @@ static int write_all(unsigned char *buf, size_t size)
     return 0;
 }
 
-static int compress_chunk(PREFIX3(stream) *strm, int level, int size, int last)
-{
+static int compress_chunk(PREFIX3(stream) *strm, int level, int size, int last) {
     int ret = 1;
     int err = PREFIX(deflateParams)(strm, level, Z_DEFAULT_STRATEGY);
     if (err != Z_OK) {
@@ -87,8 +84,7 @@ done:
  * Usage:  switchlevels level1 size1 [level2 size2 ...]
  */
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
     int ret = EXIT_FAILURE;
     PREFIX3(stream) strm;
     memset(&strm, 0, sizeof(strm));
index 54ab4c09ee98587cfd3e34461a52df1e321ea556..d0e356cee907dc3815acebf7ff783dc9577c78d0 100644 (file)
@@ -121,7 +121,7 @@ static void gen_trees_header() {
         printf("%2u%s", dist_code[i], SEPARATOR(i, DIST_CODE_LEN-1, 20));
     }
 
-    printf("const unsigned char ZLIB_INTERNAL zng_length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
+    printf("const unsigned char ZLIB_INTERNAL zng_length_code[MAX_MATCH-MIN_MATCH+1] = {\n");
     for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
         printf("%2u%s", length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
     }
diff --git a/trees.c b/trees.c
index bec889b0e9f6464bebbf6a0b5724457bc631c798..a948b96c0f74abb5ef6742c3dc9df7bc8fca99cd 100644 (file)
--- a/trees.c
+++ b/trees.c
@@ -423,7 +423,7 @@ static void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
     int min_count = 4;         /* min repeat count */
 
     if (nextlen == 0)
-         max_count = 138, min_count = 3;
+        max_count = 138, min_count = 3;
 
     tree[max_code+1].Len = (uint16_t)0xffff; /* guard */
 
@@ -683,7 +683,7 @@ void ZLIB_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, unsigned long
     if (buf != NULL) { /* force stored block */
 #else
     if (stored_len+4 <= opt_lenb && buf != NULL) {
-                       /* 4: two words for the lengths */
+        /* 4: two words for the lengths */
 #endif
         /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
          * Otherwise we can't have processed more than WSIZE input bytes since
diff --git a/trees.h b/trees.h
index a0273bf08b125d34f30bd491275237aac197a919..6cdd1d55cbe2df14876269aa99afd2a4d37461c6 100644 (file)
--- a/trees.h
+++ b/trees.h
@@ -102,7 +102,7 @@ const unsigned char ZLIB_INTERNAL zng_dist_code[DIST_CODE_LEN] = {
 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
 };
 
-const unsigned char ZLIB_INTERNAL zng_length_code[MAX_MATCH-MIN_MATCH+1]= {
+const unsigned char ZLIB_INTERNAL zng_length_code[MAX_MATCH-MIN_MATCH+1] = {
  0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,
 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
index 9f0ac2a0cf341ef23d1ca710e22d8a81dccf9d8c..b2b6c1459936fa1e2bc65a547d8ce8542303ac3d 100644 (file)
--- a/uncompr.c
+++ b/uncompr.c
@@ -8,9 +8,9 @@
 #define ZLIB_INTERNAL
 #include "zbuild.h"
 #ifdef ZLIB_COMPAT
-# include "zlib.h"
+#  include "zlib.h"
 #else
-# include "zlib-ng.h"
+#  include "zlib-ng.h"
 #endif
 
 /* ===========================================================================
@@ -40,8 +40,7 @@ int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, z_size_t *destLen, const un
     if (*destLen) {
         left = *destLen;
         *destLen = 0;
-    }
-    else {
+    } else {
         left = 1;
         dest = buf;
     }
@@ -83,7 +82,6 @@ int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, z_size_t *destLen, const un
            err;
 }
 
-int ZEXPORT PREFIX(uncompress)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t sourceLen)
-{
+int ZEXPORT PREFIX(uncompress)(unsigned char *dest, z_size_t *destLen, const unsigned char *source, z_size_t sourceLen) {
     return PREFIX(uncompress2)(dest, destLen, source, &sourceLen);
 }
index 5921abbe1e47786df561cefbd3755376409c0470..4236b13019e4a3c7c8f9d57c61d7149b4cdfbff4 100644 (file)
--- a/zendian.h
+++ b/zendian.h
@@ -7,54 +7,54 @@
 
 /* First check whether the compiler knows the target __BYTE_ORDER__. */
 #if defined(__BYTE_ORDER__)
-# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-#  if !defined(LITTLE_ENDIAN)
-#   define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
-#  endif
-#  if !defined(BYTE_ORDER)
-#   define BYTE_ORDER LITTLE_ENDIAN
-#  endif
-# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-#  if !defined(BIG_ENDIAN)
-#   define BIG_ENDIAN __ORDER_BIG_ENDIAN__
-#  endif
-#  if !defined(BYTE_ORDER)
-#   define BYTE_ORDER BIG_ENDIAN
+#  if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#    if !defined(LITTLE_ENDIAN)
+#      define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
+#    endif
+#    if !defined(BYTE_ORDER)
+#      define BYTE_ORDER LITTLE_ENDIAN
+#    endif
+#  elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#    if !defined(BIG_ENDIAN)
+#      define BIG_ENDIAN __ORDER_BIG_ENDIAN__
+#    endif
+#    if !defined(BYTE_ORDER)
+#      define BYTE_ORDER BIG_ENDIAN
+#    endif
 #  endif
-# endif
 #elif defined(__MINGW32__)
-# include <sys/param.h>
+#  include <sys/param.h>
 #elif defined(WIN32) || defined(_WIN32)
-# define LITTLE_ENDIAN 1234
-# define BIG_ENDIAN 4321
-# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) || defined (_M_ARM64)
-#  define BYTE_ORDER LITTLE_ENDIAN
-# else
-#  error Unknown endianness!
-# endif
+#  define LITTLE_ENDIAN 1234
+#  define BIG_ENDIAN 4321
+#  if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) || defined (_M_ARM64)
+#    define BYTE_ORDER LITTLE_ENDIAN
+#  else
+#    error Unknown endianness!
+#  endif
 #elif defined(__linux__)
-# include <endian.h>
+#  include <endian.h>
 #elif defined(__APPLE__) || defined(__arm__) || defined(__aarch64__)
-# include <machine/endian.h>
+#  include <machine/endian.h>
 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
-# include <sys/endian.h>
+#  include <sys/endian.h>
 #elif defined(__sun) || defined(sun)
-# include <sys/byteorder.h>
-# if !defined(LITTLE_ENDIAN)
-#  define LITTLE_ENDIAN 4321
-# endif
-# if !defined(BIG_ENDIAN)
-#  define BIG_ENDIAN 1234
-# endif
-# if !defined(BYTE_ORDER)
-#  if defined(_BIG_ENDIAN)
-#   define BYTE_ORDER BIG_ENDIAN
-#  else
-#   define BYTE_ORDER LITTLE_ENDIAN
+#  include <sys/byteorder.h>
+#  if !defined(LITTLE_ENDIAN)
+#    define LITTLE_ENDIAN 4321
+#   endif
+#  if !defined(BIG_ENDIAN)
+#    define BIG_ENDIAN 1234
+#  endif
+#  if !defined(BYTE_ORDER)
+#    if defined(_BIG_ENDIAN)
+#      define BYTE_ORDER BIG_ENDIAN
+#    else
+#      define BYTE_ORDER LITTLE_ENDIAN
+#    endif
 #  endif
-# endif
 #else
-# include <endian.h>
+#  include <endian.h>
 #endif
 
 #endif
index 0b91ec96f5bb4d504aa5e51a12c71bbd860292b6..33033b44051284bd9226f72cbb8f06bb8e58d083 100644 (file)
--- a/zlib-ng.h
+++ b/zlib-ng.h
@@ -1939,9 +1939,9 @@ ZEXTERN ZEXPORT int              zng_inflateResetKeep (zng_stream *);
 ZEXTERN ZEXPORT int              zng_deflateResetKeep (zng_stream *);
 
 #ifdef WITH_GZFILEOP
-# if (defined(WIN32) || defined(__MINGW__))
-    ZEXTERN ZEXPORT gzFile zng_gzopen_w(const wchar_t *path, const char *mode);
-# endif
+#  if (defined(WIN32) || defined(__MINGW__))
+     ZEXTERN ZEXPORT gzFile zng_gzopen_w(const wchar_t *path, const char *mode);
+#  endif
 ZEXTERN ZEXPORTVA int zng_gzvprintf(gzFile file, const char *format, va_list va);
 #endif
 
diff --git a/zlib.h b/zlib.h
index 5b2f32b3092c906286d6fc35a2ac9fa52371a039..cc6632ac9251d79f8fbe4309752fb631f110f2d7 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -649,7 +649,7 @@ ZEXTERN int ZEXPORT deflateSetDictionary(z_stream *strm,
    not perform any compression: this will be done by deflate().
 */
 
-ZEXTERN int ZEXPORT deflateGetDictionary (z_stream *strm, unsigned char *dictionary, unsigned int  *dictLength);
+ZEXTERN int ZEXPORT deflateGetDictionary (z_stream *strm, unsigned char *dictionary, unsigned int *dictLength);
 /*
      Returns the sliding dictionary being maintained by deflate.  dictLength is
    set to the number of bytes in the dictionary, and that many bytes are copied
diff --git a/zutil.c b/zutil.c
index 223d0fcc6c1431001805caed0cae0d1cdf68e7ac..e2da87f9d56766f5f030e3357f33b53cc40ad376 100644 (file)
--- a/zutil.c
+++ b/zutil.c
@@ -11,7 +11,7 @@
 #  include "gzguts.h"
 #endif
 #ifndef UNALIGNED_OK
-#  include "malloc.h"
+#  include <malloc.h>
 #endif
 
 const char * const zng_errmsg[10] = {
@@ -28,22 +28,19 @@ const char * const zng_errmsg[10] = {
 };
 
 const char zlibng_string[] =
-   " zlib-ng 1.9.9 forked from zlib 1.2.11 ";
+    " zlib-ng 1.9.9 forked from zlib 1.2.11 ";
 
 #ifdef ZLIB_COMPAT
-const char * ZEXPORT zlibVersion(void)
-{
+const char * ZEXPORT zlibVersion(void) {
     return ZLIB_VERSION;
 }
 #endif
 
-const char * ZEXPORT zlibng_version(void)
-{
+const char * ZEXPORT zlibng_version(void) {
     return ZLIBNG_VERSION;
 }
 
-unsigned long ZEXPORT PREFIX(zlibCompileFlags)(void)
-{
+unsigned long ZEXPORT PREFIX(zlibCompileFlags)(void) {
     unsigned long flags;
 
     flags = 0;
@@ -93,15 +90,13 @@ unsigned long ZEXPORT PREFIX(zlibCompileFlags)(void)
 }
 
 #ifdef ZLIB_DEBUG
-#include <stdlib.h>
+#  include <stdlib.h>
 #  ifndef verbose
 #    define verbose 0
 #  endif
 int ZLIB_INTERNAL z_verbose = verbose;
 
-void ZLIB_INTERNAL z_error (m)
-    char *m;
-{
+void ZLIB_INTERNAL z_error(char *m) {
     fprintf(stderr, "%s\n", m);
     exit(1);
 }
@@ -110,15 +105,13 @@ void ZLIB_INTERNAL z_error (m)
 /* exported to allow conversion of error code to string for compress() and
  * uncompress()
  */
-const char * ZEXPORT PREFIX(zError)(int err)
-{
+const char * ZEXPORT PREFIX(zError)(int err) {
     return ERR_MSG(err);
 }
 
 #ifndef MY_ZCALLOC /* Any system without a special alloc function */
 
-void ZLIB_INTERNAL *zng_calloc (void *opaque, unsigned items, unsigned size)
-{
+void ZLIB_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size) {
     (void)opaque;
 #ifndef UNALIGNED_OK
     return memalign(16, items * size);
@@ -128,8 +121,7 @@ void ZLIB_INTERNAL *zng_calloc (void *opaque, unsigned items, unsigned size)
 #endif
 }
 
-void ZLIB_INTERNAL zng_cfree (void *opaque, void *ptr)
-{
+void ZLIB_INTERNAL zng_cfree(void *opaque, void *ptr) {
     (void)opaque;
     free(ptr);
 }
diff --git a/zutil.h b/zutil.h
index f9cf3ff9fe539f4147c9f1890a8b9fa7cf6e6181..be38ff451853b45180d19c03982881753d41ff14 100644 (file)
--- a/zutil.h
+++ b/zutil.h
 #include <stdlib.h>
 #include <stdint.h>
 #ifdef ZLIB_COMPAT
-# include "zlib.h"
+#  include "zlib.h"
 #else
-# include "zlib-ng.h"
+#  include "zlib-ng.h"
 #endif
 
 typedef unsigned char uch; /* Included for compatibility with external code only */
 typedef uint16_t ush;      /* Included for compatibility with external code only */
-typedef unsigned long  ulg;
+typedef unsigned long ulg;
 
 extern const char * const zng_errmsg[10]; /* indexed by 2-zlib_error */
 /* (size given to avoid silly warnings with Visual C++) */
@@ -116,7 +116,7 @@ extern const char * const zng_errmsg[10]; /* indexed by 2-zlib_error */
 
 /* provide prototypes for these when building zlib without LFS */
 #if !defined(WIN32) && !defined(__MSYS__) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
-# include "zbuild.h"  /* For PREFIX() */
+#  include "zbuild.h"  /* For PREFIX() */
     ZEXTERN uint32_t ZEXPORT PREFIX(adler32_combine64)(uint32_t, uint32_t, z_off_t);
     ZEXTERN uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t, uint32_t, z_off_t);
 #endif
@@ -141,22 +141,22 @@ extern const char * const zng_errmsg[10]; /* indexed by 2-zlib_error */
 
 /* Diagnostic functions */
 #ifdef ZLIB_DEBUG
-#   include <stdio.h>
-    extern int ZLIB_INTERNAL z_verbose;
-    extern void ZLIB_INTERNAL z_error(char *m);
-#   define Assert(cond, msg) {if(!(cond)) z_error(msg);}
-#   define Trace(x) {if (z_verbose >= 0) fprintf x;}
-#   define Tracev(x) {if (z_verbose > 0) fprintf x;}
-#   define Tracevv(x) {if (z_verbose > 1) fprintf x;}
-#   define Tracec(c, x) {if (z_verbose > 0 && (c)) fprintf x;}
-#   define Tracecv(c, x) {if (z_verbose > 1 && (c)) fprintf x;}
+#  include <stdio.h>
+   extern int ZLIB_INTERNAL z_verbose;
+   extern void ZLIB_INTERNAL z_error(char *m);
+#  define Assert(cond, msg) {if (!(cond)) z_error(msg);}
+#  define Trace(x) {if (z_verbose >= 0) fprintf x;}
+#  define Tracev(x) {if (z_verbose > 0) fprintf x;}
+#  define Tracevv(x) {if (z_verbose > 1) fprintf x;}
+#  define Tracec(c, x) {if (z_verbose > 0 && (c)) fprintf x;}
+#  define Tracecv(c, x) {if (z_verbose > 1 && (c)) fprintf x;}
 #else
-#   define Assert(cond, msg)
-#   define Trace(x)
-#   define Tracev(x)
-#   define Tracevv(x)
-#   define Tracec(c, x)
-#   define Tracecv(c, x)
+#  define Assert(cond, msg)
+#  define Trace(x)
+#  define Tracev(x)
+#  define Tracevv(x)
+#  define Tracec(c, x)
+#  define Tracecv(c, x)
 #endif
 
 void ZLIB_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size);
@@ -164,7 +164,7 @@ void ZLIB_INTERNAL   zng_cfree(void *opaque, void *ptr);
 
 #define ZALLOC(strm, items, size) (*((strm)->zalloc))((strm)->opaque, (items), (size))
 #define ZFREE(strm, addr)         (*((strm)->zfree))((strm)->opaque, (void *)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
+#define TRY_FREE(s, p)            {if (p) ZFREE(s, p);}
 
 /* Reverse the bytes in a value. Use compiler intrinsics when
    possible to take advantage of hardware implementations. */
@@ -215,41 +215,41 @@ void ZLIB_INTERNAL   zng_cfree(void *opaque, void *ptr);
 
 /* Only enable likely/unlikely if the compiler is known to support it */
 #if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__INTEL_COMPILER) || defined(__Clang__)
-#    define LIKELY_NULL(x)      __builtin_expect((x) != 0, 0)
-#    define LIKELY(x)           __builtin_expect(!!(x), 1)
-#    define UNLIKELY(x)         __builtin_expect(!!(x), 0)
-#    define PREFETCH_L1(addr)    __builtin_prefetch(addr, 0, 3)
-#    define PREFETCH_L2(addr)    __builtin_prefetch(addr, 0, 2)
-#    define PREFETCH_RW(addr)    __builtin_prefetch(addr, 1, 2)
+#  define LIKELY_NULL(x)        __builtin_expect((x) != 0, 0)
+#  define LIKELY(x)             __builtin_expect(!!(x), 1)
+#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
+#  define PREFETCH_L1(addr)     __builtin_prefetch(addr, 0, 3)
+#  define PREFETCH_L2(addr)     __builtin_prefetch(addr, 0, 2)
+#  define PREFETCH_RW(addr)     __builtin_prefetch(addr, 1, 2)
 #elif defined(__WIN__)
-#    include <xmmintrin.h>
-#    define LIKELY_NULL(x) x
-#    define LIKELY(x)      x
-#    define UNLIKELY(x)    x
-#    define PREFETCH_L1(addr)    _mm_prefetch((char *) addr, _MM_HINT_T0)
-#    define PREFETCH_L2(addr)    _mm_prefetch((char *) addr, _MM_HINT_T1)
-#    define PREFETCH_RW(addr)    _mm_prefetch((char *) addr, _MM_HINT_T1)
+#  include <xmmintrin.h>
+#  define LIKELY_NULL(x)        x
+#  define LIKELY(x)             x
+#  define UNLIKELY(x)           x
+#  define PREFETCH_L1(addr)     _mm_prefetch((char *) addr, _MM_HINT_T0)
+#  define PREFETCH_L2(addr)     _mm_prefetch((char *) addr, _MM_HINT_T1)
+#  define PREFETCH_RW(addr)     _mm_prefetch((char *) addr, _MM_HINT_T1)
 #else
-#    define LIKELY_NULL(x) x
-#    define LIKELY(x)      x
-#    define UNLIKELY(x)    x
-#    define PREFETCH_L1(addr)    addr
-#    define PREFETCH_L2(addr)    addr
-#    define PREFETCH_RW(addr)    addr
+#  define LIKELY_NULL(x)        x
+#  define LIKELY(x)             x
+#  define UNLIKELY(x)           x
+#  define PREFETCH_L1(addr)     addr
+#  define PREFETCH_L2(addr)     addr
+#  define PREFETCH_RW(addr)     addr
 #endif /* (un)likely */
 
 #if defined(_MSC_VER)
-#define ALIGNED_(x) __declspec(align(x))
+#  define ALIGNED_(x) __declspec(align(x))
 #else
-#if defined(__GNUC__)
-#define ALIGNED_(x) __attribute__ ((aligned(x)))
-#endif
+#  if defined(__GNUC__)
+#    define ALIGNED_(x) __attribute__ ((aligned(x)))
+#  endif
 #endif
 
 #if defined(X86_CPUID)
-# include "arch/x86/x86.h"
+#  include "arch/x86/x86.h"
 #elif defined(ARM_GETAUXVAL)
-# include "arch/arm/arm.h"
+#  include "arch/arm/arm.h"
 #endif
 
 #endif /* ZUTIL_H_ */