Skip to content

Instantly share code, notes, and snippets.

@dyoo
Created February 5, 2013 22:07
Show Gist options
  • Select an option

  • Save dyoo/4718185 to your computer and use it in GitHub Desktop.

Select an option

Save dyoo/4718185 to your computer and use it in GitHub Desktop.
Annotations to observe what bytes deflate.c looks at.
128-110-72-21:updated-gzip-1.2.4 dyoo$ diff -u inflate.c ../gzip-1.2.4/inflate.c
--- inflate.c 2013-02-05 15:05:33.000000000 -0700
+++ ../gzip-1.2.4/inflate.c 1993-08-13 08:50:20.000000000 -0600
@@ -212,16 +212,14 @@
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
-int theByte;
-
#ifdef CRYPT
uch cc;
# define NEXTBYTE() \
(decrypt ? (cc = get_byte(), zdecode(cc), cc) : get_byte())
#else
-# define NEXTBYTE() get_byte()
+# define NEXTBYTE() (uch)get_byte()
#endif
-#define NEEDBITS(n) {while(k<(n)){theByte = (uch)NEXTBYTE(); printf("nextbyte: %d\n", theByte);b|=((ulg)theByte)<<k;k+=8;}}
+#define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE())<<k;k+=8;}}
#define DUMPBITS(n) {b>>=(n);k-=(n);}
@@ -537,10 +535,8 @@
else /* it's an EOB or a length */
{
/* exit if end of block */
- if (e == 15) {
- printf("EOB detected\n");
+ if (e == 15)
break;
- }
/* get length of block to copy */
NEEDBITS(e)
@@ -876,7 +872,6 @@
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
- printf("inflate block\n");
/* make local bit buffer */
b = bb;
@@ -922,7 +917,6 @@
int r; /* result code */
unsigned h; /* maximum struct huft's malloc'ed */
- printf("inflate\n");
/* initialize window, bit buffer */
wp = 0;
@@ -951,8 +945,6 @@
/* flush out slide */
flush_output(wp);
- printf("inflate done\n");
-
/* return success */
#ifdef DEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment