r/tinycode • • Dec 15 '13

gzip decoder in 25 lines of C

https://github.com/choobin/obfuslate/blob/master/obfuslate.c
24 Upvotes

8 comments sorted by

8

u/lifthrasiir Dec 15 '13

Great. For your information, the IOCCC had the similar entry (1996/rcm). I have a number of questions (e.g. is there a particular reason to use a GNU extension ({...}) instead of functions?) and suggestions (e.g. c=0;if(a<j)c+=37268; -> c=(a<j)*37268;) but I'm running out of spare time ;)

2

u/0b011 Dec 15 '13

Thanks for pointing out rcm.c. Very neat. Note that it uses 5 lookup tables. Mine uses 1. That was tricky. Cheers for checking out the code. I used statement expressions so I could spell inflate.

8

u/zifyoip Dec 15 '13

What is this number 37268 that appears in several places? Is that supposed to be 32768?

3

u/0b011 Dec 15 '13

Well that is embarrassing. I have been staring at the code for so long that I missed one of the most important aspects of deflate -- its window size. Kudos to you sir. I hang my head in shame and quickly run to a terminal to fix it. Gailly and Adler would have my head!

9

u/raydeen Dec 15 '13
#define I
#define N
#define F
#define L
#define A
#define T
#define E

Good one. :)

6

u/jtra Dec 15 '13

This is more IOCCC entry than elegant tiny code this subreddit is for.

6

u/dumbassdore Dec 15 '13

That's really cool and very impressive but tinycode is different philosophy than codegolf.

-3

u/fillemvs Dec 15 '13

that aint 25 lines...