[Pharo-project] [COTDC] 100 - GZipConstants

Ben Coman btc at openInWorld.com
Fri Jan 6 03:30:36 CET 2012

sean at clipperadams.com wrote:
> A new class for the New Year...
> 99 classes done
> 797 classes remaining
> Continuing in Compression...
> Today:  GZipConstants 
> Comment Of The Day Contest - One Day One Comment 
> Rules: 
> #1: Each day a not commented class is elected. Each day the best comment will be integrated with name of the author(s). 
> #2: If you cannot comment it, deprecate it. 
> Results: http://code.google.com/p/pharo/wiki/CommentOfTheDayContest
> p.s. this message was sent from a pharo image. Did you know you could easily do that?!
Well again this is something I can respond to without a great knowledge 
of Smalltalk.
RFC1952 is short and clear enough that extracts from probably don't need 
to be included it like the last one I did.
This class defines magic numbers taken from the RFC1952 GZIP file format 
specification version 4.3 (1996) [1].  A class imports these constants 
as 'class variables' by including the following in its class definition:
   poolDictionaries: 'GZipConstants'
A method on the class side initialises the values.

[1] http://www.ietf.org/rfc/rfc1952.txt  (Section 2.3.1 Member header 
and trailer)

As an aside the following in [GzipConstants class >> initialize] does 
not match the specification for bit 5 as "reserved".
    GZipEncryptFlag := 16r20.    "Archive is encrypted"

I did find it defined here [2] & [3] however the FAQ [4] specifically 
says encryption is NOT part of the standard.

This constant is only used in [GzipReadStream >> on:from:to] as...
    (flags anyMask: GZipEncryptFlag)
        ifTrue:[^self error:'Cannot decompress encrypted stream'].

So perhaps its okay to leave but maybe some slight benefit from amending 
the text as follows..
    GZipEncryptFlag := 16r20.    "Archive is encrypted.  Not supported. 
Not part of the standard."
    ifTrue:[^self error:'Cannot decompress encrypted stream. Encryption 
is not part of RFC1952'].

It is a better presentation to a user if you can indicate that it is 
someone else's fault that their decompress failed, and not Pharo.

[2] http://www.onicos.com/staff/iz/formats/gzip.html
[3] http://research.cs.wisc.edu/wpis/examples/pcca/gzip/gzip.h
[3] http://www.gzip.org/#faq15

More information about the Pharo-project mailing list