[fpc-devel] patch minigzip

Daniël Mantione daniel.mantione at freepascal.org
Fri Sep 8 11:51:02 CEST 2006



Op Fri, 8 Sep 2006, schreef Jonas Maebe:

> 
> On 8 sep 2006, at 11:03, Jonas Maebe wrote:
> 
> > > > There are no endian conversions at all in the paszlib package,
> > > > which is
> > > > IMHO impossible for correct behaviour but many of these
> > > > constructions. To
> > > > be sure, can you test minigzip on OS X?
> > > 
> > > It works fine (I compressed a file with minigzip and uncompressed it
> > > with gunzip).
> > 
> > Actually, it doesn't: decompressing with minigzip fails.
> 
> It's even stranger: minigzip uncompresses the file fine (created with gzip),
> the result is bytewise identical to the original, yet it complains about a
> "data error".

I think I found the problem:

function getLong(s : gz_streamp) : cardinal;
var
  x : packed array [0..3] of byte;
  c : integer;
begin
  { x := cardinal(get_byte(s));  - you can't do this with TP, no unsigned 
longint }
  { the following assumes a little endian machine and TP }
  x[0] := Byte(get_byte(s));
  x[1] := Byte(get_byte(s));
  x[2] := Byte(get_byte(s));
  c := get_byte(s);
  x[3] := Byte(c);
  if (c = Z_EOF) then
    s^.z_err := Z_DATA_ERROR;
  GetLong := cardinal(longint(x));
end;

I've committed a fix.

Daniël


More information about the fpc-devel mailing list