From 97bb5a3a8063644bd1685c16c1eca849c8195023 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sun, 18 Sep 2022 03:16:14 -0700 Subject: [PATCH] Fix MODE=dbg build --- third_party/zlib/deflate.c | 27 ++++++++++++++------------- third_party/zlib/inffast.c | 8 ++++---- third_party/zlib/trees.c | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/third_party/zlib/deflate.c b/third_party/zlib/deflate.c index e67fdb6e1..7a37210ff 100644 --- a/third_party/zlib/deflate.c +++ b/third_party/zlib/deflate.c @@ -6,6 +6,7 @@ #include "third_party/zlib/deflate.internal.h" #include "third_party/zlib/insert_string.internal.h" #include "third_party/zlib/internal.h" +#include "third_party/zlib/zutil.internal.h" asm(".ident\t\"\\n\\n\ inflate 1.2.12.1 (zlib License)\\n\ @@ -1521,18 +1522,18 @@ local void check_match(s, start, match, length) int length; { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", + if (memcmp(s->window + match, + s->window + start, length) != EQUAL) { + kprintf(" start %u, match %u, length %d\n", start, match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + kprintf("%c%c", s->window[match++], s->window[start++]); } while (--length != 0); - z_error("invalid match"); + z_error(__FILE__, __LINE__, "invalid match"); } if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); + kprintf("\\[%d,%d]", start-match, length); + do { kprintf("%c", s->window[start++]); } while (--length != 0); } } #else @@ -1696,7 +1697,7 @@ local void fill_window(s) (last)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ + Tracev(("[FLUSH]")); \ } /* Same but force premature exit if necessary. */ @@ -1995,7 +1996,7 @@ local block_state deflate_fast(s, flush) } } else { /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); + Tracevv(("%c", s->window[s->strstart])); _tr_tally_lit (s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; @@ -2116,7 +2117,7 @@ local block_state deflate_slow(s, flush) * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); + Tracevv(("%c", s->window[s->strstart-1])); _tr_tally_lit(s, s->window[s->strstart-1], bflush); if (bflush) { FLUSH_BLOCK_ONLY(s, 0); @@ -2135,7 +2136,7 @@ local block_state deflate_slow(s, flush) } Assert (flush != Z_NO_FLUSH, "no flush?"); if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); + Tracevv(("%c", s->window[s->strstart-1])); _tr_tally_lit(s, s->window[s->strstart-1], bflush); s->match_available = 0; } @@ -2207,7 +2208,7 @@ local block_state deflate_rle(s, flush) s->match_length = 0; } else { /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); + Tracevv(("%c", s->window[s->strstart])); _tr_tally_lit (s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; @@ -2247,7 +2248,7 @@ local block_state deflate_huff(s, flush) /* Output a literal byte */ s->match_length = 0; - Tracevv((stderr,"%c", s->window[s->strstart])); + Tracevv(("%c", s->window[s->strstart])); _tr_tally_lit (s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; diff --git a/third_party/zlib/inffast.c b/third_party/zlib/inffast.c index 95b130a79..69ad2e348 100644 --- a/third_party/zlib/inffast.c +++ b/third_party/zlib/inffast.c @@ -122,7 +122,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ bits -= op; op = (unsigned)(here->op); if (op == 0) { /* literal */ - Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ? + Tracevv((here->val >= 0x20 && here->val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", here->val)); *out++ = (unsigned char)(here->val); @@ -139,7 +139,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ hold >>= op; bits -= op; } - Tracevv((stderr, "inflate: length %u\n", len)); + Tracevv(("inflate: length %u\n", len)); if (bits < 15) { hold += (unsigned long)(*in++) << bits; bits += 8; @@ -173,7 +173,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ #endif hold >>= op; bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); + Tracevv(("inflate: distance %u\n", dist)); op = (unsigned)(out - beg); /* max distance in output */ if (dist > op) { /* see if copy from window */ op = dist - op; /* distance back in window */ @@ -286,7 +286,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ goto dolen; } else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); + Tracevv(("inflate: end of block\n")); state->mode = TYPE; break; } diff --git a/third_party/zlib/trees.c b/third_party/zlib/trees.c index 8b3b3a5ae..27a81f7d6 100644 --- a/third_party/zlib/trees.c +++ b/third_party/zlib/trees.c @@ -166,7 +166,7 @@ local void gen_trees_header OF((void)); #else /* !ZLIB_DEBUG */ # define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ + { if (z_verbose>2) kprintf("\ncd %3d ",(c)); \ send_bits(s, tree[c].Code, tree[c].Len); } #endif