+ FPC supports pointer arithmetic.

git-svn-id: trunk@4579 -
This commit is contained in:
daniel 2006-09-09 10:02:57 +00:00
parent 1a8c2f405d
commit bfe41a49e2
2 changed files with 12 additions and 2 deletions

View File

@ -531,7 +531,6 @@ var
s : gz_streamp; s : gz_streamp;
start : Pbyte; start : Pbyte;
next_out : Pbyte;
n : cardinal; n : cardinal;
crclen : cardinal; { Buffer length to update CRC32 } crclen : cardinal; { Buffer length to update CRC32 }
filecrc : cardinal; { CRC32 stored in GZIP'ed file } filecrc : cardinal; { CRC32 stored in GZIP'ed file }
@ -539,6 +538,9 @@ var
bytes : integer; { bytes actually read in I/O blockread } bytes : integer; { bytes actually read in I/O blockread }
total_in : cardinal; total_in : cardinal;
total_out : cardinal; total_out : cardinal;
{$ifndef pointer_arith}
next_out : Pbyte;
{$endif}
begin begin
@ -605,11 +607,15 @@ begin
if (s^.z_err = Z_STREAM_END) then begin if (s^.z_err = Z_STREAM_END) then begin
crclen := 0; crclen := 0;
{$ifdef pointer_arith}
crclen:=s^.stream.next_out-start;
{$else}
next_out := s^.stream.next_out; next_out := s^.stream.next_out;
while (next_out <> start ) do begin while (next_out <> start ) do begin
dec (next_out); dec (next_out);
inc (crclen); { Hack because Pascal cannot substract pointers } inc (crclen); { Hack because Pascal cannot substract pointers }
end; end;
{$endif}
{ Check CRC and original size } { Check CRC and original size }
s^.crc := crc32(s^.crc, start, crclen); s^.crc := crc32(s^.crc, start, crclen);
start := s^.stream.next_out; start := s^.stream.next_out;
@ -639,13 +645,16 @@ begin
end; {WHILE} end; {WHILE}
crclen := 0; crclen := 0;
{$ifdef pointer_arith}
crclen:=s^.stream.next_out-start;
{$else}
next_out := s^.stream.next_out; next_out := s^.stream.next_out;
while (next_out <> start ) do begin while (next_out <> start ) do begin
dec (next_out); dec (next_out);
inc (crclen); { Hack because Pascal cannot substract pointers } inc (crclen); { Hack because Pascal cannot substract pointers }
end; end;
s^.crc := crc32 (s^.crc, start, crclen); s^.crc := crc32 (s^.crc, start, crclen);
{$endif}
gzread := integer(len - s^.stream.avail_out); gzread := integer(len - s^.stream.avail_out);
end; end;

View File

@ -28,6 +28,7 @@
{$IFDEF FPC} {$IFDEF FPC}
{$DEFINE Use32} {$DEFINE Use32}
{$DEFINE pointer_arith}
{$UNDEF DPMI} {$UNDEF DPMI}
{$UNDEF MSDOS} {$UNDEF MSDOS}
{$UNDEF UNALIGNED_OK} { requires SizeOf(ush) = 2 ! } {$UNDEF UNALIGNED_OK} { requires SizeOf(ush) = 2 ! }