Browse Source

* Replace C types with native Pascal types
* Avoid sysutils overhead

git-svn-id: trunk@1843 -

daniel 19 years ago
parent
commit
4e4099e835

+ 9 - 9
packages/base/paszlib/adler.pas

@@ -1,4 +1,4 @@
-Unit Adler;
+unit adler;
 
 
 {
 {
   adler32.c -- compute the Adler-32 checksum of a data stream
   adler32.c -- compute the Adler-32 checksum of a data stream
@@ -16,7 +16,7 @@ interface
 uses
 uses
   zutil;
   zutil;
 
 
-function adler32(adler : uLong; buf : pBytef; len : uInt) : uLong;
+function adler32(adler : cardinal; buf : Pbyte; len : cardinal) : cardinal;
 
 
 {    Update a running Adler-32 checksum with the bytes buf[0..len-1] and
 {    Update a running Adler-32 checksum with the bytes buf[0..len-1] and
    return the updated checksum. If buf is NIL, this function returns
    return the updated checksum. If buf is NIL, this function returns
@@ -25,9 +25,9 @@ function adler32(adler : uLong; buf : pBytef; len : uInt) : uLong;
    much faster. Usage example:
    much faster. Usage example:
 
 
    var
    var
-     adler : uLong;
+     adler : cardinal;
    begin
    begin
-     adler := adler32(0, Z_NULL, 0);
+     adler := adler32(0, nil, 0);
 
 
      while (read_buffer(buffer, length) <> EOF) do
      while (read_buffer(buffer, length) <> EOF) do
        adler := adler32(adler, buffer, length);
        adler := adler32(adler, buffer, length);
@@ -40,7 +40,7 @@ function adler32(adler : uLong; buf : pBytef; len : uInt) : uLong;
 implementation
 implementation
 
 
 const
 const
-  BASE = uLong(65521); { largest prime smaller than 65536 }
+  BASE = cardinal(65521); { largest prime smaller than 65536 }
   {NMAX = 5552; original code with unsigned 32 bit integer }
   {NMAX = 5552; original code with unsigned 32 bit integer }
   { NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 }
   { NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 }
   NMAX = 3854;        { code with signed 32 bit integer }
   NMAX = 3854;        { code with signed 32 bit integer }
@@ -50,17 +50,17 @@ const
 
 
 { ========================================================================= }
 { ========================================================================= }
 
 
-function adler32(adler : uLong; buf : pBytef; len : uInt) : uLong;
+function adler32(adler : cardinal; buf : Pbyte; len : cardinal) : cardinal;
 var
 var
-  s1, s2 : uLong;
-  k : int;
+  s1, s2 : cardinal;
+  k : integer;
 begin
 begin
   s1 := adler and $ffff;
   s1 := adler and $ffff;
   s2 := (adler shr 16) and $ffff;
   s2 := (adler shr 16) and $ffff;
 
 
   if not Assigned(buf) then
   if not Assigned(buf) then
   begin
   begin
-    adler32 := uLong(1);
+    adler32 := cardinal(1);
     exit;
     exit;
   end;
   end;
 
 

+ 30 - 30
packages/base/paszlib/crc.pas

@@ -1,4 +1,4 @@
-Unit Crc;
+unit crc;
 
 
 {
 {
   crc32.c -- compute the CRC-32 of a data stream
   crc32.c -- compute the CRC-32 of a data stream
@@ -17,7 +17,7 @@ uses
   zutil, zbase;
   zutil, zbase;
 
 
 
 
-function crc32(crc : uLong; buf : pBytef; len : uInt) : uLong;
+function crc32(crc : cardinal; buf : Pbyte; len : cardinal) : cardinal;
 
 
 {  Update a running crc with the bytes buf[0..len-1] and return the updated
 {  Update a running crc with the bytes buf[0..len-1] and return the updated
    crc. If buf is NULL, this function returns the required initial value
    crc. If buf is NULL, this function returns the required initial value
@@ -26,9 +26,9 @@ function crc32(crc : uLong; buf : pBytef; len : uInt) : uLong;
    Usage example:
    Usage example:
 
 
     var
     var
-      crc : uLong;
+      crc : cardinal;
     begin
     begin
-      crc := crc32(0, Z_NULL, 0);
+      crc := crc32(0, nil, 0);
 
 
       while (read_buffer(buffer, length) <> EOF) do
       while (read_buffer(buffer, length) <> EOF) do
         crc := crc32(crc, buffer, length);
         crc := crc32(crc, buffer, length);
@@ -38,7 +38,7 @@ function crc32(crc : uLong; buf : pBytef; len : uInt) : uLong;
 
 
 }
 }
 
 
-function get_crc_table : puLong;  { can be used by asm versions of crc32() }
+function get_crc_table : Pcardinal;  { can be used by asm versions of crc32() }
 
 
 
 
 implementation
 implementation
@@ -80,9 +80,9 @@ var
 {local}
 {local}
 procedure make_crc_table;
 procedure make_crc_table;
 var
 var
- c    : uLong;
- n,k  : int;
- poly : uLong; { polynomial exclusive-or pattern }
+ c    : cardinal;
+ n,k  : integer;
+ poly : cardinal; { polynomial exclusive-or pattern }
 
 
 const
 const
  { terms of polynomial defining this crc (except x^32): }
  { terms of polynomial defining this crc (except x^32): }
@@ -90,13 +90,13 @@ const
 
 
 begin
 begin
   { make exclusive-or pattern from polynomial ($EDB88320) }
   { make exclusive-or pattern from polynomial ($EDB88320) }
-  poly := Long(0);
+  poly := longint(0);
   for n := 0 to (sizeof(p) div sizeof(Byte))-1 do
   for n := 0 to (sizeof(p) div sizeof(Byte))-1 do
-    poly := poly or (Long(1) shl (31 - p[n]));
+    poly := poly or (longint(1) shl (31 - p[n]));
 
 
   for n := 0 to 255 do
   for n := 0 to 255 do
   begin
   begin
-    c := uLong(n);
+    c := cardinal(n);
     for k := 0 to 7 do
     for k := 0 to 7 do
     begin
     begin
       if (c and 1) <> 0 then
       if (c and 1) <> 0 then
@@ -116,7 +116,7 @@ end;
 
 
 {local}
 {local}
 const
 const
-  crc_table : array[0..256-1] of uLongf = (
+  crc_table : array[0..256-1] of cardinal = (
   $00000000, $77073096, $ee0e612c, $990951ba, $076dc419,
   $00000000, $77073096, $ee0e612c, $990951ba, $076dc419,
   $706af48f, $e963a535, $9e6495a3, $0edb8832, $79dcb8a4,
   $706af48f, $e963a535, $9e6495a3, $0edb8832, $79dcb8a4,
   $e0d5e91e, $97d2d988, $09b64c2b, $7eb17cbd, $e7b82d07,
   $e0d5e91e, $97d2d988, $09b64c2b, $7eb17cbd, $e7b82d07,
@@ -175,21 +175,21 @@ const
 { =========================================================================
 { =========================================================================
   This function can be used by asm versions of crc32() }
   This function can be used by asm versions of crc32() }
 
 
-function get_crc_table : {const} puLong;
+function get_crc_table : {const} Pcardinal;
 begin
 begin
 {$ifdef DYNAMIC_CRC_TABLE}
 {$ifdef DYNAMIC_CRC_TABLE}
   if (crc_table_empty) then
   if (crc_table_empty) then
     make_crc_table;
     make_crc_table;
 {$endif}
 {$endif}
-  get_crc_table :=  {const} puLong(@crc_table);
+  get_crc_table :=  {const} Pcardinal(@crc_table);
 end;
 end;
 
 
 { ========================================================================= }
 { ========================================================================= }
 
 
-function crc32 (crc : uLong; buf : pBytef; len : uInt): uLong;
+function crc32 (crc : cardinal; buf : Pbyte; len : cardinal): cardinal;
 begin
 begin
-  if (buf = Z_NULL) then
-    crc32 := Long(0)
+  if (buf = nil) then
+    crc32 := 0
   else
   else
   begin
   begin
 
 
@@ -198,38 +198,38 @@ begin
       make_crc_table;
       make_crc_table;
 {$ENDIF}
 {$ENDIF}
 
 
-    crc := crc xor uLong($ffffffff);
+    crc := crc xor cardinal($ffffffff);
     while (len >= 8) do
     while (len >= 8) do
     begin
     begin
       {DO8(buf)}
       {DO8(buf)}
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
 
 
-      Dec(len, 8);
+      dec(len, 8);
     end;
     end;
     if (len <> 0) then
     if (len <> 0) then
     repeat
     repeat
       {DO1(buf)}
       {DO1(buf)}
-      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      crc := crc_table[(integer(crc) xor buf^) and $ff] xor (crc shr 8);
       inc(buf);
       inc(buf);
 
 
-      Dec(len);
+      dec(len);
     until (len = 0);
     until (len = 0);
-    crc32 := crc xor uLong($ffffffff);
+    crc32 := crc xor cardinal($ffffffff);
   end;
   end;
 end;
 end;
 
 

+ 82 - 90
packages/base/paszlib/example.pas

@@ -17,24 +17,16 @@ program example;
 {$DEFINE TEST_FLUSH}
 {$DEFINE TEST_FLUSH}
 
 
 uses
 uses
-{$ifdef ver80}
- WinCrt,
-{$endif}
-{$ifdef you may have to define this in Delphi < 5}
   strings,
   strings,
-{$endif}
-{$ifndef MSDOS}
-  SysUtils,
-{$endif}
   zutil,
   zutil,
   zbase,
   zbase,
-  gzIo,
-  zInflate,
-  zDeflate,
-  zCompres,
-  zUnCompr
-{$ifdef MemCheck}
-  , MemCheck in '..\..\monotekt\pas\memcheck\memcheck.pas'
+  gzio,
+  zinflate,
+  zdeflate,
+  zcompres,
+  zuncompr
+{$ifdef memcheck}
+  , memcheck in '..\..\monotekt\pas\memcheck\memcheck.pas'
 {$endif}
 {$endif}
 ;
 ;
 
 
@@ -45,7 +37,7 @@ begin
   Halt(1);
   Halt(1);
 end;
 end;
 
 
-procedure CHECK_ERR(err : int; msg : string);
+procedure CHECK_ERR(err : integer; msg : string);
 begin
 begin
   if (err <> Z_OK) then
   if (err <> Z_OK) then
   begin
   begin
@@ -63,21 +55,21 @@ const
 const
 const
   dictionary : PChar = 'hello';
   dictionary : PChar = 'hello';
 var
 var
-  dictId : uLong; { Adler32 value of the dictionary }
+  dictId : cardinal; { Adler32 value of the dictionary }
 {$ENDIF}
 {$ENDIF}
 
 
 { ===========================================================================
 { ===========================================================================
   Test compress() and uncompress() }
   Test compress() and uncompress() }
 
 
 {$IFDEF TEST_COMPRESS}
 {$IFDEF TEST_COMPRESS}
-procedure test_compress(compr : pBytef; var comprLen : uLong;
-                        uncompr : pBytef; uncomprLen : uLong);
+procedure test_compress(compr : Pbyte; var comprLen : cardinal;
+                        uncompr : Pbyte; uncomprLen : cardinal);
 var
 var
-  err : int;
-  len : uLong;
+  err : integer;
+  len : cardinal;
 begin
 begin
   len := strlen(hello)+1;
   len := strlen(hello)+1;
-  err := compress(compr, comprLen, pBytef(hello)^, len);
+  err := compress(compr, comprLen, Pbyte(hello)^, len);
   CHECK_ERR(err, 'compress');
   CHECK_ERR(err, 'compress');
 
 
   strcopy(PChar(uncompr), 'garbage');
   strcopy(PChar(uncompr), 'garbage');
@@ -101,11 +93,11 @@ end;
 {$IFDEF TEST_GZIO}
 {$IFDEF TEST_GZIO}
 procedure test_gzio(const outf : string; { output file }
 procedure test_gzio(const outf : string; { output file }
                     const inf : string;  { input file }
                     const inf : string;  { input file }
-                    uncompr : pBytef;
-                    uncomprLen : int);
+                    uncompr : Pbyte;
+                    uncomprLen : integer);
 var
 var
-  err : int;
-  len : int;
+  err : integer;
+  len : integer;
 var
 var
   zfile : gzFile;
   zfile : gzFile;
   pos : z_off_t;
   pos : z_off_t;
@@ -137,7 +129,7 @@ begin
     Stop;
     Stop;
   end;
   end;
   {$ENDIF}
   {$ENDIF}
-  gzseek(zfile, Long(1), SEEK_CUR); { add one zero byte }
+  gzseek(zfile, longint(1), SEEK_CUR); { add one zero byte }
   gzclose(zfile);
   gzclose(zfile);
 
 
   zfile := gzopen(inf, 'r');
   zfile := gzopen(inf, 'r');
@@ -146,7 +138,7 @@ begin
 
 
   strcopy(pchar(uncompr), 'garbage');
   strcopy(pchar(uncompr), 'garbage');
 
 
-  uncomprLen := gzread(zfile, uncompr, uInt(uncomprLen));
+  uncomprLen := gzread(zfile, uncompr, cardinal(uncomprLen));
   if (uncomprLen <> len) then
   if (uncomprLen <> len) then
   begin
   begin
     WriteLn('gzread err: ', gzerror(zfile, err));
     WriteLn('gzread err: ', gzerror(zfile, err));
@@ -160,7 +152,7 @@ begin
   else
   else
     WriteLn('gzread(): ', pchar(uncompr));
     WriteLn('gzread(): ', pchar(uncompr));
 
 
-  pos := gzseek(zfile, Long(-8), SEEK_CUR);
+  pos := gzseek(zfile, longint(-8), SEEK_CUR);
   if (pos <> 6) or (gztell(zfile) <> pos) then
   if (pos <> 6) or (gztell(zfile) <> pos) then
   begin
   begin
     WriteLn('gzseek error, pos=',pos,', gztell=',gztell(zfile));
     WriteLn('gzseek error, pos=',pos,', gztell=',gztell(zfile));
@@ -196,11 +188,11 @@ end;
   Test deflate() with small buffers }
   Test deflate() with small buffers }
 
 
 {$IFDEF TEST_DEFLATE}
 {$IFDEF TEST_DEFLATE}
-procedure test_deflate(compr : pBytef; comprLen : uLong);
+procedure test_deflate(compr : Pbyte; comprLen : cardinal);
 var
 var
   c_stream : z_stream; { compression stream }
   c_stream : z_stream; { compression stream }
-  err : int;
-  len : int;
+  err : integer;
+  len : integer;
 begin
 begin
   len := strlen(hello)+1;
   len := strlen(hello)+1;
   c_stream.zalloc := NIL; {alloc_func(0);}
   c_stream.zalloc := NIL; {alloc_func(0);}
@@ -210,10 +202,10 @@ begin
   err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
   err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
   CHECK_ERR(err, 'deflateInit');
   CHECK_ERR(err, 'deflateInit');
 
 
-  c_stream.next_in  := pBytef(hello);
+  c_stream.next_in  := Pbyte(hello);
   c_stream.next_out := compr;
   c_stream.next_out := compr;
 
 
-  while (c_stream.total_in <> uLong(len)) and (c_stream.total_out < comprLen) do
+  while (c_stream.total_in <> cardinal(len)) and (c_stream.total_out < comprLen) do
   begin
   begin
     c_stream.avail_out := 1; { force small buffers }
     c_stream.avail_out := 1; { force small buffers }
     c_stream.avail_in := 1;
     c_stream.avail_in := 1;
@@ -241,10 +233,10 @@ end;
 }
 }
 
 
 {$IFDEF TEST_INFLATE}
 {$IFDEF TEST_INFLATE}
-procedure test_inflate(compr : pBytef; comprLen : uLong;
-                       uncompr : pBytef;  uncomprLen : uLong);
+procedure test_inflate(compr : Pbyte; comprLen : cardinal;
+                       uncompr : Pbyte;  uncomprLen : cardinal);
 var
 var
-  err : int;
+  err : integer;
   d_stream : z_stream; { decompression stream }
   d_stream : z_stream; { decompression stream }
 begin
 begin
   strcopy(PChar(uncompr), 'garbage');
   strcopy(PChar(uncompr), 'garbage');
@@ -291,11 +283,11 @@ end;
  }
  }
 
 
 {$IFDEF TEST_DEFLATE}
 {$IFDEF TEST_DEFLATE}
-procedure test_large_deflate(compr : pBytef; comprLen : uLong;
-                             uncompr : pBytef;  uncomprLen : uLong);
+procedure test_large_deflate(compr : Pbyte; comprLen : cardinal;
+                             uncompr : Pbyte;  uncomprLen : cardinal);
 var
 var
   c_stream : z_stream; { compression stream }
   c_stream : z_stream; { compression stream }
-  err : int;
+  err : integer;
 begin
 begin
   c_stream.zalloc := NIL; {alloc_func(0);}
   c_stream.zalloc := NIL; {alloc_func(0);}
   c_stream.zfree := NIL;  {free_func(0);}
   c_stream.zfree := NIL;  {free_func(0);}
@@ -305,13 +297,13 @@ begin
   CHECK_ERR(err, 'deflateInit');
   CHECK_ERR(err, 'deflateInit');
 
 
   c_stream.next_out := compr;
   c_stream.next_out := compr;
-  c_stream.avail_out := uInt(comprLen);
+  c_stream.avail_out := cardinal(comprLen);
 
 
   { At this point, uncompr is still mostly zeroes, so it should compress
   { At this point, uncompr is still mostly zeroes, so it should compress
     very well: }
     very well: }
 
 
   c_stream.next_in := uncompr;
   c_stream.next_in := uncompr;
-  c_stream.avail_in := uInt(uncomprLen);
+  c_stream.avail_in := cardinal(uncomprLen);
   err := deflate(c_stream, Z_NO_FLUSH);
   err := deflate(c_stream, Z_NO_FLUSH);
   CHECK_ERR(err, 'deflate');
   CHECK_ERR(err, 'deflate');
   if (c_stream.avail_in <> 0) then
   if (c_stream.avail_in <> 0) then
@@ -323,14 +315,14 @@ begin
   { Feed in already compressed data and switch to no compression: }
   { Feed in already compressed data and switch to no compression: }
   deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
   deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
   c_stream.next_in := compr;
   c_stream.next_in := compr;
-  c_stream.avail_in := uInt(comprLen div 2);
+  c_stream.avail_in := cardinal(comprLen div 2);
   err := deflate(c_stream, Z_NO_FLUSH);
   err := deflate(c_stream, Z_NO_FLUSH);
   CHECK_ERR(err, 'deflate');
   CHECK_ERR(err, 'deflate');
 
 
   { Switch back to compressing mode: }
   { Switch back to compressing mode: }
   deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
   deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
   c_stream.next_in := uncompr;
   c_stream.next_in := uncompr;
-  c_stream.avail_in := uInt(uncomprLen);
+  c_stream.avail_in := cardinal(uncomprLen);
   err := deflate(c_stream, Z_NO_FLUSH);
   err := deflate(c_stream, Z_NO_FLUSH);
   CHECK_ERR(err, 'deflate');
   CHECK_ERR(err, 'deflate');
 
 
@@ -349,10 +341,10 @@ end;
   Test inflate() with large buffers }
   Test inflate() with large buffers }
 
 
 {$IFDEF TEST_INFLATE}
 {$IFDEF TEST_INFLATE}
-procedure test_large_inflate(compr : pBytef; comprLen : uLong;
-                             uncompr : pBytef;  uncomprLen : uLong);
+procedure test_large_inflate(compr : Pbyte; comprLen : cardinal;
+                             uncompr : Pbyte;  uncomprLen : cardinal);
 var
 var
-  err : int;
+  err : integer;
   d_stream : z_stream; { decompression stream }
   d_stream : z_stream; { decompression stream }
 begin
 begin
   strcopy(PChar(uncompr), 'garbage');
   strcopy(PChar(uncompr), 'garbage');
@@ -362,7 +354,7 @@ begin
   d_stream.opaque := NIL; {voidpf(0);}
   d_stream.opaque := NIL; {voidpf(0);}
 
 
   d_stream.next_in  := compr;
   d_stream.next_in  := compr;
-  d_stream.avail_in := uInt(comprLen);
+  d_stream.avail_in := cardinal(comprLen);
 
 
   err := inflateInit(d_stream);
   err := inflateInit(d_stream);
   CHECK_ERR(err, 'inflateInit');
   CHECK_ERR(err, 'inflateInit');
@@ -370,7 +362,7 @@ begin
   while TRUE do
   while TRUE do
   begin
   begin
     d_stream.next_out := uncompr;            { discard the output }
     d_stream.next_out := uncompr;            { discard the output }
-    d_stream.avail_out := uInt(uncomprLen);
+    d_stream.avail_out := cardinal(uncomprLen);
     err := inflate(d_stream, Z_NO_FLUSH);
     err := inflate(d_stream, Z_NO_FLUSH);
     if (err = Z_STREAM_END) then
     if (err = Z_STREAM_END) then
       break;
       break;
@@ -394,11 +386,11 @@ end;
   Test deflate() with full flush
   Test deflate() with full flush
  }
  }
 {$IFDEF TEST_FLUSH}
 {$IFDEF TEST_FLUSH}
-procedure test_flush(compr : pBytef; var comprLen : uLong);
+procedure test_flush(compr : Pbyte; var comprLen : cardinal);
 var
 var
   c_stream : z_stream; { compression stream }
   c_stream : z_stream; { compression stream }
-  err : int;
-  len : int;
+  err : integer;
+  len : integer;
 
 
 begin
 begin
   len := strlen(hello)+1;
   len := strlen(hello)+1;
@@ -409,10 +401,10 @@ begin
   err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
   err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
   CHECK_ERR(err, 'deflateInit');
   CHECK_ERR(err, 'deflateInit');
 
 
-  c_stream.next_in := pBytef(hello);
+  c_stream.next_in := Pbyte(hello);
   c_stream.next_out := compr;
   c_stream.next_out := compr;
   c_stream.avail_in := 3;
   c_stream.avail_in := 3;
-  c_stream.avail_out := uInt(comprLen);
+  c_stream.avail_out := cardinal(comprLen);
 
 
   err := deflate(c_stream, Z_FULL_FLUSH);
   err := deflate(c_stream, Z_FULL_FLUSH);
   CHECK_ERR(err, 'deflate');
   CHECK_ERR(err, 'deflate');
@@ -435,10 +427,10 @@ end;
   Test inflateSync()
   Test inflateSync()
  }
  }
 {$IFDEF TEST_SYNC}
 {$IFDEF TEST_SYNC}
-procedure test_sync(compr : pBytef; comprLen : uLong;
-                    uncompr : pBytef; uncomprLen : uLong);
+procedure test_sync(compr : Pbyte; comprLen : cardinal;
+                    uncompr : Pbyte; uncomprLen : cardinal);
 var
 var
-  err : int;
+  err : integer;
   d_stream : z_stream; { decompression stream }
   d_stream : z_stream; { decompression stream }
 begin
 begin
   strcopy(PChar(uncompr), 'garbage');
   strcopy(PChar(uncompr), 'garbage');
@@ -454,12 +446,12 @@ begin
   CHECK_ERR(err, 'inflateInit');
   CHECK_ERR(err, 'inflateInit');
 
 
   d_stream.next_out := uncompr;
   d_stream.next_out := uncompr;
-  d_stream.avail_out := uInt(uncomprLen);
+  d_stream.avail_out := cardinal(uncomprLen);
 
 
   inflate(d_stream, Z_NO_FLUSH);
   inflate(d_stream, Z_NO_FLUSH);
   CHECK_ERR(err, 'inflate');
   CHECK_ERR(err, 'inflate');
 
 
-  d_stream.avail_in := uInt(comprLen-2);   { read all compressed data }
+  d_stream.avail_in := cardinal(comprLen-2);   { read all compressed data }
   err := inflateSync(d_stream);           { but skip the damaged part }
   err := inflateSync(d_stream);           { but skip the damaged part }
   CHECK_ERR(err, 'inflateSync');
   CHECK_ERR(err, 'inflateSync');
 
 
@@ -481,10 +473,10 @@ end;
   Test deflate() with preset dictionary
   Test deflate() with preset dictionary
  }
  }
 {$IFDEF TEST_DICT}
 {$IFDEF TEST_DICT}
-procedure test_dict_deflate(compr : pBytef; comprLen : uLong);
+procedure test_dict_deflate(compr : Pbyte; comprLen : cardinal);
 var
 var
   c_stream : z_stream; { compression stream }
   c_stream : z_stream; { compression stream }
-  err : int;
+  err : integer;
 begin
 begin
   c_stream.zalloc := NIL; {(alloc_func)0;}
   c_stream.zalloc := NIL; {(alloc_func)0;}
   c_stream.zfree := NIL; {(free_func)0;}
   c_stream.zfree := NIL; {(free_func)0;}
@@ -494,15 +486,15 @@ begin
   CHECK_ERR(err, 'deflateInit');
   CHECK_ERR(err, 'deflateInit');
 
 
   err := deflateSetDictionary(c_stream,
   err := deflateSetDictionary(c_stream,
-                              pBytef(dictionary), StrLen(dictionary));
+                              Pbyte(dictionary), StrLen(dictionary));
   CHECK_ERR(err, 'deflateSetDictionary');
   CHECK_ERR(err, 'deflateSetDictionary');
 
 
   dictId := c_stream.adler;
   dictId := c_stream.adler;
   c_stream.next_out := compr;
   c_stream.next_out := compr;
-  c_stream.avail_out := uInt(comprLen);
+  c_stream.avail_out := cardinal(comprLen);
 
 
-  c_stream.next_in := pBytef(hello);
-  c_stream.avail_in := uInt(strlen(hello)+1);
+  c_stream.next_in := Pbyte(hello);
+  c_stream.avail_in := cardinal(strlen(hello)+1);
 
 
   err := deflate(c_stream, Z_FINISH);
   err := deflate(c_stream, Z_FINISH);
   if (err <> Z_STREAM_END) then
   if (err <> Z_STREAM_END) then
@@ -517,10 +509,10 @@ end;
 { ===========================================================================
 { ===========================================================================
   Test inflate() with a preset dictionary }
   Test inflate() with a preset dictionary }
 
 
-procedure test_dict_inflate(compr : pBytef; comprLen : uLong;
-                            uncompr : pBytef; uncomprLen : uLong);
+procedure test_dict_inflate(compr : Pbyte; comprLen : cardinal;
+                            uncompr : Pbyte; uncomprLen : cardinal);
 var
 var
-  err : int;
+  err : integer;
   d_stream : z_stream; { decompression stream }
   d_stream : z_stream; { decompression stream }
 begin
 begin
   strcopy(PChar(uncompr), 'garbage');
   strcopy(PChar(uncompr), 'garbage');
@@ -530,13 +522,13 @@ begin
   d_stream.opaque := NIL;              { voidpf(0); }
   d_stream.opaque := NIL;              { voidpf(0); }
 
 
   d_stream.next_in  := compr;
   d_stream.next_in  := compr;
-  d_stream.avail_in := uInt(comprLen);
+  d_stream.avail_in := cardinal(comprLen);
 
 
   err := inflateInit(d_stream);
   err := inflateInit(d_stream);
   CHECK_ERR(err, 'inflateInit');
   CHECK_ERR(err, 'inflateInit');
 
 
   d_stream.next_out := uncompr;
   d_stream.next_out := uncompr;
-  d_stream.avail_out := uInt(uncomprLen);
+  d_stream.avail_out := cardinal(uncomprLen);
 
 
   while TRUE do
   while TRUE do
   begin
   begin
@@ -550,7 +542,7 @@ begin
         WriteLn('unexpected dictionary');
         WriteLn('unexpected dictionary');
 	Stop;
 	Stop;
       end;
       end;
-      err := inflateSetDictionary(d_stream, pBytef(dictionary),
+      err := inflateSetDictionary(d_stream, Pbyte(dictionary),
 				     StrLen(dictionary));
 				     StrLen(dictionary));
     end;
     end;
     CHECK_ERR(err, 'inflate with dict');
     CHECK_ERR(err, 'inflate with dict');
@@ -571,13 +563,13 @@ begin
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
-function GetFromFile(buf : pBytef; FName : string;
-                     var MaxLen : uInt) : boolean;
+function GetFromFile(buf : Pbyte; FName : string;
+                     var MaxLen : cardinal) : boolean;
 const
 const
   zOfs = 0;
   zOfs = 0;
 var
 var
   f : file;
   f : file;
-  Len : uLong;
+  Len : cardinal;
 begin
 begin
   assign(f, FName);
   assign(f, FName);
   GetFromFile := false;
   GetFromFile := false;
@@ -604,17 +596,17 @@ end;
 }
 }
 
 
 var
 var
-  compr, uncompr : pBytef;
+  compr, uncompr : Pbyte;
 const
 const
   msdoslen = 25000;
   msdoslen = 25000;
-  comprLenL : uLong = msdoslen div sizeof(uInt); { don't overflow on MSDOS }
-  uncomprLenL : uLong = msdoslen div sizeof(uInt);
+  comprLenL : cardinal = msdoslen div sizeof(cardinal); { don't overflow on MSDOS }
+  uncomprLenL : cardinal = msdoslen div sizeof(cardinal);
 var
 var
   zVersion,
   zVersion,
   myVersion : string;
   myVersion : string;
 var
 var
-  comprLen : uInt;
-  uncomprLen : uInt;
+  comprLen : cardinal;
+  uncomprLen : cardinal;
 begin
 begin
   {$ifdef MemCheck}
   {$ifdef MemCheck}
   MemChk;
   MemChk;
@@ -635,20 +627,20 @@ begin
       WriteLn('warning: different zlib version');
       WriteLn('warning: different zlib version');
     end;
     end;
 
 
-  GetMem(compr, comprLen*sizeof(uInt));
-  GetMem(uncompr, uncomprLen*sizeof(uInt));
+  GetMem(compr, comprLen*sizeof(cardinal));
+  GetMem(uncompr, uncomprLen*sizeof(cardinal));
   { compr and uncompr are cleared to avoid reading uninitialized
   { compr and uncompr are cleared to avoid reading uninitialized
     data and to ensure that uncompr compresses well. }
     data and to ensure that uncompr compresses well. }
 
 
-  if (compr = Z_NULL) or (uncompr = Z_NULL) then
+  if (compr = nil) or (uncompr = nil) then
   begin
   begin
     WriteLn('out of memory');
     WriteLn('out of memory');
     Stop;
     Stop;
   end;
   end;
-  FillChar(compr^, comprLen*sizeof(uInt), 0);
-  FillChar(uncompr^, uncomprLen*sizeof(uInt), 0);
+  FillChar(compr^, comprLen*sizeof(cardinal), 0);
+  FillChar(uncompr^, uncomprLen*sizeof(cardinal), 0);
 
 
-  if (compr = Z_NULL) or (uncompr = Z_NULL) then
+  if (compr = nil) or (uncompr = nil) then
   begin
   begin
     WriteLn('out of memory');
     WriteLn('out of memory');
     Stop;
     Stop;
@@ -659,10 +651,10 @@ begin
 
 
   {$IFDEF TEST_GZIO}
   {$IFDEF TEST_GZIO}
   Case ParamCount of
   Case ParamCount of
-    0:  test_gzio('foo.gz', 'foo.gz', uncompr, int(uncomprLen));
-    1:  test_gzio(ParamStr(1), 'foo.gz', uncompr, int(uncomprLen));
+    0:  test_gzio('foo.gz', 'foo.gz', uncompr, integer(uncomprLen));
+    1:  test_gzio(ParamStr(1), 'foo.gz', uncompr, integer(uncomprLen));
   else
   else
-    test_gzio(ParamStr(1), ParamStr(2), uncompr, int(uncomprLen));
+    test_gzio(ParamStr(1), ParamStr(2), uncompr, integer(uncomprLen));
   end;
   end;
   {$ENDIF}
   {$ENDIF}
 
 
@@ -699,6 +691,6 @@ begin
   test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
   test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
   {$ENDIF}
   {$ENDIF}
   readln;
   readln;
-  FreeMem(compr, comprLen*sizeof(uInt));
-  FreeMem(uncompr, uncomprLen*sizeof(uInt));
+  FreeMem(compr, comprLen*sizeof(cardinal));
+  FreeMem(uncompr, uncomprLen*sizeof(cardinal));
 end.
 end.

+ 141 - 132
packages/base/paszlib/gzio.pas

@@ -16,39 +16,46 @@ interface
 {$I zconf.inc}
 {$I zconf.inc}
 
 
 uses
 uses
+  {$ifdef UNIX}
+  baseunix,
+  {$else}
+  dos,
+  {$endif}
+(*
   {$ifdef MSDOS}
   {$ifdef MSDOS}
   dos, strings,
   dos, strings,
   {$else}
   {$else}
   sysutils,
   sysutils,
   {$endif}
   {$endif}
+*)
   zutil, zbase, crc, zdeflate, zinflate;
   zutil, zbase, crc, zdeflate, zinflate;
 
 
-type gzFile = voidp;
-type z_off_t = long;
+type gzFile = pointer;
+type z_off_t = longint;
 
 
 function gzopen  (path:string; mode:string) : gzFile;
 function gzopen  (path:string; mode:string) : gzFile;
-function gzread  (f:gzFile; buf:voidp; len:uInt) : int;
-function gzgetc  (f:gzfile) : int;
-function gzgets  (f:gzfile; buf:PChar; len:int) : PChar;
+function gzread  (f:gzFile; buf:pointer; len:cardinal) : integer;
+function gzgetc  (f:gzfile) : integer;
+function gzgets  (f:gzfile; buf:Pchar; len:integer) : Pchar;
 
 
 {$ifndef NO_DEFLATE}
 {$ifndef NO_DEFLATE}
-function gzwrite (f:gzFile; buf:voidp; len:uInt) : int;
-function gzputc  (f:gzfile; c:char) : int;
-function gzputs  (f:gzfile; s:PChar) : int;
-function gzflush (f:gzFile; flush:int)           : int;
+function gzwrite (f:gzFile; buf:pointer; len:cardinal) : integer;
+function gzputc  (f:gzfile; c:char) : integer;
+function gzputs  (f:gzfile; s:Pchar) : integer;
+function gzflush (f:gzFile; flush:integer)           : integer;
   {$ifdef GZ_FORMAT_STRING}
   {$ifdef GZ_FORMAT_STRING}
   function gzprintf (zfile : gzFile;
   function gzprintf (zfile : gzFile;
                      const format : string;
                      const format : string;
-                     a : array of int);    { doesn't compile }
+                     a : array of integer);    { doesn't compile }
   {$endif}
   {$endif}
 {$endif}
 {$endif}
 
 
-function gzseek  (f:gzfile; offset:z_off_t; whence:int) : z_off_t;
+function gzseek  (f:gzfile; offset:z_off_t; whence:integer) : z_off_t;
 function gztell  (f:gzfile) : z_off_t;
 function gztell  (f:gzfile) : z_off_t;
-function gzclose (f:gzFile)                      : int;
-function gzerror (f:gzFile; var errnum:Int)      : string;
-function gzsetparams (f:gzfile; level:int; strategy:int) : int;
-function gzrewind (f:gzFile) : int;
+function gzclose (f:gzFile)                      : integer;
+function gzerror (f:gzFile; var errnum:integer)      : string;
+function gzsetparams (f:gzfile; level:integer; strategy:integer) : integer;
+function gzrewind (f:gzFile) : integer;
 function gzeof (f:gzfile) : boolean;
 function gzeof (f:gzfile) : boolean;
 
 
 const
 const
@@ -77,22 +84,22 @@ const
 
 
 type gz_stream = record
 type gz_stream = record
   stream      : z_stream;
   stream      : z_stream;
-  z_err       : int;      { error code for last stream operation }
+  z_err       : integer;      { error code for last stream operation }
   z_eof       : boolean;  { set if end of input file }
   z_eof       : boolean;  { set if end of input file }
   gzfile      : file;     { .gz file }
   gzfile      : file;     { .gz file }
-  inbuf       : pBytef;   { input buffer }
-  outbuf      : pBytef;   { output buffer }
-  crc         : uLong;    { crc32 of uncompressed data }
+  inbuf       : Pbyte;   { input buffer }
+  outbuf      : Pbyte;   { output buffer }
+  crc         : cardinal;    { crc32 of uncompressed data }
   msg,                    { error message - limit 79 chars }
   msg,                    { error message - limit 79 chars }
   path        : string[79];   { path name for debugging only - limit 79 chars }
   path        : string[79];   { path name for debugging only - limit 79 chars }
   transparent : boolean;  { true if input file is not a .gz file }
   transparent : boolean;  { true if input file is not a .gz file }
   mode        : char;     { 'w' or 'r' }
   mode        : char;     { 'w' or 'r' }
-  startpos    : long;     { start of compressed data in file (header skipped) }
+  startpos    : longint;     { start of compressed data in file (header skipped) }
 end;
 end;
 
 
 type gz_streamp = ^gz_stream;
 type gz_streamp = ^gz_stream;
 
 
-function destroy (var s:gz_streamp) : int; forward;
+function destroy (var s:gz_streamp) : integer; forward;
 procedure check_header(s:gz_streamp); forward;
 procedure check_header(s:gz_streamp); forward;
 
 
 
 
@@ -109,7 +116,7 @@ procedure check_header(s:gz_streamp); forward;
   gzopen can be used to open a file which is not in gzip format; in this
   gzopen can be used to open a file which is not in gzip format; in this
   case, gzread will directly read from the file without decompression.
   case, gzread will directly read from the file without decompression.
 
 
-  gzopen returns NIL if the file could not be opened (non-zero IOResult)
+  gzopen returns nil if the file could not be opened (non-zero IOResult)
   or if there was insufficient memory to allocate the (de)compression state
   or if there was insufficient memory to allocate the (de)compression state
   (zlib error is Z_MEM_ERROR).
   (zlib error is Z_MEM_ERROR).
 
 
@@ -119,14 +126,16 @@ function gzopen (path:string; mode:string) : gzFile;
 
 
 var
 var
 
 
-  i        : uInt;
-  err      : int;
-  level    : int;        { compression level }
-  strategy : int;        { compression strategy }
+  i        : cardinal;
+  err      : integer;
+  level    : integer;        { compression level }
+  strategy : integer;        { compression strategy }
   s        : gz_streamp;
   s        : gz_streamp;
-{$IFDEF MSDOS}
-  attr     : word;       { file attributes }
-{$ENDIF}  
+{$ifdef UNIX}
+  info:      stat;
+{$else}
+  attr:      word;
+{$endif}
 
 
 {$IFNDEF NO_DEFLATE}
 {$IFNDEF NO_DEFLATE}
   gzheader : array [0..9] of byte;
   gzheader : array [0..9] of byte;
@@ -135,31 +144,31 @@ var
 begin
 begin
 
 
   if (path='') or (mode='') then begin
   if (path='') or (mode='') then begin
-    gzopen := Z_NULL;
+    gzopen := nil;
     exit;
     exit;
   end;
   end;
 
 
   GetMem (s,sizeof(gz_stream));
   GetMem (s,sizeof(gz_stream));
   if not Assigned (s) then begin
   if not Assigned (s) then begin
-    gzopen := Z_NULL;
+    gzopen := nil;
     exit;
     exit;
   end;
   end;
 
 
   level := Z_DEFAULT_COMPRESSION;
   level := Z_DEFAULT_COMPRESSION;
   strategy := Z_DEFAULT_STRATEGY;
   strategy := Z_DEFAULT_STRATEGY;
 
 
-  s^.stream.zalloc := NIL;     { (alloc_func)0 }
-  s^.stream.zfree := NIL;      { (free_func)0 }
-  s^.stream.opaque := NIL;     { (voidpf)0 }
-  s^.stream.next_in := Z_NULL;
-  s^.stream.next_out := Z_NULL;
+  s^.stream.zalloc := nil;     { (alloc_func)0 }
+  s^.stream.zfree := nil;      { (free_func)0 }
+  s^.stream.opaque := nil;     { (voidpf)0 }
+  s^.stream.next_in := nil;
+  s^.stream.next_out := nil;
   s^.stream.avail_in := 0;
   s^.stream.avail_in := 0;
   s^.stream.avail_out := 0;
   s^.stream.avail_out := 0;
   s^.z_err := Z_OK;
   s^.z_err := Z_OK;
   s^.z_eof := false;
   s^.z_eof := false;
-  s^.inbuf := Z_NULL;
-  s^.outbuf := Z_NULL;
-  s^.crc := crc32(0, Z_NULL, 0);
+  s^.inbuf := nil;
+  s^.outbuf := nil;
+  s^.crc := crc32(0, nil, 0);
   s^.msg := '';
   s^.msg := '';
   s^.transparent := false;
   s^.transparent := false;
 
 
@@ -177,7 +186,7 @@ begin
   end;
   end;
   if (s^.mode=chr(0)) then begin
   if (s^.mode=chr(0)) then begin
     destroy(s);
     destroy(s);
-    gzopen := gzFile(Z_NULL);
+    gzopen := gzFile(nil);
     exit;
     exit;
   end;
   end;
 
 
@@ -192,9 +201,9 @@ begin
     GetMem (s^.outbuf, Z_BUFSIZE);
     GetMem (s^.outbuf, Z_BUFSIZE);
     s^.stream.next_out := s^.outbuf;
     s^.stream.next_out := s^.outbuf;
 {$ENDIF}
 {$ENDIF}
-    if (err <> Z_OK) or (s^.outbuf = Z_NULL) then begin
+    if (err <> Z_OK) or (s^.outbuf = nil) then begin
       destroy(s);
       destroy(s);
-      gzopen := gzFile(Z_NULL);
+      gzopen := gzFile(nil);
       exit;
       exit;
     end;
     end;
   end
   end
@@ -206,9 +215,9 @@ begin
     err := inflateInit2_ (s^.stream, -MAX_WBITS, ZLIB_VERSION, sizeof(z_stream));
     err := inflateInit2_ (s^.stream, -MAX_WBITS, ZLIB_VERSION, sizeof(z_stream));
         { windowBits is passed < 0 to tell that there is no zlib header }
         { windowBits is passed < 0 to tell that there is no zlib header }
 
 
-    if (err <> Z_OK) or (s^.inbuf = Z_NULL) then begin
+    if (err <> Z_OK) or (s^.inbuf = nil) then begin
       destroy(s);
       destroy(s);
-      gzopen := gzFile(Z_NULL);
+      gzopen := gzFile(nil);
       exit;
       exit;
     end;
     end;
   end;
   end;
@@ -217,22 +226,22 @@ begin
 
 
   {$IFOPT I+} {$I-} {$define IOcheck} {$ENDIF}
   {$IFOPT I+} {$I-} {$define IOcheck} {$ENDIF}
   Assign (s^.gzfile, s^.path);
   Assign (s^.gzfile, s^.path);
-  {$ifdef MSDOS}
-  GetFAttr(s^.gzfile, Attr);
-  if (DosError <> 0) and (s^.mode='w') then
-    ReWrite (s^.gzfile,1)
+  {$ifdef unix}
+  if (fpstat(s^.path,info)<0) and (s^.mode='w') then
+    ReWrite (s^.gzfile,1)  
   else
   else
     Reset (s^.gzfile,1);
     Reset (s^.gzfile,1);
   {$else}
   {$else}
-  if (not FileExists(s^.path)) and (s^.mode='w') then
-    ReWrite (s^.gzfile,1)  
+  GetFAttr(s^.gzfile, Attr);
+  if (DosError <> 0) and (s^.mode='w') then
+    ReWrite (s^.gzfile,1)
   else
   else
     Reset (s^.gzfile,1);
     Reset (s^.gzfile,1);
   {$endif}
   {$endif}
   {$IFDEF IOCheck} {$I+} {$ENDIF}
   {$IFDEF IOCheck} {$I+} {$ENDIF}
   if (IOResult <> 0) then begin
   if (IOResult <> 0) then begin
     destroy(s);
     destroy(s);
-    gzopen := gzFile(Z_NULL);
+    gzopen := gzFile(nil);
     exit;
     exit;
   end;
   end;
 
 
@@ -249,7 +258,7 @@ begin
     gzheader [8] := 0;            { xflags }
     gzheader [8] := 0;            { xflags }
     gzheader [9] := 0;            { OS code = MS-DOS }
     gzheader [9] := 0;            { OS code = MS-DOS }
     blockwrite (s^.gzfile, gzheader, 10);
     blockwrite (s^.gzfile, gzheader, 10);
-    s^.startpos := LONG(10);
+    s^.startpos := longint(10);
 {$ENDIF}
 {$ENDIF}
   end
   end
   else begin
   else begin
@@ -267,7 +276,7 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzsetparams (f:gzfile; level:int; strategy:int) : int;
+function gzsetparams (f:gzfile; level:integer; strategy:integer) : integer;
 
 
 var
 var
 
 
@@ -278,7 +287,7 @@ begin
 
 
   s := gz_streamp(f);
   s := gz_streamp(f);
 
 
-  if (s = NIL) or (s^.mode <> 'w') then begin
+  if (s = nil) or (s^.mode <> 'w') then begin
     gzsetparams := Z_STREAM_ERROR;
     gzsetparams := Z_STREAM_ERROR;
     exit;
     exit;
   end;
   end;
@@ -303,7 +312,7 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function get_byte (s:gz_streamp) : int;
+function get_byte (s:gz_streamp) : integer;
 
 
 begin
 begin
 
 
@@ -338,11 +347,11 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 {
 {
-function getLong (s:gz_streamp) : uLong;
+function getLong (s:gz_streamp) : cardinal;
 var
 var
   x  : array [0..3] of byte;
   x  : array [0..3] of byte;
   i  : byte;
   i  : byte;
-  c  : int;
+  c  : integer;
   n1 : longint;
   n1 : longint;
   n2 : longint;
   n2 : longint;
 begin
 begin
@@ -357,12 +366,12 @@ begin
   getlong := (n1 shl 16) or n2;
   getlong := (n1 shl 16) or n2;
 end;
 end;
 }
 }
-function getLong(s : gz_streamp) : uLong;
+function getLong(s : gz_streamp) : cardinal;
 var
 var
   x : packed array [0..3] of byte;
   x : packed array [0..3] of byte;
-  c : int;
+  c : integer;
 begin
 begin
-  { x := uLong(get_byte(s));  - you can't do this with TP, no unsigned long }
+  { x := cardinal(get_byte(s));  - you can't do this with TP, no unsigned longint }
   { the following assumes a little endian machine and TP }
   { the following assumes a little endian machine and TP }
   x[0] := Byte(get_byte(s));
   x[0] := Byte(get_byte(s));
   x[1] := Byte(get_byte(s));
   x[1] := Byte(get_byte(s));
@@ -371,7 +380,7 @@ begin
   x[3] := Byte(c);
   x[3] := Byte(c);
   if (c = Z_EOF) then
   if (c = Z_EOF) then
     s^.z_err := Z_DATA_ERROR;
     s^.z_err := Z_DATA_ERROR;
-  GetLong := uLong(longint(x));
+  GetLong := cardinal(longint(x));
 end;
 end;
 
 
 
 
@@ -392,10 +401,10 @@ procedure check_header (s:gz_streamp);
 
 
 var
 var
 
 
-  method : int;  { method byte }
-  flags  : int;  { flags byte }
-  len    : uInt;
-  c      : int;
+  method : integer;  { method byte }
+  flags  : integer;  { flags byte }
+  len    : cardinal;
+  c      : integer;
 
 
 begin
 begin
 
 
@@ -428,8 +437,8 @@ begin
   for len := 0 to 5 do get_byte(s); { Discard time, xflags and OS code }
   for len := 0 to 5 do get_byte(s); { Discard time, xflags and OS code }
 
 
   if ((flags and EXTRA_FIELD) <> 0) then begin { skip the extra field }
   if ((flags and EXTRA_FIELD) <> 0) then begin { skip the extra field }
-    len := uInt(get_byte(s));
-    len := len + (uInt(get_byte(s)) shr 8);
+    len := cardinal(get_byte(s));
+    len := len + (cardinal(get_byte(s)) shr 8);
     { len is garbage if EOF but the loop below will quit anyway }
     { len is garbage if EOF but the loop below will quit anyway }
     while (len <> 0) and (get_byte(s) <> Z_EOF) do Dec(len);
     while (len <> 0) and (get_byte(s) <> Z_EOF) do Dec(len);
   end;
   end;
@@ -466,7 +475,7 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function destroy (var s:gz_streamp) : int;
+function destroy (var s:gz_streamp) : integer;
 
 
 begin
 begin
 
 
@@ -477,7 +486,7 @@ begin
     exit;
     exit;
   end;
   end;
 
 
-  if (s^.stream.state <> NIL) then begin
+  if (s^.stream.state <> nil) then begin
     if (s^.mode = 'w') then begin
     if (s^.mode = 'w') then begin
 {$IFDEF NO_DEFLATE}
 {$IFDEF NO_DEFLATE}
       destroy := Z_STREAM_ERROR;
       destroy := Z_STREAM_ERROR;
@@ -519,27 +528,27 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzread (f:gzFile; buf:voidp; len:uInt) : int;
+function gzread (f:gzFile; buf:pointer; len:cardinal) : integer;
 
 
 var
 var
 
 
   s         : gz_streamp;
   s         : gz_streamp;
-  start     : pBytef;
-  next_out  : pBytef;
-  n         : uInt;
-  crclen    : uInt;  { Buffer length to update CRC32 }
-  filecrc   : uLong; { CRC32 stored in GZIP'ed file }
-  filelen   : uLong; { Total lenght of uncompressed file }
+  start     : Pbyte;
+  next_out  : Pbyte;
+  n         : cardinal;
+  crclen    : cardinal;  { Buffer length to update CRC32 }
+  filecrc   : cardinal; { CRC32 stored in GZIP'ed file }
+  filelen   : cardinal; { Total lenght of uncompressed file }
   bytes     : integer;  { bytes actually read in I/O blockread }
   bytes     : integer;  { bytes actually read in I/O blockread }
-  total_in  : uLong;
-  total_out : uLong;
+  total_in  : cardinal;
+  total_out : cardinal;
 
 
 begin
 begin
 
 
   s := gz_streamp(f);
   s := gz_streamp(f);
-  start := pBytef(buf); { starting point for crc computation }
+  start := Pbyte(buf); { starting point for crc computation }
 
 
-  if (s = NIL) or (s^.mode <> 'r') then begin
+  if (s = nil) or (s^.mode <> 'r') then begin
     gzread := Z_STREAM_ERROR;
     gzread := Z_STREAM_ERROR;
     exit;
     exit;
   end;
   end;
@@ -554,7 +563,7 @@ begin
     exit;
     exit;
   end;
   end;
 
 
-  s^.stream.next_out := pBytef(buf);
+  s^.stream.next_out := Pbyte(buf);
   s^.stream.avail_out := len;
   s^.stream.avail_out := len;
 
 
   while (s^.stream.avail_out <> 0) do begin
   while (s^.stream.avail_out <> 0) do begin
@@ -572,12 +581,12 @@ begin
       end;
       end;
       if (s^.stream.avail_out > 0) then begin
       if (s^.stream.avail_out > 0) then begin
         blockread (s^.gzfile, s^.stream.next_out^, s^.stream.avail_out, bytes);
         blockread (s^.gzfile, s^.stream.next_out^, s^.stream.avail_out, bytes);
-        dec (s^.stream.avail_out, uInt(bytes));
+        dec (s^.stream.avail_out, cardinal(bytes));
       end;
       end;
       dec (len, s^.stream.avail_out);
       dec (len, s^.stream.avail_out);
-      inc (s^.stream.total_in, uLong(len));
-      inc (s^.stream.total_out, uLong(len));
-      gzread := int(len);
+      inc (s^.stream.total_in, cardinal(len));
+      inc (s^.stream.total_out, cardinal(len));
+      gzread := integer(len);
       exit;
       exit;
     end; { IF transparent }
     end; { IF transparent }
 
 
@@ -623,7 +632,7 @@ begin
 	    inflateReset (s^.stream);
 	    inflateReset (s^.stream);
 	    s^.stream.total_in := total_in;
 	    s^.stream.total_in := total_in;
 	    s^.stream.total_out := total_out;
 	    s^.stream.total_out := total_out;
-	    s^.crc := crc32 (0, Z_NULL, 0);
+	    s^.crc := crc32 (0, nil, 0);
 	  end;
 	  end;
       end; {IF-THEN-ELSE}
       end; {IF-THEN-ELSE}
     end;
     end;
@@ -640,7 +649,7 @@ begin
   end;
   end;
   s^.crc := crc32 (s^.crc, start, crclen);
   s^.crc := crc32 (s^.crc, start, crclen);
 
 
-  gzread := int(len - s^.stream.avail_out);
+  gzread := integer(len - s^.stream.avail_out);
 
 
 end;
 end;
 
 
@@ -652,7 +661,7 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzgetc (f:gzfile) : int;
+function gzgetc (f:gzfile) : integer;
 
 
 var c:byte;
 var c:byte;
 
 
@@ -669,23 +678,23 @@ end;
   or a newline character is read and transferred to buf, or an end-of-file
   or a newline character is read and transferred to buf, or an end-of-file
   condition is encountered. The string is then Null-terminated.
   condition is encountered. The string is then Null-terminated.
 
 
-  gzgets returns buf, or Z_NULL in case of error.
+  gzgets returns buf, or nil in case of error.
   The current implementation is not optimized at all.
   The current implementation is not optimized at all.
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzgets (f:gzfile; buf:PChar; len:int) : PChar;
+function gzgets (f:gzfile; buf:Pchar; len:integer) : Pchar;
 
 
 var
 var
 
 
-  b      : PChar; { start of buffer }
-  bytes  : Int;   { number of bytes read by gzread }
+  b      : Pchar; { start of buffer }
+  bytes  : integer;   { number of bytes read by gzread }
   gzchar : char;  { char read by gzread }
   gzchar : char;  { char read by gzread }
 
 
 begin
 begin
 
 
-    if (buf = Z_NULL) or (len <= 0) then begin
-      gzgets := Z_NULL;
+    if (buf = nil) or (len <= 0) then begin
+      gzgets := nil;
       exit;
       exit;
     end;
     end;
 
 
@@ -698,7 +707,7 @@ begin
     until (len = 0) or (bytes <> 1) or (gzchar = Chr(13));
     until (len = 0) or (bytes <> 1) or (gzchar = Chr(13));
 
 
     buf^ := Chr(0);
     buf^ := Chr(0);
-    if (b = buf) and (len > 0) then gzgets := Z_NULL else gzgets := b;
+    if (b = buf) and (len > 0) then gzgets := nil else gzgets := b;
 
 
 end;
 end;
 
 
@@ -713,7 +722,7 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzwrite (f:gzfile; buf:voidp; len:uInt) : int;
+function gzwrite (f:gzfile; buf:pointer; len:cardinal) : integer;
 
 
 var
 var
 
 
@@ -724,12 +733,12 @@ begin
 
 
     s := gz_streamp(f);
     s := gz_streamp(f);
 
 
-    if (s = NIL) or (s^.mode <> 'w') then begin
+    if (s = nil) or (s^.mode <> 'w') then begin
       gzwrite := Z_STREAM_ERROR;
       gzwrite := Z_STREAM_ERROR;
       exit;
       exit;
     end;
     end;
 
 
-    s^.stream.next_in := pBytef(buf);
+    s^.stream.next_in := Pbyte(buf);
     s^.stream.avail_in := len;
     s^.stream.avail_in := len;
 
 
     while (s^.stream.avail_in <> 0) do begin
     while (s^.stream.avail_in <> 0) do begin
@@ -750,7 +759,7 @@ begin
     end; {WHILE}
     end; {WHILE}
 
 
     s^.crc := crc32(s^.crc, buf, len);
     s^.crc := crc32(s^.crc, buf, len);
-    gzwrite := int(len - s^.stream.avail_in);
+    gzwrite := integer(len - s^.stream.avail_in);
 
 
 end;
 end;
 
 
@@ -764,10 +773,10 @@ end;
 {$IFDEF GZ_FORMAT_STRING}
 {$IFDEF GZ_FORMAT_STRING}
 function gzprintf (zfile : gzFile;
 function gzprintf (zfile : gzFile;
                    const format : string;
                    const format : string;
-                   a : array of int) : int;
+                   a : array of integer) : integer;
 var
 var
   buf : array[0..Z_PRINTF_BUFSIZE-1] of char;
   buf : array[0..Z_PRINTF_BUFSIZE-1] of char;
-  len : int;
+  len : integer;
 begin
 begin
 {$ifdef HAS_snprintf}
 {$ifdef HAS_snprintf}
     snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
     snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
@@ -791,13 +800,13 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzputc (f:gzfile; c:char) : int;
+function gzputc (f:gzfile; c:char) : integer;
 begin
 begin
   if (gzwrite (f,@c,1) = 1) then
   if (gzwrite (f,@c,1) = 1) then
   {$IFDEF FPC}
   {$IFDEF FPC}
-    gzputc := int(ord(c))
+    gzputc := integer(ord(c))
   {$ELSE}
   {$ELSE}
-    gzputc := int(c)
+    gzputc := integer(c)
   {$ENDIF}
   {$ENDIF}
   else
   else
     gzputc := -1;
     gzputc := -1;
@@ -812,9 +821,9 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzputs (f:gzfile; s:PChar) : int;
+function gzputs (f:gzfile; s:Pchar) : integer;
 begin
 begin
-  gzputs := gzwrite (f, voidp(s), strlen(s));
+  gzputs := gzwrite (f, pointer(s), strlen(s));
 end;
 end;
 
 
 
 
@@ -825,9 +834,9 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function do_flush (f:gzfile; flush:int) : int;
+function do_flush (f:gzfile; flush:integer) : integer;
 var
 var
-  len     : uInt;
+  len     : cardinal;
   done    : boolean;
   done    : boolean;
   s       : gz_streamp;
   s       : gz_streamp;
   written : integer;
   written : integer;
@@ -835,7 +844,7 @@ begin
   done := false;
   done := false;
   s := gz_streamp(f);
   s := gz_streamp(f);
 
 
-  if (s = NIL) or (s^.mode <> 'w') then begin
+  if (s = nil) or (s^.mode <> 'w') then begin
     do_flush := Z_STREAM_ERROR;
     do_flush := Z_STREAM_ERROR;
     exit;
     exit;
   end;
   end;
@@ -890,9 +899,9 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzflush (f:gzfile; flush:int) : int;
+function gzflush (f:gzfile; flush:integer) : integer;
 var
 var
-  err : int;
+  err : integer;
   s   : gz_streamp;
   s   : gz_streamp;
 begin
 begin
   s := gz_streamp(f);
   s := gz_streamp(f);
@@ -915,13 +924,13 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzrewind (f:gzFile) : int;
+function gzrewind (f:gzFile) : integer;
 var
 var
   s:gz_streamp;
   s:gz_streamp;
 begin
 begin
   s := gz_streamp(f);
   s := gz_streamp(f);
 
 
-  if (s = NIL) or (s^.mode <> 'r') then begin
+  if (s = nil) or (s^.mode <> 'r') then begin
     gzrewind := -1;
     gzrewind := -1;
     exit;
     exit;
   end;
   end;
@@ -943,7 +952,7 @@ begin
   {$I-}
   {$I-}
   seek (s^.gzfile, s^.startpos);
   seek (s^.gzfile, s^.startpos);
   {$I+}
   {$I+}
-  gzrewind := int(IOResult);
+  gzrewind := integer(IOResult);
   exit;
   exit;
 end;
 end;
 
 
@@ -960,14 +969,14 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzseek (f:gzfile; offset:z_off_t; whence:int) : z_off_t;
+function gzseek (f:gzfile; offset:z_off_t; whence:integer) : z_off_t;
 var
 var
   s : gz_streamp;
   s : gz_streamp;
-  size : uInt;
+  size : cardinal;
 begin
 begin
   s := gz_streamp(f);
   s := gz_streamp(f);
 
 
-  if (s = NIL) or (whence = SEEK_END) or (s^.z_err = Z_ERRNO)
+  if (s = nil) or (whence = SEEK_END) or (s^.z_err = Z_ERRNO)
   or (s^.z_err = Z_DATA_ERROR) then begin
   or (s^.z_err = Z_DATA_ERROR) then begin
     gzseek := z_off_t(-1);
     gzseek := z_off_t(-1);
     exit;
     exit;
@@ -985,14 +994,14 @@ begin
     end;
     end;
 
 
     { At this point, offset is the number of zero bytes to write. }
     { At this point, offset is the number of zero bytes to write. }
-    if (s^.inbuf = Z_NULL) then begin
+    if (s^.inbuf = nil) then begin
       GetMem (s^.inbuf, Z_BUFSIZE);
       GetMem (s^.inbuf, Z_BUFSIZE);
       zmemzero(s^.inbuf, Z_BUFSIZE);
       zmemzero(s^.inbuf, Z_BUFSIZE);
     end;
     end;
 
 
     while (offset > 0) do begin
     while (offset > 0) do begin
       size := Z_BUFSIZE;
       size := Z_BUFSIZE;
-      if (offset < Z_BUFSIZE) then size := uInt(offset);
+      if (offset < Z_BUFSIZE) then size := cardinal(offset);
 
 
       size := gzwrite(f, s^.inbuf, size);
       size := gzwrite(f, s^.inbuf, size);
       if (size = 0) then begin
       if (size = 0) then begin
@@ -1027,14 +1036,14 @@ begin
       exit;
       exit;
     end;
     end;
 
 
-    s^.stream.total_in := uLong(offset);
-    s^.stream.total_out := uLong(offset);
+    s^.stream.total_in := cardinal(offset);
+    s^.stream.total_out := cardinal(offset);
     gzseek := z_off_t(offset);
     gzseek := z_off_t(offset);
     exit;
     exit;
   end;
   end;
 
 
   { For a negative seek, rewind and use positive seek }
   { For a negative seek, rewind and use positive seek }
-  if (uLong(offset) >= s^.stream.total_out)
+  if (cardinal(offset) >= s^.stream.total_out)
     then dec (offset, s^.stream.total_out)
     then dec (offset, s^.stream.total_out)
     else if (gzrewind(f) <> 0) then begin
     else if (gzrewind(f) <> 0) then begin
       gzseek := z_off_t(-1);
       gzseek := z_off_t(-1);
@@ -1042,12 +1051,12 @@ begin
   end;
   end;
   { offset is now the number of bytes to skip. }
   { offset is now the number of bytes to skip. }
 
 
-  if (offset <> 0) and (s^.outbuf = Z_NULL)
+  if (offset <> 0) and (s^.outbuf = nil)
   then GetMem (s^.outbuf, Z_BUFSIZE);
   then GetMem (s^.outbuf, Z_BUFSIZE);
 
 
   while (offset > 0) do begin
   while (offset > 0) do begin
     size := Z_BUFSIZE;
     size := Z_BUFSIZE;
-    if (offset < Z_BUFSIZE) then size := int(offset);
+    if (offset < Z_BUFSIZE) then size := integer(offset);
 
 
     size := gzread (f, s^.outbuf, size);
     size := gzread (f, s^.outbuf, size);
     if (size <= 0) then begin
     if (size <= 0) then begin
@@ -1088,7 +1097,7 @@ var
 begin
 begin
   s := gz_streamp(f);
   s := gz_streamp(f);
 
 
-  if (s=NIL) or (s^.mode<>'r') then
+  if (s=nil) or (s^.mode<>'r') then
     gzeof := false
     gzeof := false
   else
   else
     gzeof := s^.z_eof;
     gzeof := s^.z_eof;
@@ -1101,9 +1110,9 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-procedure putLong (var f:file; x:uLong);
+procedure putLong (var f:file; x:cardinal);
 var
 var
-  n : int;
+  n : integer;
   c : byte;
   c : byte;
 begin
 begin
   for n:=0 to 3 do begin
   for n:=0 to 3 do begin
@@ -1123,13 +1132,13 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzclose (f:gzFile) : int;
+function gzclose (f:gzFile) : integer;
 var
 var
-  err : int;
+  err : integer;
   s   : gz_streamp;
   s   : gz_streamp;
 begin
 begin
   s := gz_streamp(f);
   s := gz_streamp(f);
-  if (s = NIL) then begin
+  if (s = nil) then begin
     gzclose := Z_STREAM_ERROR;
     gzclose := Z_STREAM_ERROR;
     exit;
     exit;
   end;
   end;
@@ -1164,13 +1173,13 @@ end;
 
 
 ============================================================================}
 ============================================================================}
 
 
-function gzerror (f:gzfile; var errnum:int) : string;
+function gzerror (f:gzfile; var errnum:integer) : string;
 var
 var
  m : string;
  m : string;
  s : gz_streamp;
  s : gz_streamp;
 begin
 begin
   s := gz_streamp(f);
   s := gz_streamp(f);
-  if (s = NIL) then begin
+  if (s = nil) then begin
     errnum := Z_STREAM_ERROR;
     errnum := Z_STREAM_ERROR;
     gzerror := zError(Z_STREAM_ERROR);
     gzerror := zError(Z_STREAM_ERROR);
     end;
     end;

+ 125 - 128
packages/base/paszlib/infblock.pas

@@ -14,34 +14,31 @@ interface
 {$I zconf.inc}
 {$I zconf.inc}
 
 
 uses
 uses
-  {$IFDEF DEBUG}
-  strutils,
-  {$ENDIF}
   zutil, zbase;
   zutil, zbase;
 
 
 function inflate_blocks_new(var z : z_stream;
 function inflate_blocks_new(var z : z_stream;
                             c : check_func;  { check function }
                             c : check_func;  { check function }
-                            w : uInt     { window size }
+                            w : cardinal     { window size }
                             ) : pInflate_blocks_state;
                             ) : pInflate_blocks_state;
 
 
 function inflate_blocks (var s : inflate_blocks_state;
 function inflate_blocks (var s : inflate_blocks_state;
                          var z : z_stream;
                          var z : z_stream;
-                         r : int             { initial return code }
-                         ) : int;
+                         r : integer             { initial return code }
+                         ) : integer;
 
 
 procedure inflate_blocks_reset (var s : inflate_blocks_state;
 procedure inflate_blocks_reset (var s : inflate_blocks_state;
                                 var z : z_stream;
                                 var z : z_stream;
-                                c : puLong); { check value on output }
+                                c : Pcardinal); { check value on output }
 
 
 
 
 function inflate_blocks_free(s : pInflate_blocks_state;
 function inflate_blocks_free(s : pInflate_blocks_state;
-                             var z : z_stream) : int;
+                             var z : z_stream) : integer;
 
 
 procedure inflate_set_dictionary(var s : inflate_blocks_state;
 procedure inflate_set_dictionary(var s : inflate_blocks_state;
                                  const d : array of byte;  { dictionary }
                                  const d : array of byte;  { dictionary }
-                                 n : uInt);         { dictionary length }
+                                 n : cardinal);         { dictionary length }
 
 
-function inflate_blocks_sync_point(var s : inflate_blocks_state) : int;
+function inflate_blocks_sync_point(var s : inflate_blocks_state) : integer;
 
 
 implementation
 implementation
 
 
@@ -50,7 +47,7 @@ uses
 
 
 { Tables for deflate from PKZIP's appnote.txt. }
 { Tables for deflate from PKZIP's appnote.txt. }
 Const
 Const
-  border : Array [0..18] Of Word  { Order of the bit length code lengths }
+  border : array [0..18] of word  { Order of the bit length code lengths }
     = (16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15);
     = (16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15);
 
 
 { Notes beyond the 1.93a appnote.txt:
 { Notes beyond the 1.93a appnote.txt:
@@ -99,9 +96,9 @@ Const
 
 
 procedure inflate_blocks_reset (var s : inflate_blocks_state;
 procedure inflate_blocks_reset (var s : inflate_blocks_state;
                                 var z : z_stream;
                                 var z : z_stream;
-                                c : puLong); { check value on output }
+                                c : Pcardinal); { check value on output }
 begin
 begin
-  if (c <> Z_NULL) then
+  if (c <> nil) then
     c^ := s.check;
     c^ := s.check;
   if (s.mode = BTREE) or (s.mode = DTREE) then
   if (s.mode = BTREE) or (s.mode = DTREE) then
     ZFREE(z, s.sub.trees.blens);
     ZFREE(z, s.sub.trees.blens);
@@ -116,7 +113,7 @@ begin
   s.read := s.window;
   s.read := s.window;
   if Assigned(s.checkfn) then
   if Assigned(s.checkfn) then
   begin
   begin
-    s.check := s.checkfn(uLong(0), pBytef(NIL), 0);
+    s.check := s.checkfn(cardinal(0), Pbyte(NIL), 0);
     z.adler := s.check;
     z.adler := s.check;
   end;
   end;
   {$IFDEF DEBUG}
   {$IFDEF DEBUG}
@@ -127,32 +124,32 @@ end;
 
 
 function inflate_blocks_new(var z : z_stream;
 function inflate_blocks_new(var z : z_stream;
                             c : check_func;  { check function }
                             c : check_func;  { check function }
-                            w : uInt         { window size }
+                            w : cardinal         { window size }
                             ) : pInflate_blocks_state;
                             ) : pInflate_blocks_state;
 var
 var
   s : pInflate_blocks_state;
   s : pInflate_blocks_state;
 begin
 begin
   s := pInflate_blocks_state( ZALLOC(z,1, sizeof(inflate_blocks_state)) );
   s := pInflate_blocks_state( ZALLOC(z,1, sizeof(inflate_blocks_state)) );
-  if (s = Z_NULL) then
+  if (s = nil) then
   begin
   begin
     inflate_blocks_new := s;
     inflate_blocks_new := s;
     exit;
     exit;
   end;
   end;
   s^.hufts := huft_ptr( ZALLOC(z, sizeof(inflate_huft), MANY) );
   s^.hufts := huft_ptr( ZALLOC(z, sizeof(inflate_huft), MANY) );
 
 
-  if (s^.hufts = Z_NULL) then
+  if (s^.hufts = nil) then
   begin
   begin
     ZFREE(z, s);
     ZFREE(z, s);
-    inflate_blocks_new := Z_NULL;
+    inflate_blocks_new := nil;
     exit;
     exit;
   end;
   end;
 
 
-  s^.window := pBytef( ZALLOC(z, 1, w) );
-  if (s^.window = Z_NULL) then
+  s^.window := Pbyte( ZALLOC(z, 1, w) );
+  if (s^.window = nil) then
   begin
   begin
     ZFREE(z, s^.hufts);
     ZFREE(z, s^.hufts);
     ZFREE(z, s);
     ZFREE(z, s);
-    inflate_blocks_new := Z_NULL;
+    inflate_blocks_new := nil;
     exit;
     exit;
   end;
   end;
   s^.zend := s^.window;
   s^.zend := s^.window;
@@ -162,34 +159,34 @@ begin
   {$IFDEF DEBUG}  
   {$IFDEF DEBUG}  
   Tracev('inflate:   blocks allocated');
   Tracev('inflate:   blocks allocated');
   {$ENDIF}
   {$ENDIF}
-  inflate_blocks_reset(s^, z, Z_NULL);
+  inflate_blocks_reset(s^, z, nil);
   inflate_blocks_new := s;
   inflate_blocks_new := s;
 end;
 end;
 
 
 
 
 function inflate_blocks (var s : inflate_blocks_state;
 function inflate_blocks (var s : inflate_blocks_state;
                          var z : z_stream;
                          var z : z_stream;
-                         r : int) : int;           { initial return code }
+                         r : integer) : integer;           { initial return code }
 label
 label
   start_btree, start_dtree,
   start_btree, start_dtree,
   start_blkdone, start_dry,
   start_blkdone, start_dry,
   start_codes;
   start_codes;
 
 
 var
 var
-  t : uInt;               { temporary storage }
-  b : uLong;              { bit buffer }
-  k : uInt;               { bits in bit buffer }
-  p : pBytef;             { input data pointer }
-  n : uInt;               { bytes available there }
-  q : pBytef;             { output window write pointer }
-  m : uInt;               { bytes to end of window or read pointer }
+  t : cardinal;               { temporary storage }
+  b : cardinal;              { bit buffer }
+  k : cardinal;               { bits in bit buffer }
+  p : Pbyte;             { input data pointer }
+  n : cardinal;               { bytes available there }
+  q : Pbyte;             { output window write pointer }
+  m : cardinal;               { bytes to end of window or read pointer }
 { fixed code blocks }
 { fixed code blocks }
 var
 var
-  bl, bd : uInt;
+  bl, bd : cardinal;
   tl, td : pInflate_huft;
   tl, td : pInflate_huft;
 var
 var
   h : pInflate_huft;
   h : pInflate_huft;
-  i, j, c : uInt;
+  i, j, c : cardinal;
 var
 var
   cs : pInflate_codes_state;
   cs : pInflate_codes_state;
 begin
 begin
@@ -199,10 +196,10 @@ begin
   b := s.bitb;
   b := s.bitb;
   k := s.bitk;
   k := s.bitk;
   q := s.write;
   q := s.write;
-  if ptr2int(q) < ptr2int(s.read) then
-    m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+  if ptrint(q) < ptrint(s.read) then
+    m := cardinal(ptrint(s.read)-ptrint(q)-1)
   else
   else
-    m := uInt(ptr2int(s.zend)-ptr2int(q));
+    m := cardinal(ptrint(s.zend)-ptrint(q));
 
 
 { decompress an inflated block }
 { decompress an inflated block }
 
 
@@ -224,19 +221,19 @@ begin
             s.bitb := b;
             s.bitb := b;
             s.bitk := k;
             s.bitk := k;
             z.avail_in := n;
             z.avail_in := n;
-            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
             z.next_in := p;
             z.next_in := p;
             s.write := q;
             s.write := q;
             inflate_blocks := inflate_flush(s,z,r);
             inflate_blocks := inflate_flush(s,z,r);
             exit;
             exit;
           end;
           end;
-          Dec(n);
-          b := b or (uLong(p^) shl k);
+          dec(n);
+          b := b or (cardinal(p^) shl k);
           Inc(p);
           Inc(p);
           Inc(k, 8);
           Inc(k, 8);
         end;
         end;
 
 
-        t := uInt(b) and 7;
+        t := cardinal(b) and 7;
         s.last := boolean(t and 1);
         s.last := boolean(t and 1);
         case (t shr 1) of
         case (t shr 1) of
           0:                         { stored }
           0:                         { stored }
@@ -249,12 +246,12 @@ begin
               {$ENDIF}
               {$ENDIF}
               {DUMPBITS(3);}
               {DUMPBITS(3);}
               b := b shr 3;
               b := b shr 3;
-              Dec(k, 3);
+              dec(k, 3);
 
 
               t := k and 7;                  { go to byte boundary }
               t := k and 7;                  { go to byte boundary }
               {DUMPBITS(t);}
               {DUMPBITS(t);}
               b := b shr t;
               b := b shr t;
-              Dec(k, t);
+              dec(k, t);
 
 
               s.mode := LENS;                { get length of stored block }
               s.mode := LENS;                { get length of stored block }
             end;
             end;
@@ -269,14 +266,14 @@ begin
                 {$ENDIF}
                 {$ENDIF}
                 inflate_trees_fixed(bl, bd, tl, td, z);
                 inflate_trees_fixed(bl, bd, tl, td, z);
                 s.sub.decode.codes := inflate_codes_new(bl, bd, tl, td, z);
                 s.sub.decode.codes := inflate_codes_new(bl, bd, tl, td, z);
-                if (s.sub.decode.codes = Z_NULL) then
+                if (s.sub.decode.codes = nil) then
                 begin
                 begin
                   r := Z_MEM_ERROR;
                   r := Z_MEM_ERROR;
                   { update pointers and return }
                   { update pointers and return }
                   s.bitb := b;
                   s.bitb := b;
                   s.bitk := k;
                   s.bitk := k;
                   z.avail_in := n;
                   z.avail_in := n;
-                  Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+                  Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
                   z.next_in := p;
                   z.next_in := p;
                   s.write := q;
                   s.write := q;
                   inflate_blocks := inflate_flush(s,z,r);
                   inflate_blocks := inflate_flush(s,z,r);
@@ -285,7 +282,7 @@ begin
               end;
               end;
               {DUMPBITS(3);}
               {DUMPBITS(3);}
               b := b shr 3;
               b := b shr 3;
-              Dec(k, 3);
+              dec(k, 3);
 
 
               s.mode := CODES;
               s.mode := CODES;
             end;
             end;
@@ -299,7 +296,7 @@ begin
               {$ENDIF}                
               {$ENDIF}                
               {DUMPBITS(3);}
               {DUMPBITS(3);}
               b := b shr 3;
               b := b shr 3;
-              Dec(k, 3);
+              dec(k, 3);
 
 
               s.mode := TABLE;
               s.mode := TABLE;
             end;
             end;
@@ -307,7 +304,7 @@ begin
             begin                   { illegal }
             begin                   { illegal }
               {DUMPBITS(3);}
               {DUMPBITS(3);}
               b := b shr 3;
               b := b shr 3;
-              Dec(k, 3);
+              dec(k, 3);
 
 
               s.mode := BLKBAD;
               s.mode := BLKBAD;
               z.msg := 'invalid block type';
               z.msg := 'invalid block type';
@@ -316,7 +313,7 @@ begin
               s.bitb := b;
               s.bitb := b;
               s.bitk := k;
               s.bitk := k;
               z.avail_in := n;
               z.avail_in := n;
-              Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+              Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
               z.next_in := p;
               z.next_in := p;
               s.write := q;
               s.write := q;
               inflate_blocks := inflate_flush(s,z,r);
               inflate_blocks := inflate_flush(s,z,r);
@@ -338,14 +335,14 @@ begin
             s.bitb := b;
             s.bitb := b;
             s.bitk := k;
             s.bitk := k;
             z.avail_in := n;
             z.avail_in := n;
-            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
             z.next_in := p;
             z.next_in := p;
             s.write := q;
             s.write := q;
             inflate_blocks := inflate_flush(s,z,r);
             inflate_blocks := inflate_flush(s,z,r);
             exit;
             exit;
           end;
           end;
-          Dec(n);
-          b := b or (uLong(p^) shl k);
+          dec(n);
+          b := b or (cardinal(p^) shl k);
           Inc(p);
           Inc(p);
           Inc(k, 8);
           Inc(k, 8);
         end;
         end;
@@ -359,13 +356,13 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_blocks := inflate_flush(s,z,r);
           inflate_blocks := inflate_flush(s,z,r);
           exit;
           exit;
         end;
         end;
-        s.sub.left := uInt(b) and $ffff;
+        s.sub.left := cardinal(b) and $ffff;
         k := 0;
         k := 0;
         b := 0;                      { dump bits }
         b := 0;                      { dump bits }
         {$IFDEF DEBUG}
         {$IFDEF DEBUG}
@@ -387,7 +384,7 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_blocks := inflate_flush(s,z,r);
           inflate_blocks := inflate_flush(s,z,r);
@@ -400,10 +397,10 @@ begin
           if (q = s.zend) and (s.read <> s.window) then
           if (q = s.zend) and (s.read <> s.window) then
           begin
           begin
             q := s.window;
             q := s.window;
-            if ptr2int(q) < ptr2int(s.read) then
-              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            if ptrint(q) < ptrint(s.read) then
+              m := cardinal(ptrint(s.read)-ptrint(q)-1)
             else
             else
-              m := uInt(ptr2int(s.zend)-ptr2int(q));
+              m := cardinal(ptrint(s.zend)-ptrint(q));
           end;
           end;
 
 
           if (m = 0) then
           if (m = 0) then
@@ -412,19 +409,19 @@ begin
             s.write := q;
             s.write := q;
             r := inflate_flush(s,z,r);
             r := inflate_flush(s,z,r);
             q := s.write;
             q := s.write;
-            if ptr2int(q) < ptr2int(s.read) then
-              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            if ptrint(q) < ptrint(s.read) then
+              m := cardinal(ptrint(s.read)-ptrint(q)-1)
             else
             else
-              m := uInt(ptr2int(s.zend)-ptr2int(q));
+              m := cardinal(ptrint(s.zend)-ptrint(q));
 
 
             {WRAP}
             {WRAP}
             if (q = s.zend) and (s.read <> s.window) then
             if (q = s.zend) and (s.read <> s.window) then
             begin
             begin
               q := s.window;
               q := s.window;
-              if ptr2int(q) < ptr2int(s.read) then
-                m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+              if ptrint(q) < ptrint(s.read) then
+                m := cardinal(ptrint(s.read)-ptrint(q)-1)
               else
               else
-                m := uInt(ptr2int(s.zend)-ptr2int(q));
+                m := cardinal(ptrint(s.zend)-ptrint(q));
             end;
             end;
 
 
             if (m = 0) then
             if (m = 0) then
@@ -433,7 +430,7 @@ begin
               s.bitb := b;
               s.bitb := b;
               s.bitk := k;
               s.bitk := k;
               z.avail_in := n;
               z.avail_in := n;
-              Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+              Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
               z.next_in := p;
               z.next_in := p;
               s.write := q;
               s.write := q;
               inflate_blocks := inflate_flush(s,z,r);
               inflate_blocks := inflate_flush(s,z,r);
@@ -449,19 +446,19 @@ begin
         if (t > m) then
         if (t > m) then
           t := m;
           t := m;
         zmemcpy(q, p, t);
         zmemcpy(q, p, t);
-        Inc(p, t);  Dec(n, t);
-        Inc(q, t);  Dec(m, t);
-        Dec(s.sub.left, t);
+        Inc(p, t);  dec(n, t);
+        Inc(q, t);  dec(m, t);
+        dec(s.sub.left, t);
         if (s.sub.left = 0) then
         if (s.sub.left = 0) then
         begin
         begin
           {$IFDEF DEBUG}
           {$IFDEF DEBUG}
-          if (ptr2int(q) >= ptr2int(s.read)) then
+          if (ptrint(q) >= ptrint(s.read)) then
             Tracev('inflate:       stored end '+
             Tracev('inflate:       stored end '+
-                IntToStr(z.total_out + ptr2int(q) - ptr2int(s.read)) + ' total out')
+                IntToStr(z.total_out + ptrint(q) - ptrint(s.read)) + ' total out')
           else
           else
             Tracev('inflate:       stored end '+
             Tracev('inflate:       stored end '+
-                    IntToStr(z.total_out + ptr2int(s.zend) - ptr2int(s.read) +
-                    ptr2int(q) - ptr2int(s.window)) +  ' total out');
+                    IntToStr(z.total_out + ptrint(s.zend) - ptrint(s.read) +
+                    ptrint(q) - ptrint(s.window)) +  ' total out');
           {$ENDIF}
           {$ENDIF}
           if s.last then
           if s.last then
             s.mode := DRY
             s.mode := DRY
@@ -483,19 +480,19 @@ begin
             s.bitb := b;
             s.bitb := b;
             s.bitk := k;
             s.bitk := k;
             z.avail_in := n;
             z.avail_in := n;
-            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
             z.next_in := p;
             z.next_in := p;
             s.write := q;
             s.write := q;
             inflate_blocks := inflate_flush(s,z,r);
             inflate_blocks := inflate_flush(s,z,r);
             exit;
             exit;
           end;
           end;
-          Dec(n);
-          b := b or (uLong(p^) shl k);
+          dec(n);
+          b := b or (cardinal(p^) shl k);
           Inc(p);
           Inc(p);
           Inc(k, 8);
           Inc(k, 8);
         end;
         end;
 
 
-        t := uInt(b) and $3fff;
+        t := cardinal(b) and $3fff;
         s.sub.trees.table := t;
         s.sub.trees.table := t;
   {$ifndef PKZIP_BUG_WORKAROUND}
   {$ifndef PKZIP_BUG_WORKAROUND}
         if ((t and $1f) > 29) or (((t shr 5) and $1f) > 29) then
         if ((t and $1f) > 29) or (((t shr 5) and $1f) > 29) then
@@ -507,7 +504,7 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_blocks := inflate_flush(s,z,r);
           inflate_blocks := inflate_flush(s,z,r);
@@ -515,15 +512,15 @@ begin
         end;
         end;
   {$endif}
   {$endif}
         t := 258 + (t and $1f) + ((t shr 5) and $1f);
         t := 258 + (t and $1f) + ((t shr 5) and $1f);
-        s.sub.trees.blens := puIntArray( ZALLOC(z, t, sizeof(uInt)) );
-        if (s.sub.trees.blens = Z_NULL) then
+        s.sub.trees.blens := puIntArray( ZALLOC(z, t, sizeof(cardinal)) );
+        if (s.sub.trees.blens = nil) then
         begin
         begin
           r := Z_MEM_ERROR;
           r := Z_MEM_ERROR;
           { update pointers and return }
           { update pointers and return }
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_blocks := inflate_flush(s,z,r);
           inflate_blocks := inflate_flush(s,z,r);
@@ -531,7 +528,7 @@ begin
         end;
         end;
         {DUMPBITS(14);}
         {DUMPBITS(14);}
         b := b shr 14;
         b := b shr 14;
-        Dec(k, 14);
+        dec(k, 14);
 
 
         s.sub.trees.index := 0;
         s.sub.trees.index := 0;
         {$IFDEF DEBUG}
         {$IFDEF DEBUG}
@@ -559,23 +556,23 @@ begin
               s.bitb := b;
               s.bitb := b;
               s.bitk := k;
               s.bitk := k;
               z.avail_in := n;
               z.avail_in := n;
-              Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+              Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
               z.next_in := p;
               z.next_in := p;
               s.write := q;
               s.write := q;
               inflate_blocks := inflate_flush(s,z,r);
               inflate_blocks := inflate_flush(s,z,r);
               exit;
               exit;
             end;
             end;
-            Dec(n);
-            b := b or (uLong(p^) shl k);
+            dec(n);
+            b := b or (cardinal(p^) shl k);
             Inc(p);
             Inc(p);
             Inc(k, 8);
             Inc(k, 8);
           end;
           end;
 
 
-          s.sub.trees.blens^[border[s.sub.trees.index]] := uInt(b) and 7;
+          s.sub.trees.blens^[border[s.sub.trees.index]] := cardinal(b) and 7;
           Inc(s.sub.trees.index);
           Inc(s.sub.trees.index);
           {DUMPBITS(3);}
           {DUMPBITS(3);}
           b := b shr 3;
           b := b shr 3;
-          Dec(k, 3);
+          dec(k, 3);
         end;
         end;
         while (s.sub.trees.index < 19) do
         while (s.sub.trees.index < 19) do
         begin
         begin
@@ -595,7 +592,7 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_blocks := inflate_flush(s,z,r);
           inflate_blocks := inflate_flush(s,z,r);
@@ -631,20 +628,20 @@ begin
               s.bitb := b;
               s.bitb := b;
               s.bitk := k;
               s.bitk := k;
               z.avail_in := n;
               z.avail_in := n;
-              Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+              Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
               z.next_in := p;
               z.next_in := p;
               s.write := q;
               s.write := q;
               inflate_blocks := inflate_flush(s,z,r);
               inflate_blocks := inflate_flush(s,z,r);
               exit;
               exit;
             end;
             end;
-            Dec(n);
-            b := b or (uLong(p^) shl k);
+            dec(n);
+            b := b or (cardinal(p^) shl k);
             Inc(p);
             Inc(p);
             Inc(k, 8);
             Inc(k, 8);
           end;
           end;
 
 
           h := s.sub.trees.tb;
           h := s.sub.trees.tb;
-          Inc(h, uInt(b) and inflate_mask[t]);
+          Inc(h, cardinal(b) and inflate_mask[t]);
           t := h^.Bits;
           t := h^.Bits;
           c := h^.Base;
           c := h^.Base;
 
 
@@ -652,7 +649,7 @@ begin
           begin
           begin
             {DUMPBITS(t);}
             {DUMPBITS(t);}
             b := b shr t;
             b := b shr t;
-            Dec(k, t);
+            dec(k, t);
 
 
             s.sub.trees.blens^[s.sub.trees.index] := c;
             s.sub.trees.blens^[s.sub.trees.index] := c;
             Inc(s.sub.trees.index);
             Inc(s.sub.trees.index);
@@ -681,26 +678,26 @@ begin
                 s.bitb := b;
                 s.bitb := b;
                 s.bitk := k;
                 s.bitk := k;
                 z.avail_in := n;
                 z.avail_in := n;
-                Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+                Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
                 z.next_in := p;
                 z.next_in := p;
                 s.write := q;
                 s.write := q;
                 inflate_blocks := inflate_flush(s,z,r);
                 inflate_blocks := inflate_flush(s,z,r);
                 exit;
                 exit;
               end;
               end;
-              Dec(n);
-              b := b or (uLong(p^) shl k);
+              dec(n);
+              b := b or (cardinal(p^) shl k);
               Inc(p);
               Inc(p);
               Inc(k, 8);
               Inc(k, 8);
             end;
             end;
 
 
             {DUMPBITS(t);}
             {DUMPBITS(t);}
             b := b shr t;
             b := b shr t;
-            Dec(k, t);
+            dec(k, t);
 
 
-            Inc(j, uInt(b) and inflate_mask[i]);
+            Inc(j, cardinal(b) and inflate_mask[i]);
             {DUMPBITS(i);}
             {DUMPBITS(i);}
             b := b shr i;
             b := b shr i;
-            Dec(k, i);
+            dec(k, i);
 
 
             i := s.sub.trees.index;
             i := s.sub.trees.index;
             t := s.sub.trees.table;
             t := s.sub.trees.table;
@@ -715,7 +712,7 @@ begin
               s.bitb := b;
               s.bitb := b;
               s.bitk := k;
               s.bitk := k;
               z.avail_in := n;
               z.avail_in := n;
-              Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+              Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
               z.next_in := p;
               z.next_in := p;
               s.write := q;
               s.write := q;
               inflate_blocks := inflate_flush(s,z,r);
               inflate_blocks := inflate_flush(s,z,r);
@@ -728,12 +725,12 @@ begin
             repeat
             repeat
               s.sub.trees.blens^[i] := c;
               s.sub.trees.blens^[i] := c;
               Inc(i);
               Inc(i);
-              Dec(j);
+              dec(j);
             until (j=0);
             until (j=0);
             s.sub.trees.index := i;
             s.sub.trees.index := i;
           end;
           end;
         end; { while }
         end; { while }
-        s.sub.trees.tb := Z_NULL;
+        s.sub.trees.tb := nil;
         begin
         begin
           bl := 9;         { must be <= 9 for lookahead assumptions }
           bl := 9;         { must be <= 9 for lookahead assumptions }
           bd := 6;         { must be <= 9 for lookahead assumptions }
           bd := 6;         { must be <= 9 for lookahead assumptions }
@@ -744,14 +741,14 @@ begin
           ZFREE(z, s.sub.trees.blens);
           ZFREE(z, s.sub.trees.blens);
           if (t <> Z_OK) then
           if (t <> Z_OK) then
           begin
           begin
-            if (t = uInt(Z_DATA_ERROR)) then
+            if (t = cardinal(Z_DATA_ERROR)) then
               s.mode := BLKBAD;
               s.mode := BLKBAD;
             r := t;
             r := t;
             { update pointers and return }
             { update pointers and return }
             s.bitb := b;
             s.bitb := b;
             s.bitk := k;
             s.bitk := k;
             z.avail_in := n;
             z.avail_in := n;
-            Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+            Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
             z.next_in := p;
             z.next_in := p;
             s.write := q;
             s.write := q;
             inflate_blocks := inflate_flush(s,z,r);
             inflate_blocks := inflate_flush(s,z,r);
@@ -762,14 +759,14 @@ begin
           {$ENDIF}          
           {$ENDIF}          
           { c renamed to cs }
           { c renamed to cs }
           cs := inflate_codes_new(bl, bd, tl, td, z);
           cs := inflate_codes_new(bl, bd, tl, td, z);
-          if (cs = Z_NULL) then
+          if (cs = nil) then
           begin
           begin
             r := Z_MEM_ERROR;
             r := Z_MEM_ERROR;
             { update pointers and return }
             { update pointers and return }
             s.bitb := b;
             s.bitb := b;
             s.bitk := k;
             s.bitk := k;
             z.avail_in := n;
             z.avail_in := n;
-            Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+            Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
             z.next_in := p;
             z.next_in := p;
             s.write := q;
             s.write := q;
             inflate_blocks := inflate_flush(s,z,r);
             inflate_blocks := inflate_flush(s,z,r);
@@ -788,7 +785,7 @@ begin
         s.bitb := b;
         s.bitb := b;
         s.bitk := k;
         s.bitk := k;
         z.avail_in := n;
         z.avail_in := n;
-        Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+        Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
         z.next_in := p;
         z.next_in := p;
         s.write := q;
         s.write := q;
 
 
@@ -806,18 +803,18 @@ begin
         b := s.bitb;
         b := s.bitb;
         k := s.bitk;
         k := s.bitk;
         q := s.write;
         q := s.write;
-        if ptr2int(q) < ptr2int(s.read) then
-          m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+        if ptrint(q) < ptrint(s.read) then
+          m := cardinal(ptrint(s.read)-ptrint(q)-1)
         else
         else
-          m := uInt(ptr2int(s.zend)-ptr2int(q));
+          m := cardinal(ptrint(s.zend)-ptrint(q));
         {$IFDEF DEBUG}
         {$IFDEF DEBUG}
-        if (ptr2int(q) >= ptr2int(s.read)) then
+        if (ptrint(q) >= ptrint(s.read)) then
           Tracev('inflate:       codes end '+
           Tracev('inflate:       codes end '+
-              IntToStr(z.total_out + ptr2int(q) - ptr2int(s.read)) + ' total out')
+              IntToStr(z.total_out + ptrint(q) - ptrint(s.read)) + ' total out')
         else
         else
           Tracev('inflate:       codes end '+
           Tracev('inflate:       codes end '+
-                  IntToStr(z.total_out + ptr2int(s.zend) - ptr2int(s.read) +
-                  ptr2int(q) - ptr2int(s.window)) +  ' total out');
+                  IntToStr(z.total_out + ptrint(s.zend) - ptrint(s.read) +
+                  ptrint(q) - ptrint(s.window)) +  ' total out');
         {$ENDIF}
         {$ENDIF}
         if (not s.last) then
         if (not s.last) then
         begin
         begin
@@ -830,9 +827,9 @@ begin
           {$IFDEF DEBUG}
           {$IFDEF DEBUG}
           Assert(k < 16, 'inflate_codes grabbed too many bytes');
           Assert(k < 16, 'inflate_codes grabbed too many bytes');
           {$ENDIF}
           {$ENDIF}
-          Dec(k, 8);
-          Inc(n);
-          Dec(p);                    { can always return one }
+          dec(k, 8);
+          inc(n);
+          dec(p);                    { can always return one }
         end;
         end;
         {$endif}
         {$endif}
         s.mode := DRY;
         s.mode := DRY;
@@ -848,10 +845,10 @@ begin
         q := s.write;
         q := s.write;
 
 
         { not needed anymore, we are done:
         { not needed anymore, we are done:
-        if ptr2int(q) < ptr2int(s.read) then
-          m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+        if ptrint(q) < ptrint(s.read) then
+          m := cardinal(ptrint(s.read)-ptrint(q)-1)
         else
         else
-          m := uInt(ptr2int(s.zend)-ptr2int(q));
+          m := cardinal(ptrint(s.zend)-ptrint(q));
         }
         }
 
 
         if (s.read <> s.write) then
         if (s.read <> s.write) then
@@ -860,7 +857,7 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_blocks := inflate_flush(s,z,r);
           inflate_blocks := inflate_flush(s,z,r);
@@ -877,7 +874,7 @@ begin
         s.bitb := b;
         s.bitb := b;
         s.bitk := k;
         s.bitk := k;
         z.avail_in := n;
         z.avail_in := n;
-        Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+        Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
         z.next_in := p;
         z.next_in := p;
         s.write := q;
         s.write := q;
         inflate_blocks := inflate_flush(s,z,r);
         inflate_blocks := inflate_flush(s,z,r);
@@ -890,7 +887,7 @@ begin
         s.bitb := b;
         s.bitb := b;
         s.bitk := k;
         s.bitk := k;
         z.avail_in := n;
         z.avail_in := n;
-        Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+        Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
         z.next_in := p;
         z.next_in := p;
         s.write := q;
         s.write := q;
         inflate_blocks := inflate_flush(s,z,r);
         inflate_blocks := inflate_flush(s,z,r);
@@ -903,7 +900,7 @@ begin
       s.bitb := b;
       s.bitb := b;
       s.bitk := k;
       s.bitk := k;
       z.avail_in := n;
       z.avail_in := n;
-      Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+      Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
       z.next_in := p;
       z.next_in := p;
       s.write := q;
       s.write := q;
       inflate_blocks := inflate_flush(s,z,r);
       inflate_blocks := inflate_flush(s,z,r);
@@ -915,9 +912,9 @@ end;
 
 
 
 
 function inflate_blocks_free(s : pInflate_blocks_state;
 function inflate_blocks_free(s : pInflate_blocks_state;
-                             var z : z_stream) : int;
+                             var z : z_stream) : integer;
 begin
 begin
-  inflate_blocks_reset(s^, z, Z_NULL);
+  inflate_blocks_reset(s^, z, nil);
   ZFREE(z, s^.window);
   ZFREE(z, s^.window);
   ZFREE(z, s^.hufts);
   ZFREE(z, s^.hufts);
   ZFREE(z, s);
   ZFREE(z, s);
@@ -930,9 +927,9 @@ end;
 
 
 procedure inflate_set_dictionary(var s : inflate_blocks_state;
 procedure inflate_set_dictionary(var s : inflate_blocks_state;
                                  const d : array of byte; { dictionary }
                                  const d : array of byte; { dictionary }
-                                 n : uInt);         { dictionary length }
+                                 n : cardinal);         { dictionary length }
 begin
 begin
-  zmemcpy(s.window, pBytef(@d), n);
+  zmemcpy(s.window, Pbyte(@d), n);
   s.write := s.window;
   s.write := s.window;
   Inc(s.write, n);
   Inc(s.write, n);
   s.read := s.write;
   s.read := s.write;
@@ -941,11 +938,11 @@ end;
 
 
 { Returns true if inflate is currently at the end of a block generated
 { Returns true if inflate is currently at the end of a block generated
   by Z_SYNC_FLUSH or Z_FULL_FLUSH.
   by Z_SYNC_FLUSH or Z_FULL_FLUSH.
-  IN assertion: s <> Z_NULL }
+  IN assertion: s <> nil }
 
 
-function inflate_blocks_sync_point(var s : inflate_blocks_state) : int;
+function inflate_blocks_sync_point(var s : inflate_blocks_state) : integer;
 begin
 begin
-  inflate_blocks_sync_point := int(s.mode = LENS);
+  inflate_blocks_sync_point := integer(s.mode = LENS);
 end;
 end;
 
 
 end.
 end.

+ 82 - 85
packages/base/paszlib/infcodes.pas

@@ -1,4 +1,4 @@
-Unit InfCodes;
+unit infcodes;
 
 
 { infcodes.c -- process literals and length/distance pairs
 { infcodes.c -- process literals and length/distance pairs
   Copyright (C) 1995-1998 Mark Adler
   Copyright (C) 1995-1998 Mark Adler
@@ -13,20 +13,17 @@ interface
 {$I zconf.inc}
 {$I zconf.inc}
 
 
 uses
 uses
-  {$IFDEF DEBUG}
-  strutils,
-  {$ENDIF}
   zutil, zbase;
   zutil, zbase;
 
 
-function inflate_codes_new (bl : uInt;
-                            bd : uInt;
+function inflate_codes_new (bl : cardinal;
+                            bd : cardinal;
                             tl : pInflate_huft;
                             tl : pInflate_huft;
                             td : pInflate_huft;
                             td : pInflate_huft;
                             var z : z_stream): pInflate_codes_state;
                             var z : z_stream): pInflate_codes_state;
 
 
 function inflate_codes(var s : inflate_blocks_state;
 function inflate_codes(var s : inflate_blocks_state;
                        var z : z_stream;
                        var z : z_stream;
-                       r : int) : int;
+                       r : integer) : integer;
 
 
 procedure inflate_codes_free(c : pInflate_codes_state;
 procedure inflate_codes_free(c : pInflate_codes_state;
                              var z : z_stream);
                              var z : z_stream);
@@ -37,8 +34,8 @@ uses
   infutil, inffast;
   infutil, inffast;
 
 
 
 
-function inflate_codes_new (bl : uInt;
-                            bd : uInt;
+function inflate_codes_new (bl : cardinal;
+                            bd : cardinal;
                             tl : pInflate_huft;
                             tl : pInflate_huft;
                             td : pInflate_huft;
                             td : pInflate_huft;
                             var z : z_stream): pInflate_codes_state;
                             var z : z_stream): pInflate_codes_state;
@@ -63,18 +60,18 @@ end;
 
 
 function inflate_codes(var s : inflate_blocks_state;
 function inflate_codes(var s : inflate_blocks_state;
                        var z : z_stream;
                        var z : z_stream;
-                       r : int) : int;
+                       r : integer) : integer;
 var
 var
-  j : uInt;               { temporary storage }
+  j : cardinal;               { temporary storage }
   t : pInflate_huft;      { temporary pointer }
   t : pInflate_huft;      { temporary pointer }
-  e : uInt;               { extra bits or operation }
-  b : uLong;              { bit buffer }
-  k : uInt;               { bits in bit buffer }
-  p : pBytef;             { input data pointer }
-  n : uInt;               { bytes available there }
-  q : pBytef;             { output window write pointer }
-  m : uInt;               { bytes to end of window or read pointer }
-  f : pBytef;             { pointer to copy strings from }
+  e : cardinal;               { extra bits or operation }
+  b : cardinal;              { bit buffer }
+  k : cardinal;               { bits in bit buffer }
+  p : Pbyte;             { input data pointer }
+  n : cardinal;               { bytes available there }
+  q : Pbyte;             { output window write pointer }
+  m : cardinal;               { bytes to end of window or read pointer }
+  f : Pbyte;             { pointer to copy strings from }
 var
 var
   c : pInflate_codes_state;
   c : pInflate_codes_state;
 begin
 begin
@@ -86,10 +83,10 @@ begin
   b := s.bitb;
   b := s.bitb;
   k := s.bitk;
   k := s.bitk;
   q := s.write;
   q := s.write;
-  if ptr2int(q) < ptr2int(s.read) then
-    m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+  if ptrint(q) < ptrint(s.read) then
+    m := cardinal(ptrint(s.read)-ptrint(q)-1)
   else
   else
-    m := uInt(ptr2int(s.zend)-ptr2int(q));
+    m := cardinal(ptrint(s.zend)-ptrint(q));
 
 
   { process input and output based on current state }
   { process input and output based on current state }
   while True do
   while True do
@@ -104,7 +101,7 @@ begin
         s.bitb := b;
         s.bitb := b;
         s.bitk := k;
         s.bitk := k;
         z.avail_in := n;
         z.avail_in := n;
-        Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+        Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
         z.next_in := p;
         z.next_in := p;
         s.write := q;
         s.write := q;
 
 
@@ -115,10 +112,10 @@ begin
         b := s.bitb;
         b := s.bitb;
         k := s.bitk;
         k := s.bitk;
         q := s.write;
         q := s.write;
-        if ptr2int(q) < ptr2int(s.read) then
-          m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+        if ptrint(q) < ptrint(s.read) then
+          m := cardinal(ptrint(s.read)-ptrint(q)-1)
         else
         else
-          m := uInt(ptr2int(s.zend)-ptr2int(q));
+          m := cardinal(ptrint(s.zend)-ptrint(q));
 
 
         if (r <> Z_OK) then
         if (r <> Z_OK) then
         begin
         begin
@@ -149,24 +146,24 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_codes := inflate_flush(s,z,r);
           inflate_codes := inflate_flush(s,z,r);
           exit;
           exit;
         end;
         end;
-        Dec(n);
-        b := b or (uLong(p^) shl k);
+        dec(n);
+        b := b or (cardinal(p^) shl k);
         Inc(p);
         Inc(p);
         Inc(k, 8);
         Inc(k, 8);
       end;
       end;
       t := c^.sub.code.tree;
       t := c^.sub.code.tree;
-      Inc(t, uInt(b) and inflate_mask[j]);
+      Inc(t, cardinal(b) and inflate_mask[j]);
       {DUMPBITS(t^.bits);}
       {DUMPBITS(t^.bits);}
       b := b shr t^.bits;
       b := b shr t^.bits;
-      Dec(k, t^.bits);
+      dec(k, t^.bits);
 
 
-      e := uInt(t^.exop);
+      e := cardinal(t^.exop);
       if (e = 0) then            { literal }
       if (e = 0) then            { literal }
       begin
       begin
         c^.sub.lit := t^.base;
         c^.sub.lit := t^.base;
@@ -207,7 +204,7 @@ begin
       s.bitb := b;
       s.bitb := b;
       s.bitk := k;
       s.bitk := k;
       z.avail_in := n;
       z.avail_in := n;
-      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
       z.next_in := p;
       z.next_in := p;
       s.write := q;
       s.write := q;
       inflate_codes := inflate_flush(s,z,r);
       inflate_codes := inflate_flush(s,z,r);
@@ -228,21 +225,21 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_codes := inflate_flush(s,z,r);
           inflate_codes := inflate_flush(s,z,r);
           exit;
           exit;
         end;
         end;
-        Dec(n);
-        b := b or (uLong(p^) shl k);
+        dec(n);
+        b := b or (cardinal(p^) shl k);
         Inc(p);
         Inc(p);
         Inc(k, 8);
         Inc(k, 8);
       end;
       end;
-      Inc(c^.len, uInt(b and inflate_mask[j]));
+      Inc(c^.len, cardinal(b and inflate_mask[j]));
       {DUMPBITS(j);}
       {DUMPBITS(j);}
       b := b shr j;
       b := b shr j;
-      Dec(k, j);
+      dec(k, j);
 
 
       c^.sub.code.need := c^.dbits;
       c^.sub.code.need := c^.dbits;
       c^.sub.code.tree := c^.dtree;
       c^.sub.code.tree := c^.dtree;
@@ -267,23 +264,23 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_codes := inflate_flush(s,z,r);
           inflate_codes := inflate_flush(s,z,r);
           exit;
           exit;
         end;
         end;
-        Dec(n);
-        b := b or (uLong(p^) shl k);
+        dec(n);
+        b := b or (cardinal(p^) shl k);
         Inc(p);
         Inc(p);
         Inc(k, 8);
         Inc(k, 8);
       end;
       end;
-      t := @huft_ptr(c^.sub.code.tree)^[uInt(b) and inflate_mask[j]];
+      t := @huft_ptr(c^.sub.code.tree)^[cardinal(b) and inflate_mask[j]];
       {DUMPBITS(t^.bits);}
       {DUMPBITS(t^.bits);}
       b := b shr t^.bits;
       b := b shr t^.bits;
-      Dec(k, t^.bits);
+      dec(k, t^.bits);
 
 
-      e := uInt(t^.exop);
+      e := cardinal(t^.exop);
       if (e and 16 <> 0) then            { distance }
       if (e and 16 <> 0) then            { distance }
       begin
       begin
         c^.sub.copy.get := e and 15;
         c^.sub.copy.get := e and 15;
@@ -304,7 +301,7 @@ begin
       s.bitb := b;
       s.bitb := b;
       s.bitk := k;
       s.bitk := k;
       z.avail_in := n;
       z.avail_in := n;
-      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
       z.next_in := p;
       z.next_in := p;
       s.write := q;
       s.write := q;
       inflate_codes := inflate_flush(s,z,r);
       inflate_codes := inflate_flush(s,z,r);
@@ -325,21 +322,21 @@ begin
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_codes := inflate_flush(s,z,r);
           inflate_codes := inflate_flush(s,z,r);
           exit;
           exit;
         end;
         end;
-        Dec(n);
-        b := b or (uLong(p^) shl k);
+        dec(n);
+        b := b or (cardinal(p^) shl k);
         Inc(p);
         Inc(p);
         Inc(k, 8);
         Inc(k, 8);
       end;
       end;
-      Inc(c^.sub.copy.dist, uInt(b) and inflate_mask[j]);
+      Inc(c^.sub.copy.dist, cardinal(b) and inflate_mask[j]);
       {DUMPBITS(j);}
       {DUMPBITS(j);}
       b := b shr j;
       b := b shr j;
-      Dec(k, j);
+      dec(k, j);
       {$IFDEF DEBUG}
       {$IFDEF DEBUG}
       Tracevv('inflate:         distance '+ IntToStr(c^.sub.copy.dist));
       Tracevv('inflate:         distance '+ IntToStr(c^.sub.copy.dist));
       {$ENDIF}
       {$ENDIF}
@@ -349,11 +346,11 @@ begin
   COPY:          { o: copying bytes in window, waiting for space }
   COPY:          { o: copying bytes in window, waiting for space }
     begin
     begin
       f := q;
       f := q;
-      Dec(f, c^.sub.copy.dist);
-      if (uInt(ptr2int(q) - ptr2int(s.window)) < c^.sub.copy.dist) then
+      dec(f, c^.sub.copy.dist);
+      if (cardinal(ptrint(q) - ptrint(s.window)) < c^.sub.copy.dist) then
       begin
       begin
         f := s.zend;
         f := s.zend;
-        Dec(f, c^.sub.copy.dist - uInt(ptr2int(q) - ptr2int(s.window)));
+        dec(f, c^.sub.copy.dist - cardinal(ptrint(q) - ptrint(s.window)));
       end;
       end;
 
 
       while (c^.len <> 0) do
       while (c^.len <> 0) do
@@ -365,10 +362,10 @@ begin
           if (q = s.zend) and (s.read <> s.window) then
           if (q = s.zend) and (s.read <> s.window) then
           begin
           begin
             q := s.window;
             q := s.window;
-            if ptr2int(q) < ptr2int(s.read) then
-              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            if ptrint(q) < ptrint(s.read) then
+              m := cardinal(ptrint(s.read)-ptrint(q)-1)
             else
             else
-              m := uInt(ptr2int(s.zend)-ptr2int(q));
+              m := cardinal(ptrint(s.zend)-ptrint(q));
           end;
           end;
 
 
           if (m = 0) then
           if (m = 0) then
@@ -377,19 +374,19 @@ begin
             s.write := q;
             s.write := q;
             r := inflate_flush(s,z,r);
             r := inflate_flush(s,z,r);
             q := s.write;
             q := s.write;
-            if ptr2int(q) < ptr2int(s.read) then
-              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            if ptrint(q) < ptrint(s.read) then
+              m := cardinal(ptrint(s.read)-ptrint(q)-1)
             else
             else
-              m := uInt(ptr2int(s.zend)-ptr2int(q));
+              m := cardinal(ptrint(s.zend)-ptrint(q));
 
 
             {WRAP}
             {WRAP}
             if (q = s.zend) and (s.read <> s.window) then
             if (q = s.zend) and (s.read <> s.window) then
             begin
             begin
               q := s.window;
               q := s.window;
-              if ptr2int(q) < ptr2int(s.read) then
-                m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+              if ptrint(q) < ptrint(s.read) then
+                m := cardinal(ptrint(s.read)-ptrint(q)-1)
               else
               else
-                m := uInt(ptr2int(s.zend)-ptr2int(q));
+                m := cardinal(ptrint(s.zend)-ptrint(q));
             end;
             end;
 
 
             if (m = 0) then
             if (m = 0) then
@@ -398,7 +395,7 @@ begin
               s.bitb := b;
               s.bitb := b;
               s.bitk := k;
               s.bitk := k;
               z.avail_in := n;
               z.avail_in := n;
-              Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+              Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
               z.next_in := p;
               z.next_in := p;
               s.write := q;
               s.write := q;
               inflate_codes := inflate_flush(s,z,r);
               inflate_codes := inflate_flush(s,z,r);
@@ -412,11 +409,11 @@ begin
         q^ := f^;
         q^ := f^;
         Inc(q);
         Inc(q);
         Inc(f);
         Inc(f);
-        Dec(m);
+        dec(m);
 
 
         if (f = s.zend) then
         if (f = s.zend) then
           f := s.window;
           f := s.window;
-        Dec(c^.len);
+        dec(c^.len);
       end;
       end;
       c^.mode := START;
       c^.mode := START;
       { C-switch break; not needed }
       { C-switch break; not needed }
@@ -430,10 +427,10 @@ begin
         if (q = s.zend) and (s.read <> s.window) then
         if (q = s.zend) and (s.read <> s.window) then
         begin
         begin
           q := s.window;
           q := s.window;
-          if ptr2int(q) < ptr2int(s.read) then
-            m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+          if ptrint(q) < ptrint(s.read) then
+            m := cardinal(ptrint(s.read)-ptrint(q)-1)
           else
           else
-            m := uInt(ptr2int(s.zend)-ptr2int(q));
+            m := cardinal(ptrint(s.zend)-ptrint(q));
         end;
         end;
 
 
         if (m = 0) then
         if (m = 0) then
@@ -442,19 +439,19 @@ begin
           s.write := q;
           s.write := q;
           r := inflate_flush(s,z,r);
           r := inflate_flush(s,z,r);
           q := s.write;
           q := s.write;
-          if ptr2int(q) < ptr2int(s.read) then
-            m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+          if ptrint(q) < ptrint(s.read) then
+            m := cardinal(ptrint(s.read)-ptrint(q)-1)
           else
           else
-            m := uInt(ptr2int(s.zend)-ptr2int(q));
+            m := cardinal(ptrint(s.zend)-ptrint(q));
 
 
           {WRAP}
           {WRAP}
           if (q = s.zend) and (s.read <> s.window) then
           if (q = s.zend) and (s.read <> s.window) then
           begin
           begin
             q := s.window;
             q := s.window;
-            if ptr2int(q) < ptr2int(s.read) then
-              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            if ptrint(q) < ptrint(s.read) then
+              m := cardinal(ptrint(s.read)-ptrint(q)-1)
             else
             else
-              m := uInt(ptr2int(s.zend)-ptr2int(q));
+              m := cardinal(ptrint(s.zend)-ptrint(q));
           end;
           end;
 
 
           if (m = 0) then
           if (m = 0) then
@@ -463,7 +460,7 @@ begin
             s.bitb := b;
             s.bitb := b;
             s.bitk := k;
             s.bitk := k;
             z.avail_in := n;
             z.avail_in := n;
-            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
             z.next_in := p;
             z.next_in := p;
             s.write := q;
             s.write := q;
             inflate_codes := inflate_flush(s,z,r);
             inflate_codes := inflate_flush(s,z,r);
@@ -476,7 +473,7 @@ begin
       {OUTBYTE(c^.sub.lit);}
       {OUTBYTE(c^.sub.lit);}
       q^ := c^.sub.lit;
       q^ := c^.sub.lit;
       Inc(q);
       Inc(q);
-      Dec(m);
+      dec(m);
 
 
       c^.mode := START;
       c^.mode := START;
       {break;}
       {break;}
@@ -489,19 +486,19 @@ begin
         {$IFDEF DEBUG}
         {$IFDEF DEBUG}
         Assert(k < 16, 'inflate_codes grabbed too many bytes');
         Assert(k < 16, 'inflate_codes grabbed too many bytes');
         {$ENDIF}
         {$ENDIF}
-        Dec(k, 8);
+        dec(k, 8);
         Inc(n);
         Inc(n);
-        Dec(p);                    { can always return one }
+        dec(p);                    { can always return one }
       end;
       end;
       {$endif}
       {$endif}
       {FLUSH}
       {FLUSH}
       s.write := q;
       s.write := q;
       r := inflate_flush(s,z,r);
       r := inflate_flush(s,z,r);
       q := s.write;
       q := s.write;
-      if ptr2int(q) < ptr2int(s.read) then
-        m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+      if ptrint(q) < ptrint(s.read) then
+        m := cardinal(ptrint(s.read)-ptrint(q)-1)
       else
       else
-        m := uInt(ptr2int(s.zend)-ptr2int(q));
+        m := cardinal(ptrint(s.zend)-ptrint(q));
 
 
       if (s.read <> s.write) then
       if (s.read <> s.write) then
       begin
       begin
@@ -509,7 +506,7 @@ begin
         s.bitb := b;
         s.bitb := b;
         s.bitk := k;
         s.bitk := k;
         z.avail_in := n;
         z.avail_in := n;
-        Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+        Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
         z.next_in := p;
         z.next_in := p;
         s.write := q;
         s.write := q;
         inflate_codes := inflate_flush(s,z,r);
         inflate_codes := inflate_flush(s,z,r);
@@ -526,7 +523,7 @@ begin
       s.bitb := b;
       s.bitb := b;
       s.bitk := k;
       s.bitk := k;
       z.avail_in := n;
       z.avail_in := n;
-      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
       z.next_in := p;
       z.next_in := p;
       s.write := q;
       s.write := q;
       inflate_codes := inflate_flush(s,z,r);
       inflate_codes := inflate_flush(s,z,r);
@@ -539,7 +536,7 @@ begin
       s.bitb := b;
       s.bitb := b;
       s.bitk := k;
       s.bitk := k;
       z.avail_in := n;
       z.avail_in := n;
-      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
       z.next_in := p;
       z.next_in := p;
       s.write := q;
       s.write := q;
       inflate_codes := inflate_flush(s,z,r);
       inflate_codes := inflate_flush(s,z,r);
@@ -552,7 +549,7 @@ begin
       s.bitb := b;
       s.bitb := b;
       s.bitk := k;
       s.bitk := k;
       z.avail_in := n;
       z.avail_in := n;
-      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      Inc(z.total_in, ptrint(p)-ptrint(z.next_in));
       z.next_in := p;
       z.next_in := p;
       s.write := q;
       s.write := q;
       inflate_codes := inflate_flush(s,z,r);
       inflate_codes := inflate_flush(s,z,r);

+ 80 - 83
packages/base/paszlib/inffast.pas

@@ -16,17 +16,14 @@ interface
 {$I zconf.inc}
 {$I zconf.inc}
 
 
 uses
 uses
-  {$ifdef DEBUG}
-  strutils,
-  {$ENDIF}
   zutil, zbase;
   zutil, zbase;
 
 
-function inflate_fast( bl : uInt;
-                       bd : uInt;
+function inflate_fast( bl : cardinal;
+                       bd : cardinal;
                        tl : pInflate_huft;
                        tl : pInflate_huft;
                        td : pInflate_huft;
                        td : pInflate_huft;
                       var s : inflate_blocks_state;
                       var s : inflate_blocks_state;
-                      var z : z_stream) : int;
+                      var z : z_stream) : integer;
 
 
 
 
 implementation
 implementation
@@ -40,27 +37,27 @@ uses
   at least ten.  The ten bytes are six bytes for the longest length/
   at least ten.  The ten bytes are six bytes for the longest length/
   distance pair plus four bytes for overloading the bit buffer. }
   distance pair plus four bytes for overloading the bit buffer. }
 
 
-function inflate_fast( bl : uInt;
-                       bd : uInt;
+function inflate_fast( bl : cardinal;
+                       bd : cardinal;
                        tl : pInflate_huft;
                        tl : pInflate_huft;
                        td : pInflate_huft;
                        td : pInflate_huft;
                       var s : inflate_blocks_state;
                       var s : inflate_blocks_state;
-                      var z : z_stream) : int;
+                      var z : z_stream) : integer;
 
 
 var
 var
   t : pInflate_huft;      { temporary pointer }
   t : pInflate_huft;      { temporary pointer }
-  e : uInt;               { extra bits or operation }
-  b : uLong;              { bit buffer }
-  k : uInt;               { bits in bit buffer }
-  p : pBytef;             { input data pointer }
-  n : uInt;               { bytes available there }
-  q : pBytef;             { output window write pointer }
-  m : uInt;               { bytes to end of window or read pointer }
-  ml : uInt;              { mask for literal/length tree }
-  md : uInt;              { mask for distance tree }
-  c : uInt;               { bytes to copy }
-  d : uInt;               { distance back to copy from }
-  r : pBytef;             { copy source pointer }
+  e : cardinal;               { extra bits or operation }
+  b : longint;              { bit buffer }
+  k : cardinal;               { bits in bit buffer }
+  p : Pbyte;             { input data pointer }
+  n : cardinal;               { bytes available there }
+  q : Pbyte;             { output window write pointer }
+  m : cardinal;               { bytes to end of window or read pointer }
+  ml : cardinal;              { mask for literal/length tree }
+  md : cardinal;              { mask for distance tree }
+  c : cardinal;               { bytes to copy }
+  d : cardinal;               { distance back to copy from }
+  r : Pbyte;             { copy source pointer }
 begin
 begin
   { load input, output, bit values (macro LOAD) }
   { load input, output, bit values (macro LOAD) }
   p := z.next_in;
   p := z.next_in;
@@ -68,10 +65,10 @@ begin
   b := s.bitb;
   b := s.bitb;
   k := s.bitk;
   k := s.bitk;
   q := s.write;
   q := s.write;
-  if ptr2int(q) < ptr2int(s.read) then
-    m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+  if ptrint(q) < ptrint(s.read) then
+    m := cardinal(ptrint(s.read)-ptrint(q)-1)
   else
   else
-    m := uInt(ptr2int(s.zend)-ptr2int(q));
+    m := cardinal(ptrint(s.zend)-ptrint(q));
 
 
   { initialize masks }
   { initialize masks }
   ml := inflate_mask[bl];
   ml := inflate_mask[bl];
@@ -83,20 +80,20 @@ begin
     {GRABBITS(20);}             { max bits for literal/length code }
     {GRABBITS(20);}             { max bits for literal/length code }
     while (k < 20) do
     while (k < 20) do
     begin
     begin
-      Dec(n);
-      b := b or (uLong(p^) shl k);
-      Inc(p);
-      Inc(k, 8);
+      dec(n);
+      b := b or (longint(p^) shl k);
+      inc(p);
+      inc(k, 8);
     end;
     end;
 
 
-    t := @(huft_ptr(tl)^[uInt(b) and ml]);
+    t := @(huft_ptr(tl)^[cardinal(b) and ml]);
 
 
     e := t^.exop;
     e := t^.exop;
     if (e = 0) then
     if (e = 0) then
     begin
     begin
       {DUMPBITS(t^.bits);}
       {DUMPBITS(t^.bits);}
       b := b shr t^.bits;
       b := b shr t^.bits;
-      Dec(k, t^.bits);
+      dec(k, t^.bits);
      {$IFDEF DEBUG}
      {$IFDEF DEBUG}
       if (t^.base >= $20) and (t^.base < $7f) then
       if (t^.base >= $20) and (t^.base < $7f) then
         Tracevv('inflate:         * literal '+char(t^.base))
         Tracevv('inflate:         * literal '+char(t^.base))
@@ -104,23 +101,23 @@ begin
         Tracevv('inflate:         * literal '+ IntToStr(t^.base));
         Tracevv('inflate:         * literal '+ IntToStr(t^.base));
       {$ENDIF}
       {$ENDIF}
       q^ := Byte(t^.base);
       q^ := Byte(t^.base);
-      Inc(q);
-      Dec(m);
+      inc(q);
+      dec(m);
       continue;
       continue;
     end;
     end;
     repeat
     repeat
       {DUMPBITS(t^.bits);}
       {DUMPBITS(t^.bits);}
       b := b shr t^.bits;
       b := b shr t^.bits;
-      Dec(k, t^.bits);
+      dec(k, t^.bits);
 
 
       if (e and 16 <> 0) then
       if (e and 16 <> 0) then
       begin
       begin
         { get extra bits for length }
         { get extra bits for length }
         e := e and 15;
         e := e and 15;
-        c := t^.base + (uInt(b) and inflate_mask[e]);
+        c := t^.base + (cardinal(b) and inflate_mask[e]);
         {DUMPBITS(e);}
         {DUMPBITS(e);}
         b := b shr e;
         b := b shr e;
-        Dec(k, e);
+        dec(k, e);
         {$IFDEF DEBUG}
         {$IFDEF DEBUG}
         Tracevv('inflate:         * length ' + IntToStr(c));
         Tracevv('inflate:         * length ' + IntToStr(c));
         {$ENDIF}
         {$ENDIF}
@@ -128,18 +125,18 @@ begin
         {GRABBITS(15);}           { max bits for distance code }
         {GRABBITS(15);}           { max bits for distance code }
         while (k < 15) do
         while (k < 15) do
         begin
         begin
-          Dec(n);
-          b := b or (uLong(p^) shl k);
-          Inc(p);
-          Inc(k, 8);
+          dec(n);
+          b := b or (longint(p^) shl k);
+          inc(p);
+          inc(k, 8);
         end;
         end;
 
 
-        t := @huft_ptr(td)^[uInt(b) and md];
+        t := @huft_ptr(td)^[cardinal(b) and md];
         e := t^.exop;
         e := t^.exop;
         repeat
         repeat
           {DUMPBITS(t^.bits);}
           {DUMPBITS(t^.bits);}
           b := b shr t^.bits;
           b := b shr t^.bits;
-          Dec(k, t^.bits);
+          dec(k, t^.bits);
 
 
           if (e and 16 <> 0) then
           if (e and 16 <> 0) then
           begin
           begin
@@ -148,58 +145,58 @@ begin
             {GRABBITS(e);}         { get extra bits (up to 13) }
             {GRABBITS(e);}         { get extra bits (up to 13) }
             while (k < e) do
             while (k < e) do
             begin
             begin
-              Dec(n);
-              b := b or (uLong(p^) shl k);
-              Inc(p);
-              Inc(k, 8);
+              dec(n);
+              b := b or (longint(p^) shl k);
+              inc(p);
+              inc(k, 8);
             end;
             end;
 
 
-            d := t^.base + (uInt(b) and inflate_mask[e]);
+            d := t^.base + (cardinal(b) and inflate_mask[e]);
             {DUMPBITS(e);}
             {DUMPBITS(e);}
             b := b shr e;
             b := b shr e;
-            Dec(k, e);
+            dec(k, e);
 
 
             {$IFDEF DEBUG}
             {$IFDEF DEBUG}
             Tracevv('inflate:         * distance '+IntToStr(d));
             Tracevv('inflate:         * distance '+IntToStr(d));
             {$ENDIF}
             {$ENDIF}
             { do the copy }
             { do the copy }
-            Dec(m, c);
-            if (uInt(ptr2int(q) - ptr2int(s.window)) >= d) then     { offset before dest }
+            dec(m, c);
+            if (cardinal(ptrint(q) - ptrint(s.window)) >= d) then     { offset before dest }
             begin                                  {  just copy }
             begin                                  {  just copy }
               r := q;
               r := q;
-              Dec(r, d);
-              q^ := r^;  Inc(q); Inc(r); Dec(c); { minimum count is three, }
-              q^ := r^;  Inc(q); Inc(r); Dec(c); { so unroll loop a little }
+              dec(r, d);
+              q^ := r^;  inc(q); inc(r); dec(c); { minimum count is three, }
+              q^ := r^;  inc(q); inc(r); dec(c); { so unroll loop a little }
             end
             end
             else                        { else offset after destination }
             else                        { else offset after destination }
             begin
             begin
-              e := d - uInt(ptr2int(q) - ptr2int(s.window)); { bytes from offset to end }
+              e := d - cardinal(ptrint(q) - ptrint(s.window)); { bytes from offset to end }
               r := s.zend;
               r := s.zend;
-              Dec(r, e);                  { pointer to offset }
+              dec(r, e);                  { pointer to offset }
               if (c > e) then             { if source crosses, }
               if (c > e) then             { if source crosses, }
               begin
               begin
-                Dec(c, e);                { copy to end of window }
+                dec(c, e);                { copy to end of window }
                 repeat
                 repeat
                   q^ := r^;
                   q^ := r^;
-                  Inc(q);
-                  Inc(r);
-                  Dec(e);
+                  inc(q);
+                  inc(r);
+                  dec(e);
                 until (e=0);
                 until (e=0);
                 r := s.window;           { copy rest from start of window }
                 r := s.window;           { copy rest from start of window }
               end;
               end;
             end;
             end;
             repeat                       { copy all or what's left }
             repeat                       { copy all or what's left }
               q^ := r^;
               q^ := r^;
-              Inc(q);
-              Inc(r);
-              Dec(c);
+              inc(q);
+              inc(r);
+              dec(c);
             until (c = 0);
             until (c = 0);
             break;
             break;
           end
           end
           else
           else
             if (e and 64 = 0) then
             if (e and 64 = 0) then
             begin
             begin
-              Inc(t, t^.base + (uInt(b) and inflate_mask[e]));
+              inc(t, t^.base + (cardinal(b) and inflate_mask[e]));
               e := t^.exop;
               e := t^.exop;
             end
             end
           else
           else
@@ -209,14 +206,14 @@ begin
             c := z.avail_in-n;
             c := z.avail_in-n;
             if (k shr 3) < c then
             if (k shr 3) < c then
               c := k shr 3;
               c := k shr 3;
-            Inc(n, c);
-            Dec(p, c);
-            Dec(k, c shl 3);
+            inc(n, c);
+            dec(p, c);
+            dec(k, c shl 3);
             {UPDATE}
             {UPDATE}
             s.bitb := b;
             s.bitb := b;
             s.bitk := k;
             s.bitk := k;
             z.avail_in := n;
             z.avail_in := n;
-            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            inc(z.total_in, ptrint(p)-ptrint(z.next_in));
             z.next_in := p;
             z.next_in := p;
             s.write := q;
             s.write := q;
 
 
@@ -229,15 +226,15 @@ begin
       if (e and 64 = 0) then
       if (e and 64 = 0) then
       begin
       begin
          {t += t->base;
          {t += t->base;
-          e = (t += ((uInt)b & inflate_mask[e]))->exop;}
+          e = (t += ((cardinal)b & inflate_mask[e]))->exop;}
 
 
-        Inc(t, t^.base + (uInt(b) and inflate_mask[e]));
+        inc(t, t^.base + (cardinal(b) and inflate_mask[e]));
         e := t^.exop;
         e := t^.exop;
         if (e = 0) then
         if (e = 0) then
         begin
         begin
           {DUMPBITS(t^.bits);}
           {DUMPBITS(t^.bits);}
           b := b shr t^.bits;
           b := b shr t^.bits;
-          Dec(k, t^.bits);
+          dec(k, t^.bits);
 
 
          {$IFDEF DEBUG}
          {$IFDEF DEBUG}
           if (t^.base >= $20) and (t^.base < $7f) then
           if (t^.base >= $20) and (t^.base < $7f) then
@@ -246,8 +243,8 @@ begin
             Tracevv('inflate:         * literal '+IntToStr(t^.base));
             Tracevv('inflate:         * literal '+IntToStr(t^.base));
           {$ENDIF}            
           {$ENDIF}            
           q^ := Byte(t^.base);
           q^ := Byte(t^.base);
-          Inc(q);
-          Dec(m);
+          inc(q);
+          dec(m);
           break;
           break;
         end;
         end;
       end
       end
@@ -261,14 +258,14 @@ begin
           c := z.avail_in-n;
           c := z.avail_in-n;
           if (k shr 3) < c then
           if (k shr 3) < c then
             c := k shr 3;
             c := k shr 3;
-          Inc(n, c);
-          Dec(p, c);
-          Dec(k, c shl 3);
+          inc(n, c);
+          dec(p, c);
+          dec(k, c shl 3);
           {UPDATE}
           {UPDATE}
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          inc(z.total_in, ptrint(p)-ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_fast := Z_STREAM_END;
           inflate_fast := Z_STREAM_END;
@@ -281,14 +278,14 @@ begin
           c := z.avail_in-n;
           c := z.avail_in-n;
           if (k shr 3) < c then
           if (k shr 3) < c then
             c := k shr 3;
             c := k shr 3;
-          Inc(n, c);
-          Dec(p, c);
-          Dec(k, c shl 3);
+          inc(n, c);
+          dec(p, c);
+          dec(k, c shl 3);
           {UPDATE}
           {UPDATE}
           s.bitb := b;
           s.bitb := b;
           s.bitk := k;
           s.bitk := k;
           z.avail_in := n;
           z.avail_in := n;
-          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          inc(z.total_in, ptrint(p)-ptrint(z.next_in));
           z.next_in := p;
           z.next_in := p;
           s.write := q;
           s.write := q;
           inflate_fast := Z_DATA_ERROR;
           inflate_fast := Z_DATA_ERROR;
@@ -302,14 +299,14 @@ begin
   c := z.avail_in-n;
   c := z.avail_in-n;
   if (k shr 3) < c then
   if (k shr 3) < c then
     c := k shr 3;
     c := k shr 3;
-  Inc(n, c);
-  Dec(p, c);
-  Dec(k, c shl 3);
+  inc(n, c);
+  dec(p, c);
+  dec(k, c shl 3);
   {UPDATE}
   {UPDATE}
   s.bitb := b;
   s.bitb := b;
   s.bitk := k;
   s.bitk := k;
   z.avail_in := n;
   z.avail_in := n;
-  Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+  inc(z.total_in, ptrint(p)-ptrint(z.next_in));
   z.next_in := p;
   z.next_in := p;
   s.write := q;
   s.write := q;
   inflate_fast := Z_OK;
   inflate_fast := Z_OK;

+ 91 - 91
packages/base/paszlib/inftrees.pas

@@ -1,4 +1,4 @@
-Unit InfTrees;
+unit inftrees;
 
 
 { inftrees.h -- header to use inftrees.c
 { inftrees.h -- header to use inftrees.c
   inftrees.c -- generate Huffman trees for efficient decoding
   inftrees.c -- generate Huffman trees for efficient decoding
@@ -13,7 +13,7 @@ Unit InfTrees;
   For conditions of distribution and use, see copyright notice in readme.txt
   For conditions of distribution and use, see copyright notice in readme.txt
 }
 }
 
 
-Interface
+interface
 
 
 {$I zconf.inc}
 {$I zconf.inc}
 
 
@@ -32,36 +32,36 @@ const
 
 
 {$ifdef DEBUG}
 {$ifdef DEBUG}
 var
 var
-  inflate_hufts : uInt;
+  inflate_hufts : cardinal;
 {$endif}
 {$endif}
 
 
 function inflate_trees_bits(
 function inflate_trees_bits(
-  var c : array of uIntf;  { 19 code lengths }
-  var bb : uIntf;          { bits tree desired/actual depth }
+  var c : array of cardinal;  { 19 code lengths }
+  var bb : cardinal;          { bits tree desired/actual depth }
   var tb : pinflate_huft;  { bits tree result }
   var tb : pinflate_huft;  { bits tree result }
   var hp : array of Inflate_huft;      { space for trees }
   var hp : array of Inflate_huft;      { space for trees }
   var z : z_stream         { for messages }
   var z : z_stream         { for messages }
-    ) : int;
+    ) : integer;
 
 
 function inflate_trees_dynamic(
 function inflate_trees_dynamic(
-    nl : uInt;                    { number of literal/length codes }
-    nd : uInt;                    { number of distance codes }
-    var c : Array of uIntf;           { that many (total) code lengths }
-    var bl : uIntf;               { literal desired/actual bit depth }
-    var bd : uIntf;               { distance desired/actual bit depth }
+    nl : cardinal;                    { number of literal/length codes }
+    nd : cardinal;                    { number of distance codes }
+    var c : Array of cardinal;           { that many (total) code lengths }
+    var bl : cardinal;               { literal desired/actual bit depth }
+    var bd : cardinal;               { distance desired/actual bit depth }
 var tl : pInflate_huft;           { literal/length tree result }
 var tl : pInflate_huft;           { literal/length tree result }
 var td : pInflate_huft;           { distance tree result }
 var td : pInflate_huft;           { distance tree result }
 var hp : array of Inflate_huft;   { space for trees }
 var hp : array of Inflate_huft;   { space for trees }
 var z : z_stream                  { for messages }
 var z : z_stream                  { for messages }
-     ) : int;
+     ) : integer;
 
 
 function inflate_trees_fixed (
 function inflate_trees_fixed (
-    var bl : uInt;                { literal desired/actual bit depth }
-    var bd : uInt;                { distance desired/actual bit depth }
+    var bl : cardinal;                { literal desired/actual bit depth }
+    var bd : cardinal;                { distance desired/actual bit depth }
     var tl : pInflate_huft;       { literal/length tree result }
     var tl : pInflate_huft;       { literal/length tree result }
     var td : pInflate_huft;       { distance tree result }
     var td : pInflate_huft;       { distance tree result }
     var z : z_stream              { for memory allocation }
     var z : z_stream              { for memory allocation }
-     ) : int;
+     ) : integer;
 
 
 
 
 implementation
 implementation
@@ -79,23 +79,23 @@ const
 
 
 const
 const
 { Tables for deflate from PKZIP's appnote.txt. }
 { Tables for deflate from PKZIP's appnote.txt. }
-  cplens : Array [0..30] Of uInt  { Copy lengths for literal codes 257..285 }
+  cplens : Array [0..30] Of cardinal  { Copy lengths for literal codes 257..285 }
      = (3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
      = (3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0);
         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0);
         { actually lengths - 2; also see note #13 above about 258 }
         { actually lengths - 2; also see note #13 above about 258 }
 
 
   invalid_code = 112;
   invalid_code = 112;
 
 
-  cplext : Array [0..30] Of uInt  { Extra bits for literal codes 257..285 }
+  cplext : Array [0..30] Of cardinal  { Extra bits for literal codes 257..285 }
      = (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
      = (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
         3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, invalid_code, invalid_code);
         3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, invalid_code, invalid_code);
 
 
-  cpdist : Array [0..29] Of uInt { Copy offsets for distance codes 0..29 }
+  cpdist : Array [0..29] Of cardinal { Copy offsets for distance codes 0..29 }
      = (1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
      = (1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
         8193, 12289, 16385, 24577);
         8193, 12289, 16385, 24577);
 
 
-  cpdext : Array [0..29] Of uInt { Extra bits for distance codes }
+  cpdext : Array [0..29] Of cardinal { Extra bits for distance codes }
      = (0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
      = (0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
         7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
         7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
         12, 12, 13, 13);
         12, 12, 13, 13);
@@ -138,48 +138,48 @@ const
 {$DEFINE USE_PTR}
 {$DEFINE USE_PTR}
 
 
 function huft_build(
 function huft_build(
-var b : array of uIntf;    { code lengths in bits (all assumed <= BMAX) }
-    n : uInt;              { number of codes (assumed <= N_MAX) }
-    s : uInt;              { number of simple-valued codes (0..s-1) }
-const d : array of uIntf;  { list of base values for non-simple codes }
+var b : array of cardinal;    { code lengths in bits (all assumed <= BMAX) }
+    n : cardinal;              { number of codes (assumed <= N_MAX) }
+    s : cardinal;              { number of simple-valued codes (0..s-1) }
+const d : array of cardinal;  { list of base values for non-simple codes }
 { array of word }
 { array of word }
-const e : array of uIntf;  { list of extra bits for non-simple codes }
+const e : array of cardinal;  { list of extra bits for non-simple codes }
 { array of byte }
 { array of byte }
   t : ppInflate_huft;     { result: starting table }
   t : ppInflate_huft;     { result: starting table }
-var m : uIntf;             { maximum lookup bits, returns actual }
+var m : cardinal;             { maximum lookup bits, returns actual }
 var hp : array of inflate_huft;  { space for trees }
 var hp : array of inflate_huft;  { space for trees }
-var hn : uInt;             { hufts used in space }
-var v : array of uIntf     { working area: values in order of bit length }
-   ) : int;
+var hn : cardinal;             { hufts used in space }
+var v : array of cardinal     { working area: values in order of bit length }
+   ) : integer;
 { Given a list of code lengths and a maximum table size, make a set of
 { Given a list of code lengths and a maximum table size, make a set of
   tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR
   tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR
   if the given code set is incomplete (the tables are still built in this
   if the given code set is incomplete (the tables are still built in this
   case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
   case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
   lengths), or Z_MEM_ERROR if not enough memory. }
   lengths), or Z_MEM_ERROR if not enough memory. }
 Var
 Var
-  a : uInt;                     { counter for codes of length k }
-  c : Array [0..BMAX] Of uInt;  { bit length count table }
-  f : uInt;                     { i repeats in table every f entries }
-  g : int;                      { maximum code length }
-  h : int;                      { table level }
-  i : uInt;  {register}         { counter, current code }
-  j : uInt;  {register}         { counter }
-  k : Int;   {register}         { number of bits in current code }
-  l : int;			{ bits per table (returned in m) }
-  mask : uInt;                  { (1 shl w) - 1, to avoid cc -O bug on HP }
-  p : ^uIntf; {register}        { pointer into c[], b[], or v[] }
+  a : cardinal;                     { counter for codes of length k }
+  c : Array [0..BMAX] Of cardinal;  { bit length count table }
+  f : cardinal;                     { i repeats in table every f entries }
+  g : integer;                      { maximum code length }
+  h : integer;                      { table level }
+  i : cardinal;  {register}         { counter, current code }
+  j : cardinal;  {register}         { counter }
+  k : integer;   {register}         { number of bits in current code }
+  l : integer;			{ bits per table (returned in m) }
+  mask : cardinal;                  { (1 shl w) - 1, to avoid cc -O bug on HP }
+  p : ^cardinal; {register}        { pointer into c[], b[], or v[] }
   q : pInflate_huft;            { points to current table }
   q : pInflate_huft;            { points to current table }
   r : inflate_huft;             { table entry for structure assignment }
   r : inflate_huft;             { table entry for structure assignment }
   u : Array [0..BMAX-1] Of pInflate_huft; { table stack }
   u : Array [0..BMAX-1] Of pInflate_huft; { table stack }
-  w : int;   {register}         { bits before this table = (l*h) }
-  x : Array [0..BMAX] Of uInt;  { bit offsets, then code stack }
+  w : integer;   {register}         { bits before this table = (l*h) }
+  x : Array [0..BMAX] Of cardinal;  { bit offsets, then code stack }
   {$IFDEF USE_PTR}
   {$IFDEF USE_PTR}
-  xp : puIntf;                  { pointer into x }
+  xp : Pcardinal;                  { pointer into x }
   {$ELSE}
   {$ELSE}
-  xp : uInt;
+  xp : cardinal;
   {$ENDIF}
   {$ENDIF}
-  y : int;                      { number of dummy codes added }
-  z : uInt;                     { number of entries in current table }
+  y : integer;                      { number of dummy codes added }
+  z : cardinal;                     { number of entries in current table }
 Begin
 Begin
   { Generate counts for each bit length }
   { Generate counts for each bit length }
   FillChar(c,SizeOf(c),0) ;     { clear c[] }
   FillChar(c,SizeOf(c),0) ;     { clear c[] }
@@ -201,13 +201,13 @@ Begin
     if (c[j] <> 0) then
     if (c[j] <> 0) then
       break;
       break;
   k := j ;                      { minimum code length }
   k := j ;                      { minimum code length }
-  if (uInt(l) < j) then
+  if (cardinal(l) < j) then
     l := j;
     l := j;
   for i := BMAX downto 1 do
   for i := BMAX downto 1 do
     if (c[i] <> 0) then
     if (c[i] <> 0) then
       break ;
       break ;
   g := i ;                      { maximum code length }
   g := i ;                      { maximum code length }
-  if (uInt(l) > i) then
+  if (cardinal(l) > i) then
      l := i;
      l := i;
   m := l;
   m := l;
 
 
@@ -301,7 +301,7 @@ Begin
 
 
         { table size upper limit }
         { table size upper limit }
         z := g - w;
         z := g - w;
-        If (z > uInt(l)) Then
+        If (z > cardinal(l)) Then
           z := l;
           z := l;
 
 
         { try a k-w bit table }
         { try a k-w bit table }
@@ -362,11 +362,11 @@ Begin
         if (h <> 0) then
         if (h <> 0) then
         begin
         begin
           x[h] := i;             { save pattern for backing up }
           x[h] := i;             { save pattern for backing up }
-          r.bits := Byte(l);     { bits to dump before this table }
-          r.exop := Byte(j);     { bits in this table }
+          r.bits := byte(l);     { bits to dump before this table }
+          r.exop := byte(j);     { bits in this table }
           j := i shr (w - l);
           j := i shr (w - l);
-          {r.base := uInt( q - u[h-1] -j);}   { offset to this table }
-          r.base := (ptr2int(q) - ptr2int(u[h-1]) ) div sizeof(q^) - j;
+          {r.base := cardinal( q - u[h-1] -j);}   { offset to this table }
+          r.base := (ptrint(q) - ptrint(u[h-1]) ) div sizeof(q^) - j;
           huft_Ptr(u[h-1])^[j] := r;  { connect to last table }
           huft_Ptr(u[h-1])^[j] := r;  { connect to last table }
         end
         end
         else
         else
@@ -374,11 +374,11 @@ Begin
       end;
       end;
 
 
       { set up table entry in r }
       { set up table entry in r }
-      r.bits := Byte(k - w);
+      r.bits := byte(k - w);
 
 
       { C-code: if (p >= v + n) - see ZUTIL.PAS for comments }
       { C-code: if (p >= v + n) - see ZUTIL.PAS for comments }
 
 
-      if ptr2int(p)>=ptr2int(@(v[n])) then  { also works under DPMI ?? }
+      if ptrint(p)>=ptrint(@(v[n])) then  { also works under DPMI ?? }
         r.exop := 128 + 64                  { out of values--invalid code }
         r.exop := 128 + 64                  { out of values--invalid code }
       else
       else
         if (p^ < s) then
         if (p^ < s) then
@@ -392,7 +392,7 @@ Begin
         end
         end
         Else
         Else
         begin
         begin
-          r.exop := Byte(e[p^-s] + 16 + 64);  { non-simple--look up in lists }
+          r.exop := byte(e[p^-s] + 16 + 64);  { non-simple--look up in lists }
           r.base := d[p^-s];
           r.base := d[p^-s];
           Inc (p);
           Inc (p);
         end ;
         end ;
@@ -438,27 +438,27 @@ end; { huft_build}
 
 
 
 
 function inflate_trees_bits(
 function inflate_trees_bits(
-  var c : array of uIntf;  { 19 code lengths }
-  var bb : uIntf;          { bits tree desired/actual depth }
+  var c : array of cardinal;  { 19 code lengths }
+  var bb : cardinal;          { bits tree desired/actual depth }
   var tb : pinflate_huft;  { bits tree result }
   var tb : pinflate_huft;  { bits tree result }
   var hp : array of Inflate_huft;      { space for trees }
   var hp : array of Inflate_huft;      { space for trees }
   var z : z_stream         { for messages }
   var z : z_stream         { for messages }
-    ) : int;
+    ) : integer;
 var
 var
-  r : int;
-  hn : uInt;          { hufts used in space }
+  r : integer;
+  hn : cardinal;          { hufts used in space }
   v : PuIntArray;     { work area for huft_build }
   v : PuIntArray;     { work area for huft_build }
 begin
 begin
   hn := 0;
   hn := 0;
-  v := PuIntArray( ZALLOC(z, 19, sizeof(uInt)) );
-  if (v = Z_NULL) then
+  v := PuIntArray( ZALLOC(z, 19, sizeof(cardinal)) );
+  if (v = nil) then
   begin
   begin
     inflate_trees_bits := Z_MEM_ERROR;
     inflate_trees_bits := Z_MEM_ERROR;
     exit;
     exit;
   end;
   end;
 
 
   r := huft_build(c, 19, 19, cplens, cplext,
   r := huft_build(c, 19, 19, cplens, cplext,
-                             {puIntf(Z_NULL), puIntf(Z_NULL),}
+                             {Pcardinal(nil), Pcardinal(nil),}
                   @tb, bb, hp, hn, v^);
                   @tb, bb, hp, hn, v^);
   if (r = Z_DATA_ERROR) then
   if (r = Z_DATA_ERROR) then
     z.msg := 'oversubscribed dynamic bit lengths tree'
     z.msg := 'oversubscribed dynamic bit lengths tree'
@@ -474,25 +474,25 @@ end;
 
 
 
 
 function inflate_trees_dynamic(
 function inflate_trees_dynamic(
-    nl : uInt;                    { number of literal/length codes }
-    nd : uInt;                    { number of distance codes }
-    var c : Array of uIntf;           { that many (total) code lengths }
-    var bl : uIntf;          { literal desired/actual bit depth }
-    var bd : uIntf;          { distance desired/actual bit depth }
+    nl : cardinal;                    { number of literal/length codes }
+    nd : cardinal;                    { number of distance codes }
+    var c : Array of cardinal;           { that many (total) code lengths }
+    var bl : cardinal;          { literal desired/actual bit depth }
+    var bd : cardinal;          { distance desired/actual bit depth }
 var tl : pInflate_huft;           { literal/length tree result }
 var tl : pInflate_huft;           { literal/length tree result }
 var td : pInflate_huft;           { distance tree result }
 var td : pInflate_huft;           { distance tree result }
 var hp : array of Inflate_huft;   { space for trees }
 var hp : array of Inflate_huft;   { space for trees }
 var z : z_stream                  { for messages }
 var z : z_stream                  { for messages }
-     ) : int;
+     ) : integer;
 var
 var
-  r : int;
-  hn : uInt;          { hufts used in space }
+  r : integer;
+  hn : cardinal;          { hufts used in space }
   v : PuIntArray;     { work area for huft_build }
   v : PuIntArray;     { work area for huft_build }
 begin
 begin
   hn := 0;
   hn := 0;
   { allocate work area }
   { allocate work area }
-  v := PuIntArray( ZALLOC(z, 288, sizeof(uInt)) );
-  if (v = Z_NULL) then
+  v := PuIntArray( ZALLOC(z, 288, sizeof(cardinal)) );
+  if (v = nil) then
   begin
   begin
     inflate_trees_dynamic := Z_MEM_ERROR;
     inflate_trees_dynamic := Z_MEM_ERROR;
     exit;
     exit;
@@ -560,8 +560,8 @@ const
   FIXEDH = 544;      { number of hufts used by fixed tables }
   FIXEDH = 544;      { number of hufts used by fixed tables }
 var
 var
   fixed_mem : array[0..FIXEDH-1] of inflate_huft;
   fixed_mem : array[0..FIXEDH-1] of inflate_huft;
-  fixed_bl : uInt;
-  fixed_bd : uInt;
+  fixed_bl : cardinal;
+  fixed_bd : cardinal;
   fixed_tl : pInflate_huft;
   fixed_tl : pInflate_huft;
   fixed_td : pInflate_huft;
   fixed_td : pInflate_huft;
 
 
@@ -571,18 +571,18 @@ var
 
 
 {local}
 {local}
 const
 const
-  fixed_bl = uInt(9);
+  fixed_bl = 9;
 {local}
 {local}
 const
 const
-  fixed_bd = uInt(5);
+  fixed_bd = 5;
 {local}
 {local}
 const
 const
   fixed_tl : array [0..288-1] of inflate_huft = (
   fixed_tl : array [0..288-1] of inflate_huft = (
     Exop,             { number of extra bits or operation }
     Exop,             { number of extra bits or operation }
-    bits : Byte;      { number of bits in this code or subcode }
-    {pad : uInt;}       { pad structure to a power of 2 (4 bytes for }
-                      {  16-bit, 8 bytes for 32-bit int's) }
-    base : uInt;      { literal, length base, or distance base }
+    bits : byte;      { number of bits in this code or subcode }
+    {pad : cardinal;}       { pad structure to a power of 2 (4 bytes for }
+                      {  16-bit, 8 bytes for 32-bit integer's) }
+    base : cardinal;      { literal, length base, or distance base }
                       { or table offset }
                       { or table offset }
 
 
     ((96,7),256), ((0,8),80), ((0,8),16), ((84,8),115), ((82,7),31),
     ((96,7),256), ((0,8),80), ((0,8),16), ((84,8),115), ((82,7),31),
@@ -708,21 +708,21 @@ const
 {$ENDIF}
 {$ENDIF}
 
 
 function inflate_trees_fixed(
 function inflate_trees_fixed(
-var bl : uInt;               { literal desired/actual bit depth }
-var bd : uInt;               { distance desired/actual bit depth }
+var bl : cardinal;               { literal desired/actual bit depth }
+var bd : cardinal;               { distance desired/actual bit depth }
 var tl : pInflate_huft;      { literal/length tree result }
 var tl : pInflate_huft;      { literal/length tree result }
 var td : pInflate_huft;      { distance tree result }
 var td : pInflate_huft;      { distance tree result }
 var  z : z_stream            { for memory allocation }
 var  z : z_stream            { for memory allocation }
-      ) : int;
+      ) : integer;
 type
 type
   pFixed_table = ^fixed_table;
   pFixed_table = ^fixed_table;
-  fixed_table = array[0..288-1] of uIntf;
+  fixed_table = array[0..288-1] of cardinal;
 var
 var
-  k : int;                   { temporary variable }
+  k : integer;                   { temporary variable }
   c : pFixed_table;          { length list for huft_build }
   c : pFixed_table;          { length list for huft_build }
   v : PuIntArray;            { work area for huft_build }
   v : PuIntArray;            { work area for huft_build }
 var
 var
-  f : uInt;                  { number of hufts used in fixed_mem }
+  f : cardinal;                  { number of hufts used in fixed_mem }
 begin
 begin
   { build fixed tables if not already (multiple overlapped executions ok) }
   { build fixed tables if not already (multiple overlapped executions ok) }
   if not fixed_built then
   if not fixed_built then
@@ -730,14 +730,14 @@ begin
     f := 0;
     f := 0;
 
 
     { allocate memory }
     { allocate memory }
-    c := pFixed_table( ZALLOC(z, 288, sizeof(uInt)) );
-    if (c = Z_NULL) then
+    c := pFixed_table( ZALLOC(z, 288, sizeof(cardinal)) );
+    if (c = nil) then
     begin
     begin
       inflate_trees_fixed := Z_MEM_ERROR;
       inflate_trees_fixed := Z_MEM_ERROR;
       exit;
       exit;
     end;
     end;
-    v := PuIntArray( ZALLOC(z, 288, sizeof(uInt)) );
-    if (v = Z_NULL) then
+    v := PuIntArray( ZALLOC(z, 288, sizeof(cardinal)) );
+    if (v = nil) then
     begin
     begin
       ZFREE(z, c);
       ZFREE(z, c);
       inflate_trees_fixed := Z_MEM_ERROR;
       inflate_trees_fixed := Z_MEM_ERROR;

+ 40 - 40
packages/base/paszlib/infutil.pas

@@ -22,41 +22,41 @@ uses
 { copy as much as possible from the sliding window to the output area }
 { copy as much as possible from the sliding window to the output area }
 function inflate_flush(var s : inflate_blocks_state;
 function inflate_flush(var s : inflate_blocks_state;
                        var z : z_stream;
                        var z : z_stream;
-                       r : int) : int;
+                       r : integer) : integer;
 
 
 { And'ing with mask[n] masks the lower n bits }
 { And'ing with mask[n] masks the lower n bits }
 const
 const
-  inflate_mask : array[0..17-1] of uInt = (
+  inflate_mask : array[0..17-1] of cardinal = (
     $0000,
     $0000,
     $0001, $0003, $0007, $000f, $001f, $003f, $007f, $00ff,
     $0001, $0003, $0007, $000f, $001f, $003f, $007f, $00ff,
     $01ff, $03ff, $07ff, $0fff, $1fff, $3fff, $7fff, $ffff);
     $01ff, $03ff, $07ff, $0fff, $1fff, $3fff, $7fff, $ffff);
 
 
-{procedure GRABBITS(j : int);}
-{procedure DUMPBITS(j : int);}
-{procedure NEEDBITS(j : int);}
+{procedure GRABBITS(j : integer);}
+{procedure DUMPBITS(j : integer);}
+{procedure NEEDBITS(j : integer);}
 
 
 implementation
 implementation
 
 
 { macros for bit input with no checking and for returning unused bytes }
 { macros for bit input with no checking and for returning unused bytes }
-procedure GRABBITS(j : int);
+procedure GRABBITS(j : integer);
 begin
 begin
   {while (k < j) do
   {while (k < j) do
   begin
   begin
-    Dec(z^.avail_in);
-    Inc(z^.total_in);
+    dec(z^.avail_in);
+    inc(z^.total_in);
     b := b or (uLong(z^.next_in^) shl k);
     b := b or (uLong(z^.next_in^) shl k);
-    Inc(z^.next_in);
-    Inc(k, 8);
+    inc(z^.next_in);
+    inc(k, 8);
   end;}
   end;}
 end;
 end;
 
 
-procedure DUMPBITS(j : int);
+procedure DUMPBITS(j : integer);
 begin
 begin
   {b := b shr j;
   {b := b shr j;
-  Dec(k, j);}
+  dec(k, j);}
 end;
 end;
 
 
-procedure NEEDBITS(j : int);
+procedure NEEDBITS(j : integer);
 begin
 begin
  (*
  (*
           while (k < j) do
           while (k < j) do
@@ -70,16 +70,16 @@ begin
               s.bitb := b;
               s.bitb := b;
               s.bitk := k;
               s.bitk := k;
               z.avail_in := n;
               z.avail_in := n;
-              Inc(z.total_in, LongInt(p)-LongInt(z.next_in));
+              inc(z.total_in, LongInt(p)-LongInt(z.next_in));
               z.next_in := p;
               z.next_in := p;
               s.write := q;
               s.write := q;
               result := inflate_flush(s,z,r);
               result := inflate_flush(s,z,r);
               exit;
               exit;
             end;
             end;
-            Dec(n);
+            dec(n);
             b := b or (uLong(p^) shl k);
             b := b or (uLong(p^) shl k);
-            Inc(p);
-            Inc(k, 8);
+            inc(p);
+            inc(k, 8);
           end;
           end;
  *)
  *)
 end;
 end;
@@ -94,9 +94,9 @@ begin
     begin
     begin
       q := s.window;
       q := s.window;
       if LongInt(q) < LongInt(s.read) then
       if LongInt(q) < LongInt(s.read) then
-        m := uInt(LongInt(s.read)-LongInt(q)-1)
+        m := cardinal(LongInt(s.read)-LongInt(q)-1)
       else
       else
-        m := uInt(LongInt(s.zend)-LongInt(q));
+        m := cardinal(LongInt(s.zend)-LongInt(q));
     end;
     end;
 
 
     if (m = 0) then
     if (m = 0) then
@@ -106,18 +106,18 @@ begin
       r := inflate_flush(s,z,r);
       r := inflate_flush(s,z,r);
       q := s.write;
       q := s.write;
       if LongInt(q) < LongInt(s.read) then
       if LongInt(q) < LongInt(s.read) then
-        m := uInt(LongInt(s.read)-LongInt(q)-1)
+        m := cardinal(LongInt(s.read)-LongInt(q)-1)
       else
       else
-        m := uInt(LongInt(s.zend)-LongInt(q));
+        m := cardinal(LongInt(s.zend)-LongInt(q));
 
 
       {WRAP}
       {WRAP}
       if (q = s.zend) and (s.read <> s.window) then
       if (q = s.zend) and (s.read <> s.window) then
       begin
       begin
         q := s.window;
         q := s.window;
         if LongInt(q) < LongInt(s.read) then
         if LongInt(q) < LongInt(s.read) then
-          m := uInt(LongInt(s.read)-LongInt(q)-1)
+          m := cardinal(LongInt(s.read)-LongInt(q)-1)
         else
         else
-          m := uInt(LongInt(s.zend)-LongInt(q));
+          m := cardinal(LongInt(s.zend)-LongInt(q));
       end;
       end;
 
 
       if (m = 0) then
       if (m = 0) then
@@ -126,7 +126,7 @@ begin
         s.bitb := b;
         s.bitb := b;
         s.bitk := k;
         s.bitk := k;
         z.avail_in := n;
         z.avail_in := n;
-        Inc(z.total_in, LongInt(p)-LongInt(z.next_in));
+        inc(z.total_in, LongInt(p)-LongInt(z.next_in));
         z.next_in := p;
         z.next_in := p;
         s.write := q;
         s.write := q;
         result := inflate_flush(s,z,r);
         result := inflate_flush(s,z,r);
@@ -141,29 +141,29 @@ end;
 { copy as much as possible from the sliding window to the output area }
 { copy as much as possible from the sliding window to the output area }
 function inflate_flush(var s : inflate_blocks_state;
 function inflate_flush(var s : inflate_blocks_state;
                        var z : z_stream;
                        var z : z_stream;
-                       r : int) : int;
+                       r : integer) : integer;
 var
 var
-  n : uInt;
-  p : pBytef;
-  q : pBytef;
+  n : cardinal;
+  p : Pbyte;
+  q : Pbyte;
 begin
 begin
   { local copies of source and destination pointers }
   { local copies of source and destination pointers }
   p := z.next_out;
   p := z.next_out;
   q := s.read;
   q := s.read;
 
 
   { compute number of bytes to copy as far as end of window }
   { compute number of bytes to copy as far as end of window }
-  if ptr2int(q) <= ptr2int(s.write) then
-    n := uInt(ptr2int(s.write) - ptr2int(q))
+  if ptrint(q) <= ptrint(s.write) then
+    n := cardinal(ptrint(s.write) - ptrint(q))
   else
   else
-    n := uInt(ptr2int(s.zend) - ptr2int(q));
+    n := cardinal(ptrint(s.zend) - ptrint(q));
   if (n > z.avail_out) then
   if (n > z.avail_out) then
     n := z.avail_out;
     n := z.avail_out;
   if (n <> 0) and (r = Z_BUF_ERROR) then
   if (n <> 0) and (r = Z_BUF_ERROR) then
     r := Z_OK;
     r := Z_OK;
 
 
   { update counters }
   { update counters }
-  Dec(z.avail_out, n);
-  Inc(z.total_out, n);
+  dec(z.avail_out, n);
+  inc(z.total_out, n);
 
 
 
 
   { update check information }
   { update check information }
@@ -175,8 +175,8 @@ begin
 
 
   { copy as far as end of window }
   { copy as far as end of window }
   zmemcpy(p, q, n);
   zmemcpy(p, q, n);
-  Inc(p, n);
-  Inc(q, n);
+  inc(p, n);
+  inc(q, n);
 
 
   { see if more to copy at beginning of window }
   { see if more to copy at beginning of window }
   if (q = s.zend) then
   if (q = s.zend) then
@@ -187,15 +187,15 @@ begin
       s.write := s.window;
       s.write := s.window;
 
 
     { compute bytes to copy }
     { compute bytes to copy }
-    n := uInt(ptr2int(s.write) - ptr2int(q));
+    n := cardinal(ptrint(s.write) - ptrint(q));
     if (n > z.avail_out) then
     if (n > z.avail_out) then
       n := z.avail_out;
       n := z.avail_out;
     if (n <> 0) and (r = Z_BUF_ERROR) then
     if (n <> 0) and (r = Z_BUF_ERROR) then
       r := Z_OK;
       r := Z_OK;
 
 
     { update counters }
     { update counters }
-    Dec( z.avail_out, n);
-    Inc( z.total_out, n);
+    dec( z.avail_out, n);
+    inc( z.total_out, n);
 
 
     { update check information }
     { update check information }
     if Assigned(s.checkfn) then
     if Assigned(s.checkfn) then
@@ -206,8 +206,8 @@ begin
 
 
     { copy }
     { copy }
     zmemcpy(p, q, n);
     zmemcpy(p, q, n);
-    Inc(p, n);
-    Inc(q, n);
+    inc(p, n);
+    inc(q, n);
   end;
   end;
 
 
 
 

+ 5 - 8
packages/base/paszlib/minigzip.pas

@@ -18,9 +18,6 @@ program minigzip;
 }
 }
 
 
 uses
 uses
-  {$IFDEF VER80}
-  WinCrt,
-  {$ENDIF}
   gzio, zutil;
   gzio, zutil;
 
 
 const
 const
@@ -54,9 +51,9 @@ end;
 
 
 procedure gz_compress (var infile:file; outfile:gzFile);
 procedure gz_compress (var infile:file; outfile:gzFile);
 var
 var
-  len   : uInt;
+  len   : cardinal;
   ioerr : integer;
   ioerr : integer;
-  err   : int;
+  err   : integer;
 begin
 begin
 
 
   while true do begin
   while true do begin
@@ -91,10 +88,10 @@ end;
 
 
 procedure gz_uncompress (infile:gzFile; var outfile:file);
 procedure gz_uncompress (infile:gzFile; var outfile:file);
 var
 var
-  len     : int;
-  written : uInt;
+  len     : integer;
+  written : cardinal;
   ioerr   : integer;
   ioerr   : integer;
-  err     : int;
+  err     : integer;
 begin
 begin
   while true do begin
   while true do begin
 
 

+ 41 - 46
packages/base/paszlib/paszlib.pas

@@ -10,14 +10,9 @@ const
 
 
 type
 type
   { Compatibility types }
   { Compatibility types }
-  PByte   = ^Byte;
-  Uint    = Cardinal;
-  Ulong   = Cardinal;
-  Ulongf  = ULong;
-  Pulongf = ^Ulongf;
   z_off_t = longint;
   z_off_t = longint;
 
 
-  TAllocfunc = function (opaque:pointer; items:uInt; size:uInt):pointer;
+  TAllocfunc = function (opaque:pointer; items:cardinal; size:cardinal):pointer;
   TFreeFunc = procedure (opaque:pointer; address:pointer);
   TFreeFunc = procedure (opaque:pointer; address:pointer);
 
 
   TInternalState = record
   TInternalState = record
@@ -63,29 +58,29 @@ const
 
 
   Z_DEFLATED = 8;
   Z_DEFLATED = 8;
 
 
-  Z_NULL = 0;
+  Z_NULL = nil;
 
 
 function zlibVersion:string;
 function zlibVersion:string;
 function deflate(var strm:TZstream; flush:longint):longint;
 function deflate(var strm:TZstream; flush:longint):longint;
 function deflateEnd(var strm:TZstream):longint;
 function deflateEnd(var strm:TZstream):longint;
 function inflate(var strm:TZstream; flush:longint):longint;
 function inflate(var strm:TZstream; flush:longint):longint;
 function inflateEnd(var strm:TZstream):longint;
 function inflateEnd(var strm:TZstream):longint;
-function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;
+function deflateSetDictionary(var strm:TZstream;dictionary : Pchar; dictLength:cardinal):longint;
 function deflateCopy(var dest,source:TZstream):longint;
 function deflateCopy(var dest,source:TZstream):longint;
 function deflateReset(var strm:TZstream):longint;
 function deflateReset(var strm:TZstream):longint;
 function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;
 function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;
-function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;
+function inflateSetDictionary(var strm:TZStream;dictionary : Pchar; dictLength:cardinal):longint;
 function inflateSync(var strm:TZStream):longint;
 function inflateSync(var strm:TZStream):longint;
 function inflateReset(var strm:TZStream):longint;
 function inflateReset(var strm:TZStream):longint;
-function compress(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong):longint;
-function compress2(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;
-function uncompress(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong):longint;
-function gzopen(path:pchar; mode:pchar):gzFile;
+function compress(dest:Pchar;var destLen:cardinal; source : Pchar; sourceLen:cardinal):longint;
+function compress2(dest:Pchar;var destLen:cardinal; source : Pchar; sourceLen:cardinal; level:longint):longint;
+function uncompress(dest:Pchar;var destLen:cardinal; source : Pchar; sourceLen:cardinal):longint;
+function gzopen(path:Pchar; mode:Pchar):gzFile;
 function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;
 function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;
 function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;
 function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;
 function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;
 function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;
-function gzputs(thefile:gzFile; s:pchar):longint;
-function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;
+function gzputs(thefile:gzFile; s:Pchar):longint;
+function gzgets(thefile:gzFile; buf:Pchar; len:longint):Pchar;
 function gzputc(thefile:gzFile; c:char):longint;
 function gzputc(thefile:gzFile; c:char):longint;
 function gzgetc(thefile:gzFile):char;
 function gzgetc(thefile:gzFile):char;
 function gzflush(thefile:gzFile; flush:longint):longint;
 function gzflush(thefile:gzFile; flush:longint):longint;
@@ -94,13 +89,13 @@ function gzrewind(thefile:gzFile):longint;
 function gztell(thefile:gzFile):z_off_t;
 function gztell(thefile:gzFile):z_off_t;
 function gzeof(thefile:gzFile):longbool;
 function gzeof(thefile:gzFile):longbool;
 function gzclose(thefile:gzFile):longint;
 function gzclose(thefile:gzFile):longint;
-function gzerror(thefile:gzFile; var errnum:longint):string;
-function adler32(theadler:uLong;buf : pchar; len:uInt):uLong;
-function crc32(thecrc:uLong;buf : pchar; len:uInt):uLong;
-{function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;
-function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;
-function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;
-function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;}
+function gzerror(thefile:gzFile; var errnum:smallint):string;
+function adler32(theadler:cardinal;buf : Pchar; len:cardinal):cardinal;
+function crc32(thecrc:cardinal;buf : Pchar; len:cardinal):cardinal;
+{function deflateInit_(var strm:TZStream; level:longint; version:Pchar; stream_size:longint):longint;
+function inflateInit_(var strm:TZStream; version:Pchar; stream_size:longint):longint;
+function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:Pchar; stream_size:longint):longint;
+function inflateInit2_(var strm:TZStream; windowBits:longint; version:Pchar; stream_size:longint):longint;}
 function deflateInit(var strm:TZStream;level : longint) : longint;
 function deflateInit(var strm:TZStream;level : longint) : longint;
 function inflateInit(var strm:TZStream) : longint;
 function inflateInit(var strm:TZStream) : longint;
 function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
 function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
@@ -112,7 +107,7 @@ function get_crc_table:pointer;
 implementation
 implementation
 
 
 uses
 uses
-  zutil,zdeflate,zinflate,zcompres,zuncompr,gzio,adler,gzcrc;
+  zutil,zdeflate,zinflate,zcompres,zuncompr,gzio,adler,crc;
 
 
 function zlibVersion:string;
 function zlibVersion:string;
 begin
 begin
@@ -139,9 +134,9 @@ begin
   inflateEnd:=zinflate.inflateEnd(strm);
   inflateEnd:=zinflate.inflateEnd(strm);
 end;
 end;
 
 
-function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;
+function deflateSetDictionary(var strm:TZstream;dictionary : Pchar; dictLength:cardinal):longint;
 begin
 begin
-  deflateSetDictionary:=zdeflate.deflateSetDictionary(strm,pbytef(dictionary),dictlength);
+  deflateSetDictionary:=zdeflate.deflateSetDictionary(strm,Pbyte(dictionary),dictlength);
 end;
 end;
 
 
 function deflateCopy(var dest,source:TZstream):longint;
 function deflateCopy(var dest,source:TZstream):longint;
@@ -159,9 +154,9 @@ begin
   deflateParams:=zdeflate.deflateParams(strm,level,strategy);
   deflateParams:=zdeflate.deflateParams(strm,level,strategy);
 end;
 end;
 
 
-function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;
+function inflateSetDictionary(var strm:TZStream;dictionary : Pchar; dictLength:cardinal):longint;
 begin
 begin
-  inflateSetDictionary:=zinflate.inflateSetDictionary(strm,pbytef(dictionary),dictlength);
+  inflateSetDictionary:=zinflate.inflateSetDictionary(strm,Pbyte(dictionary),dictlength);
 end;
 end;
 
 
 function inflateSync(var strm:TZStream):longint;
 function inflateSync(var strm:TZStream):longint;
@@ -174,34 +169,34 @@ begin
   inflateReset:=zinflate.inflateReset(strm);
   inflateReset:=zinflate.inflateReset(strm);
 end;
 end;
 
 
-function compress(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong):longint;
+function compress(dest:Pchar;var destLen:cardinal; source : Pchar; sourceLen:cardinal):longint;
 
 
 type Pbytearray=^Tbytearray;
 type Pbytearray=^Tbytearray;
      Tbytearray=array[0..0] of byte;
      Tbytearray=array[0..0] of byte;
 
 
 begin
 begin
-  compress:=zcompres.compress(pbytef(dest),destlen,Pbytearray(source)^,sourcelen);
+  compress:=zcompres.compress(Pbyte(dest),destlen,Pbytearray(source)^,sourcelen);
 end;
 end;
 
 
-function compress2(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;
+function compress2(dest:Pchar;var destLen:cardinal; source : Pchar; sourceLen:cardinal; level:longint):longint;
 
 
 type Pbytearray=^Tbytearray;
 type Pbytearray=^Tbytearray;
      Tbytearray=array[0..0] of byte;
      Tbytearray=array[0..0] of byte;
 
 
 begin
 begin
-  compress2:=zcompres.compress2(pbytef(dest),destlen,Pbytearray(source)^,sourcelen,level);
+  compress2:=zcompres.compress2(Pbyte(dest),destlen,Pbytearray(source)^,sourcelen,level);
 end;
 end;
 
 
-function uncompress(dest:pchar;var destLen:uLongf; source : pchar; sourceLen:uLong):longint;
+function uncompress(dest:Pchar;var destLen:cardinal; source : Pchar; sourceLen:cardinal):longint;
 
 
 type Pbytearray=^Tbytearray;
 type Pbytearray=^Tbytearray;
      Tbytearray=array[0..0] of byte;
      Tbytearray=array[0..0] of byte;
 
 
 begin
 begin
-  uncompress:=zuncompr.uncompress(pbytef(dest),destlen,Pbytearray(source)^,sourcelen);
+  uncompress:=zuncompr.uncompress(Pbyte(dest),destlen,Pbytearray(source)^,sourcelen);
 end;
 end;
 
 
-function gzopen(path:pchar; mode:pchar):gzFile;
+function gzopen(path:Pchar; mode:Pchar):gzFile;
 begin
 begin
   gzopen:=gzio.gzopen(path,mode);
   gzopen:=gzio.gzopen(path,mode);
 end;
 end;
@@ -221,12 +216,12 @@ begin
   gzwrite:=gzio.gzwrite(thefile,buf,len);
   gzwrite:=gzio.gzwrite(thefile,buf,len);
 end;
 end;
 
 
-function gzputs(thefile:gzFile; s:pchar):longint;
+function gzputs(thefile:gzFile; s:Pchar):longint;
 begin
 begin
   gzputs:=gzio.gzputs(thefile,s);
   gzputs:=gzio.gzputs(thefile,s);
 end;
 end;
 
 
-function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;
+function gzgets(thefile:gzFile; buf:Pchar; len:longint):Pchar;
 begin
 begin
   gzgets:=gzio.gzgets(thefile,buf,len);
   gzgets:=gzio.gzgets(thefile,buf,len);
 end;
 end;
@@ -271,37 +266,37 @@ begin
   gzclose:=gzio.gzclose(thefile);
   gzclose:=gzio.gzclose(thefile);
 end;
 end;
 
 
-function gzerror(thefile:gzFile; var errnum:longint):string;
+function gzerror(thefile:gzFile; var errnum:smallint):string;
 begin
 begin
   gzerror:=gzio.gzerror(thefile,errnum);
   gzerror:=gzio.gzerror(thefile,errnum);
 end;
 end;
 
 
-function adler32(theadler:uLong;buf : pchar; len:uInt):uLong;
+function adler32(theadler:cardinal;buf : Pchar; len:cardinal):cardinal;
 begin
 begin
-  adler32:=adler.adler32(theadler,pbytef(buf),len);
+  adler32:=adler.adler32(theadler,Pbyte(buf),len);
 end;
 end;
 
 
-function crc32(thecrc:uLong;buf : pchar; len:uInt):uLong;
+function crc32(thecrc:cardinal;buf : Pchar; len:cardinal):cardinal;
 begin
 begin
-  crc32:=gzcrc.crc32(thecrc,pbytef(buf),len);
+  crc32:=crc.crc32(thecrc,Pbyte(buf),len);
 end;
 end;
 {
 {
-function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;
+function deflateInit_(var strm:TZStream; level:longint; version:Pchar; stream_size:longint):longint;
 begin
 begin
   deflateInit_:=zdeflate.deflateInit_(@strm,level,version,stream_size);
   deflateInit_:=zdeflate.deflateInit_(@strm,level,version,stream_size);
 end;
 end;
 
 
-function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;
+function inflateInit_(var strm:TZStream; version:Pchar; stream_size:longint):longint;
 begin
 begin
   inflateInit_:=zinflate.inflateInit_(@strm,version,stream_size);
   inflateInit_:=zinflate.inflateInit_(@strm,version,stream_size);
 end;
 end;
 
 
-function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;
+function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:Pchar; stream_size:longint):longint;
 begin
 begin
   deflateInit2_:=zdeflate.deflateInit2_(strm,level,method,windowBits,memlevel,strategy,version,stream_size);
   deflateInit2_:=zdeflate.deflateInit2_(strm,level,method,windowBits,memlevel,strategy,version,stream_size);
 end;
 end;
 
 
-function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;
+function inflateInit2_(var strm:TZStream; windowBits:longint; version:Pchar; stream_size:longint):longint;
 begin
 begin
   inflateInit2_:=zinflate.inflateInit2_(strm,windowBits,version,stream_size);
   inflateInit2_:=zinflate.inflateInit2_(strm,windowBits,version,stream_size);
 end;
 end;
@@ -338,7 +333,7 @@ end;
 
 
 function get_crc_table:pointer;
 function get_crc_table:pointer;
 begin
 begin
-  get_crc_table:=gzcrc.get_crc_table;
+  get_crc_table:=crc.get_crc_table;
 end;
 end;
 
 
 end.
 end.

File diff suppressed because it is too large
+ 213 - 216
packages/base/paszlib/trees.pas


+ 50 - 50
packages/base/paszlib/zbase.pas

@@ -69,7 +69,7 @@ uses
 
 
 
 
 { Compile with -DMAXSEG_64K if the alloc function cannot allocate more
 { Compile with -DMAXSEG_64K if the alloc function cannot allocate more
-  than 64k bytes at a time (needed on systems with 16-bit int). }
+  than 64k bytes at a time (needed on systems with 16-bit integer). }
 
 
 { Maximum value for memLevel in deflateInit2 }
 { Maximum value for memLevel in deflateInit2 }
 {$ifdef MAXSEG_64K}
 {$ifdef MAXSEG_64K}
@@ -121,9 +121,9 @@ type
   inflate_huft = Record
   inflate_huft = Record
     Exop,             { number of extra bits or operation }
     Exop,             { number of extra bits or operation }
     bits : Byte;      { number of bits in this code or subcode }
     bits : Byte;      { number of bits in this code or subcode }
-    {pad : uInt;}       { pad structure to a power of 2 (4 bytes for }
-                      {  16-bit, 8 bytes for 32-bit int's) }
-    base : uInt;      { literal, length base, or distance base }
+    {pad : cardinal;}       { pad structure to a power of 2 (4 bytes for }
+                      {  16-bit, 8 bytes for 32-bit integer's) }
+    base : cardinal;      { literal, length base, or distance base }
                       { or table offset }
                       { or table offset }
   End;
   End;
 
 
@@ -154,17 +154,17 @@ type
     mode : inflate_codes_mode;        { current inflate_codes mode }
     mode : inflate_codes_mode;        { current inflate_codes mode }
 
 
     { mode dependent information }
     { mode dependent information }
-    len : uInt;
+    len : cardinal;
     sub : record                      { submode }
     sub : record                      { submode }
       Case Byte of
       Case Byte of
       0:(code : record                { if LEN or DIST, where in tree }
       0:(code : record                { if LEN or DIST, where in tree }
           tree : pInflate_huft;       { pointer into tree }
           tree : pInflate_huft;       { pointer into tree }
-          need : uInt;                { bits needed }
+          need : cardinal;                { bits needed }
          end);
          end);
-      1:(lit : uInt);                 { if LIT, literal }
+      1:(lit : cardinal);                 { if LIT, literal }
       2:(copy: record                 { if EXT or COPY, where and how much }
       2:(copy: record                 { if EXT or COPY, where and how much }
-           get : uInt;                { bits to get for extra }
-           dist : uInt;               { distance back to copy from }
+           get : cardinal;                { bits to get for extra }
+           dist : cardinal;               { distance back to copy from }
          end);
          end);
     end;
     end;
 
 
@@ -176,10 +176,10 @@ type
   end;
   end;
 
 
 type
 type
-  check_func = function(check : uLong;
-                        buf : pBytef;
+  check_func = function(check : cardinal;
+                        buf : Pbyte;
                         {const buf : array of byte;}
                         {const buf : array of byte;}
-	                len : uInt) : uLong;
+	                len : cardinal) : cardinal;
 type
 type
   inflate_block_mode =
   inflate_block_mode =
      (ZTYPE,    { get type bits (3, including end bit) }
      (ZTYPE,    { get type bits (3, including end bit) }
@@ -204,12 +204,12 @@ type
     { mode dependent information }
     { mode dependent information }
     sub : record                  { submode }
     sub : record                  { submode }
     case Byte of
     case Byte of
-    0:(left : uInt);              { if STORED, bytes left to copy }
+    0:(left : cardinal);              { if STORED, bytes left to copy }
     1:(trees : record             { if DTREE, decoding info for trees }
     1:(trees : record             { if DTREE, decoding info for trees }
-        table : uInt;               { table lengths (14 bits) }
-        index : uInt;               { index into blens (or border) }
+        table : cardinal;               { table lengths (14 bits) }
+        index : cardinal;               { index into blens (or border) }
         blens : PuIntArray;         { bit lengths of codes }
         blens : PuIntArray;         { bit lengths of codes }
-        bb : uInt;                  { bit length tree depth }
+        bb : cardinal;                  { bit length tree depth }
         tb : pInflate_huft;         { bit length decoding tree }
         tb : pInflate_huft;         { bit length decoding tree }
       end);
       end);
     2:(decode : record            { if CODES, current state }
     2:(decode : record            { if CODES, current state }
@@ -221,15 +221,15 @@ type
     last : boolean;               { true if this block is the last block }
     last : boolean;               { true if this block is the last block }
 
 
     { mode independent information }
     { mode independent information }
-    bitk : uInt;            { bits in bit buffer }
-    bitb : uLong;           { bit buffer }
+    bitk : cardinal;            { bits in bit buffer }
+    bitb : cardinal;           { bit buffer }
     hufts : huft_ptr; {pInflate_huft;}  { single malloc for tree space }
     hufts : huft_ptr; {pInflate_huft;}  { single malloc for tree space }
-    window : pBytef;        { sliding window }
-    zend : pBytef;          { one byte after sliding window }
-    read : pBytef;          { window read pointer }
-    write : pBytef;         { window write pointer }
+    window : Pbyte;        { sliding window }
+    zend : Pbyte;          { one byte after sliding window }
+    read : Pbyte;          { window read pointer }
+    write : Pbyte;         { window write pointer }
     checkfn : check_func;   { check function }
     checkfn : check_func;   { check function }
-    check : uLong;          { check on output }
+    check : cardinal;          { check on output }
   end;
   end;
 
 
 type
 type
@@ -259,45 +259,45 @@ type
      { mode dependent information }
      { mode dependent information }
      sub : record          { submode }
      sub : record          { submode }
        case byte of
        case byte of
-       0:(method : uInt);  { if FLAGS, method byte }
+       0:(method : cardinal);  { if FLAGS, method byte }
        1:(check : record   { if CHECK, check values to compare }
        1:(check : record   { if CHECK, check values to compare }
-           was : uLong;        { computed check value }
-           need : uLong;       { stream check value }
+           was : cardinal;        { computed check value }
+           need : cardinal;       { stream check value }
           end);
           end);
-       2:(marker : uInt);  { if BAD, inflateSync's marker bytes count }
+       2:(marker : cardinal);  { if BAD, inflateSync's marker bytes count }
      end;
      end;
 
 
      { mode independent information }
      { mode independent information }
      nowrap : boolean;      { flag for no wrapper }
      nowrap : boolean;      { flag for no wrapper }
-     wbits : uInt;          { log2(window size)  (8..15, defaults to 15) }
+     wbits : cardinal;          { log2(window size)  (8..15, defaults to 15) }
      blocks : pInflate_blocks_state;    { current inflate_blocks state }
      blocks : pInflate_blocks_state;    { current inflate_blocks state }
    end;
    end;
 
 
 type
 type
-  alloc_func = function(opaque : voidpf; items : uInt; size : uInt) : voidpf;
-  free_func = procedure(opaque : voidpf; address : voidpf);
+  alloc_func = function(opaque : pointer; items : cardinal; size : cardinal) : pointer;
+  free_func = procedure(opaque : pointer; address : pointer);
 
 
 type
 type
   z_streamp = ^z_stream;
   z_streamp = ^z_stream;
   z_stream = record
   z_stream = record
-    next_in : pBytef;     { next input byte }
-    avail_in : uInt;      { number of bytes available at next_in }
-    total_in : uLong;     { total nb of input bytes read so far }
+    next_in : Pbyte;     { next input byte }
+    avail_in : cardinal;      { number of bytes available at next_in }
+    total_in : cardinal;     { total nb of input bytes read so far }
 
 
-    next_out : pBytef;    { next output byte should be put there }
-    avail_out : uInt;     { remaining free space at next_out }
-    total_out : uLong;    { total nb of bytes output so far }
+    next_out : Pbyte;    { next output byte should be put there }
+    avail_out : cardinal;     { remaining free space at next_out }
+    total_out : cardinal;    { total nb of bytes output so far }
 
 
     msg : string[255];         { last error message, '' if no error }
     msg : string[255];         { last error message, '' if no error }
     state : pInternal_state; { not visible by applications }
     state : pInternal_state; { not visible by applications }
 
 
     zalloc : alloc_func;  { used to allocate the internal state }
     zalloc : alloc_func;  { used to allocate the internal state }
     zfree : free_func;    { used to free the internal state }
     zfree : free_func;    { used to free the internal state }
-    opaque : voidpf;      { private data object passed to zalloc and zfree }
+    opaque : pointer;      { private data object passed to zalloc and zfree }
 
 
-    data_type : int;      { best guess about the data type: ascii or binary }
-    adler : uLong;        { adler32 value of the uncompressed data }
-    reserved : uLong;     { reserved for future use }
+    data_type : integer;      { best guess about the data type: ascii or binary }
+    adler : cardinal;        { adler32 value of the uncompressed data }
+    reserved : cardinal;     { reserved for future use }
   end;
   end;
 
 
 
 
@@ -371,7 +371,7 @@ const  { constants }
 
 
   {$IFDEF GZIO}
   {$IFDEF GZIO}
 var
 var
-  errno : int;
+  errno : integer;
   {$ENDIF}
   {$ENDIF}
 
 
         { common constants }
         { common constants }
@@ -412,13 +412,13 @@ function zlibVersion : string;
   not compatible with the zlib.h header file used by the application.
   not compatible with the zlib.h header file used by the application.
   This check is automatically made by deflateInit and inflateInit. }
   This check is automatically made by deflateInit and inflateInit. }
 
 
-function zError(err : int) : string;
+function zError(err : integer) : string;
 
 
-function ZALLOC (var strm : z_stream; items : uInt; size : uInt) : voidpf;
+function ZALLOC (var strm : z_stream; items : cardinal; size : cardinal) : pointer;
 
 
-procedure ZFREE (var strm : z_stream; ptr : voidpf);
+procedure ZFREE (var strm : z_stream; ptr : pointer);
 
 
-procedure TRY_FREE (var strm : z_stream; ptr : voidpf);
+procedure TRY_FREE (var strm : z_stream; ptr : pointer);
 
 
 const
 const
   ZLIB_VERSION : string[10] = '1.1.2';
   ZLIB_VERSION : string[10] = '1.1.2';
@@ -437,7 +437,7 @@ const
             'incompatible version',{ Z_VERSION_ERROR (-6) }
             'incompatible version',{ Z_VERSION_ERROR (-6) }
             '');
             '');
 const
 const
-  z_verbose : int = 1;
+  z_verbose : integer = 1;
 
 
 {$IFDEF DEBUG}
 {$IFDEF DEBUG}
 procedure z_error (m : string);
 procedure z_error (m : string);
@@ -445,7 +445,7 @@ procedure z_error (m : string);
 
 
 implementation
 implementation
 
 
-function zError(err : int) : string;
+function zError(err : integer) : string;
 begin
 begin
   zError := z_errmsg[Z_NEED_DICT-err];
   zError := z_errmsg[Z_NEED_DICT-err];
 end;
 end;
@@ -504,17 +504,17 @@ begin
     WriteLn(x);
     WriteLn(x);
 end;
 end;
 
 
-function ZALLOC (var strm : z_stream; items : uInt; size : uInt) : voidpf;
+function ZALLOC (var strm : z_stream; items : cardinal; size : cardinal) : pointer;
 begin
 begin
   ZALLOC := strm.zalloc(strm.opaque, items, size);
   ZALLOC := strm.zalloc(strm.opaque, items, size);
 end;
 end;
 
 
-procedure ZFREE (var strm : z_stream; ptr : voidpf);
+procedure ZFREE (var strm : z_stream; ptr : pointer);
 begin
 begin
   strm.zfree(strm.opaque, ptr);
   strm.zfree(strm.opaque, ptr);
 end;
 end;
 
 
-procedure TRY_FREE (var strm : z_stream; ptr : voidpf);
+procedure TRY_FREE (var strm : z_stream; ptr : pointer);
 begin
 begin
   {if @strm <> Z_NULL then}
   {if @strm <> Z_NULL then}
     strm.zfree(strm.opaque, ptr);
     strm.zfree(strm.opaque, ptr);

+ 20 - 20
packages/base/paszlib/zcompres.pas

@@ -18,10 +18,10 @@ uses
                         { utility functions }
                         { utility functions }
 
 
 {EXPORT}
 {EXPORT}
-function compress (dest : pBytef;
-                   var destLen : uLong;
+function compress (dest : Pbyte;
+                   var destLen : cardinal;
                    const source : array of Byte;
                    const source : array of Byte;
-                   sourceLen : uLong) : int;
+                   sourceLen : cardinal) : integer;
 
 
  { Compresses the source buffer into the destination buffer.  sourceLen is
  { Compresses the source buffer into the destination buffer.  sourceLen is
    the byte length of the source buffer. Upon entry, destLen is the total
    the byte length of the source buffer. Upon entry, destLen is the total
@@ -35,11 +35,11 @@ function compress (dest : pBytef;
    buffer. }
    buffer. }
 
 
 {EXPORT}
 {EXPORT}
-function compress2 (dest : pBytef;
-                    var destLen : uLong;
+function compress2 (dest : Pbyte;
+                    var destLen : cardinal;
                     const source : array of byte;
                     const source : array of byte;
-                    sourceLen : uLong;
-                    level : int) : int;
+                    sourceLen : cardinal;
+                    level : integer) : integer;
 {  Compresses the source buffer into the destination buffer. The level
 {  Compresses the source buffer into the destination buffer. The level
    parameter has the same meaning as in deflateInit.  sourceLen is the byte
    parameter has the same meaning as in deflateInit.  sourceLen is the byte
    length of the source buffer. Upon entry, destLen is the total size of the
    length of the source buffer. Upon entry, destLen is the total size of the
@@ -54,28 +54,28 @@ implementation
 
 
 { ===========================================================================
 { ===========================================================================
 }
 }
-function compress2 (dest : pBytef;
-                    var destLen : uLong;
+function compress2 (dest : Pbyte;
+                    var destLen : cardinal;
                     const source : array of byte;
                     const source : array of byte;
-                    sourceLen : uLong;
-                    level : int) : int;
+                    sourceLen : cardinal;
+                    level : integer) : integer;
 var
 var
   stream : z_stream;
   stream : z_stream;
-  err : int;
+  err : integer;
 begin
 begin
-  stream.next_in := pBytef(@source);
-  stream.avail_in := uInt(sourceLen);
+  stream.next_in := Pbyte(@source);
+  stream.avail_in := cardinal(sourceLen);
 {$ifdef MAXSEG_64K}
 {$ifdef MAXSEG_64K}
   { Check for source > 64K on 16-bit machine: }
   { Check for source > 64K on 16-bit machine: }
-  if (uLong(stream.avail_in) <> sourceLen) then
+  if (cardinal(stream.avail_in) <> sourceLen) then
   begin
   begin
     compress2 := Z_BUF_ERROR;
     compress2 := Z_BUF_ERROR;
     exit;
     exit;
   end;
   end;
 {$endif}
 {$endif}
   stream.next_out := dest;
   stream.next_out := dest;
-  stream.avail_out := uInt(destLen);
-  if (uLong(stream.avail_out) <> destLen) then
+  stream.avail_out := cardinal(destLen);
+  if (cardinal(stream.avail_out) <> destLen) then
   begin
   begin
     compress2 := Z_BUF_ERROR;
     compress2 := Z_BUF_ERROR;
     exit;
     exit;
@@ -110,10 +110,10 @@ end;
 
 
 { ===========================================================================
 { ===========================================================================
  }
  }
-function compress (dest : pBytef;
-                   var destLen : uLong;
+function compress (dest : Pbyte;
+                   var destLen : cardinal;
                    const source : array of Byte;
                    const source : array of Byte;
-                   sourceLen : uLong) : int;
+                   sourceLen : cardinal) : integer;
 begin
 begin
   compress := compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
   compress := compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
 end;
 end;

File diff suppressed because it is too large
+ 209 - 209
packages/base/paszlib/zdeflate.pas


+ 56 - 56
packages/base/paszlib/zinflate.pas

@@ -15,7 +15,7 @@ interface
 uses
 uses
   zutil, zbase, infblock, infutil;
   zutil, zbase, infblock, infutil;
 
 
-function inflateInit(var z : z_stream) : int;
+function inflateInit(var z : z_stream) : integer;
 
 
 {    Initializes the internal stream state for decompression. The fields
 {    Initializes the internal stream state for decompression. The fields
    zalloc, zfree and opaque must be initialized before by the caller.  If
    zalloc, zfree and opaque must be initialized before by the caller.  If
@@ -32,16 +32,16 @@ function inflateInit(var z : z_stream) : int;
 
 
 function inflateInit_(z : z_streamp;
 function inflateInit_(z : z_streamp;
                       const version : string;
                       const version : string;
-                      stream_size : int) : int;
+                      stream_size : integer) : integer;
 
 
 
 
 function inflateInit2_(var z: z_stream;
 function inflateInit2_(var z: z_stream;
-                       w : int;
+                       w : integer;
                        const version : string;
                        const version : string;
-                       stream_size : int) : int;
+                       stream_size : integer) : integer;
 
 
 function inflateInit2(var z: z_stream;
 function inflateInit2(var z: z_stream;
-                       windowBits : int) : int;
+                       windowBits : integer) : integer;
 
 
 {
 {
      This is another version of inflateInit with an extra parameter. The
      This is another version of inflateInit with an extra parameter. The
@@ -65,7 +65,7 @@ function inflateInit2(var z: z_stream;
 
 
 
 
 
 
-function inflateEnd(var z : z_stream) : int;
+function inflateEnd(var z : z_stream) : integer;
 
 
 {
 {
    All dynamically allocated data structures for this stream are freed.
    All dynamically allocated data structures for this stream are freed.
@@ -77,7 +77,7 @@ function inflateEnd(var z : z_stream) : int;
    static string (which must not be deallocated).
    static string (which must not be deallocated).
 }
 }
 
 
-function inflateReset(var z : z_stream) : int;
+function inflateReset(var z : z_stream) : integer;
 
 
 {
 {
    This function is equivalent to inflateEnd followed by inflateInit,
    This function is equivalent to inflateEnd followed by inflateInit,
@@ -90,7 +90,7 @@ function inflateReset(var z : z_stream) : int;
 
 
 
 
 function inflate(var z : z_stream;
 function inflate(var z : z_stream;
-                 f : int) : int;
+                 f : integer) : integer;
 {
 {
   inflate decompresses as much data as possible, and stops when the input
   inflate decompresses as much data as possible, and stops when the input
   buffer becomes empty or the output buffer becomes full. It may introduce
   buffer becomes empty or the output buffer becomes full. It may introduce
@@ -160,8 +160,8 @@ function inflate(var z : z_stream;
 
 
 
 
 function inflateSetDictionary(var z : z_stream;
 function inflateSetDictionary(var z : z_stream;
-                              dictionary : pBytef; {const array of byte}
-                              dictLength : uInt) : int;
+                              dictionary : Pbyte; {const array of byte}
+                              dictLength : cardinal) : integer;
 
 
 {
 {
      Initializes the decompression dictionary from the given uncompressed byte
      Initializes the decompression dictionary from the given uncompressed byte
@@ -179,7 +179,7 @@ function inflateSetDictionary(var z : z_stream;
    inflate().
    inflate().
 }
 }
 
 
-function inflateSync(var z : z_stream) : int;
+function inflateSync(var z : z_stream) : integer;
 
 
 {
 {
   Skips invalid compressed data until a full flush point (see above the
   Skips invalid compressed data until a full flush point (see above the
@@ -196,7 +196,7 @@ function inflateSync(var z : z_stream) : int;
 }
 }
 
 
 
 
-function inflateSyncPoint(var z : z_stream) : int;
+function inflateSyncPoint(var z : z_stream) : integer;
 
 
 
 
 implementation
 implementation
@@ -204,7 +204,7 @@ implementation
 uses
 uses
   adler;
   adler;
 
 
-function inflateReset(var z : z_stream) : int;
+function inflateReset(var z : z_stream) : integer;
 begin
 begin
   if (z.state = Z_NULL) then
   if (z.state = Z_NULL) then
   begin
   begin
@@ -226,7 +226,7 @@ begin
 end;
 end;
 
 
 
 
-function inflateEnd(var z : z_stream) : int;
+function inflateEnd(var z : z_stream) : integer;
 begin
 begin
   if (z.state = Z_NULL) or not Assigned(z.zfree) then
   if (z.state = Z_NULL) or not Assigned(z.zfree) then
   begin
   begin
@@ -245,9 +245,9 @@ end;
 
 
 
 
 function inflateInit2_(var z: z_stream;
 function inflateInit2_(var z: z_stream;
-                       w : int;
+                       w : integer;
                        const version : string;
                        const version : string;
-                       stream_size : int) : int;
+                       stream_size : integer) : integer;
 begin
 begin
   if (version = '') or (version[1] <> ZLIB_VERSION[1]) or
   if (version = '') or (version[1] <> ZLIB_VERSION[1]) or
       (stream_size <> sizeof(z_stream)) then
       (stream_size <> sizeof(z_stream)) then
@@ -263,7 +263,7 @@ begin
     {$IFDEF FPC}  z.zalloc := @zcalloc;  {$ELSE}
     {$IFDEF FPC}  z.zalloc := @zcalloc;  {$ELSE}
     z.zalloc := zcalloc;
     z.zalloc := zcalloc;
     {$endif}
     {$endif}
-    z.opaque := voidpf(0);
+    z.opaque := nil;
   end;
   end;
   if not Assigned(z.zfree) then
   if not Assigned(z.zfree) then
     {$IFDEF FPC}  z.zfree := @zcfree;  {$ELSE}
     {$IFDEF FPC}  z.zfree := @zcfree;  {$ELSE}
@@ -294,16 +294,16 @@ begin
     inflateInit2_ := Z_STREAM_ERROR;
     inflateInit2_ := Z_STREAM_ERROR;
     exit;
     exit;
   end;
   end;
-  z.state^.wbits := uInt(w);
+  z.state^.wbits := cardinal(w);
 
 
   { create inflate_blocks state }
   { create inflate_blocks state }
   if z.state^.nowrap then
   if z.state^.nowrap then
-    z.state^.blocks := inflate_blocks_new(z, NIL, uInt(1) shl w)
+    z.state^.blocks := inflate_blocks_new(z, NIL, cardinal(1) shl w)
   else
   else
   {$IFDEF FPC}
   {$IFDEF FPC}
-    z.state^.blocks := inflate_blocks_new(z, @adler32, uInt(1) shl w);
+    z.state^.blocks := inflate_blocks_new(z, @adler32, cardinal(1) shl w);
   {$ELSE}
   {$ELSE}
-    z.state^.blocks := inflate_blocks_new(z, adler32, uInt(1) shl w);
+    z.state^.blocks := inflate_blocks_new(z, adler32, cardinal(1) shl w);
   {$ENDIF}
   {$ENDIF}
   if (z.state^.blocks = Z_NULL) then
   if (z.state^.blocks = Z_NULL) then
   begin
   begin
@@ -319,13 +319,13 @@ begin
   inflateInit2_ :=  Z_OK;
   inflateInit2_ :=  Z_OK;
 end;
 end;
 
 
-function inflateInit2(var z: z_stream; windowBits : int) : int;
+function inflateInit2(var z: z_stream; windowBits : integer) : integer;
 begin
 begin
   inflateInit2 := inflateInit2_(z, windowBits, ZLIB_VERSION, sizeof(z_stream));
   inflateInit2 := inflateInit2_(z, windowBits, ZLIB_VERSION, sizeof(z_stream));
 end;
 end;
 
 
 
 
-function inflateInit(var z : z_stream) : int;
+function inflateInit(var z : z_stream) : integer;
 { inflateInit is a macro to allow checking the zlib version
 { inflateInit is a macro to allow checking the zlib version
   and the compiler's view of z_stream:  }
   and the compiler's view of z_stream:  }
 begin
 begin
@@ -334,7 +334,7 @@ end;
 
 
 function inflateInit_(z : z_streamp;
 function inflateInit_(z : z_streamp;
                       const version : string;
                       const version : string;
-                      stream_size : int) : int;
+                      stream_size : integer) : integer;
 begin
 begin
   { initialize state }
   { initialize state }
   if (z = Z_NULL) then
   if (z = Z_NULL) then
@@ -344,10 +344,10 @@ begin
 end;
 end;
 
 
 function inflate(var z : z_stream;
 function inflate(var z : z_stream;
-                 f : int) : int;
+                 f : integer) : integer;
 var
 var
-  r : int;
-  b : uInt;
+  r : integer;
+  b : cardinal;
 begin
 begin
   if (z.state = Z_NULL) or (z.next_in = Z_NULL) then
   if (z.state = Z_NULL) or (z.next_in = Z_NULL) then
   begin
   begin
@@ -396,10 +396,10 @@ begin
         end;
         end;
         r := f;
         r := f;
 
 
-        {z.state^.sub.check.need := uLong(NEXTBYTE(z)) shl 24;}
+        {z.state^.sub.check.need := cardinal(NEXTBYTE(z)) shl 24;}
         Dec(z.avail_in);
         Dec(z.avail_in);
         Inc(z.total_in);
         Inc(z.total_in);
-        z.state^.sub.check.need := uLong(z.next_in^) shl 24;
+        z.state^.sub.check.need := cardinal(z.next_in^) shl 24;
         Inc(z.next_in);
         Inc(z.next_in);
 
 
         z.state^.mode := CHECK3;   { falltrough }
         z.state^.mode := CHECK3;   { falltrough }
@@ -413,10 +413,10 @@ begin
           exit;
           exit;
         end;
         end;
         r := f;
         r := f;
-        {Inc( z.state^.sub.check.need, uLong(NEXTBYTE(z)) shl 16);}
+        {Inc( z.state^.sub.check.need, cardinal(NEXTBYTE(z)) shl 16);}
         Dec(z.avail_in);
         Dec(z.avail_in);
         Inc(z.total_in);
         Inc(z.total_in);
-        Inc(z.state^.sub.check.need, uLong(z.next_in^) shl 16);
+        Inc(z.state^.sub.check.need, cardinal(z.next_in^) shl 16);
         Inc(z.next_in);
         Inc(z.next_in);
 
 
         z.state^.mode := CHECK2;   { falltrough }
         z.state^.mode := CHECK2;   { falltrough }
@@ -431,10 +431,10 @@ begin
         end;
         end;
         r := f;
         r := f;
 
 
-        {Inc( z.state^.sub.check.need, uLong(NEXTBYTE(z)) shl 8);}
+        {Inc( z.state^.sub.check.need, cardinal(NEXTBYTE(z)) shl 8);}
         Dec(z.avail_in);
         Dec(z.avail_in);
         Inc(z.total_in);
         Inc(z.total_in);
-        Inc(z.state^.sub.check.need, uLong(z.next_in^) shl 8);
+        Inc(z.state^.sub.check.need, cardinal(z.next_in^) shl 8);
         Inc(z.next_in);
         Inc(z.next_in);
 
 
         z.state^.mode := CHECK1;   { falltrough }
         z.state^.mode := CHECK1;   { falltrough }
@@ -448,10 +448,10 @@ begin
           exit;
           exit;
         end;
         end;
         r := f;
         r := f;
-        {Inc( z.state^.sub.check.need, uLong(NEXTBYTE(z)) );}
+        {Inc( z.state^.sub.check.need, cardinal(NEXTBYTE(z)) );}
         Dec(z.avail_in);
         Dec(z.avail_in);
         Inc(z.total_in);
         Inc(z.total_in);
-        Inc(z.state^.sub.check.need, uLong(z.next_in^) );
+        Inc(z.state^.sub.check.need, cardinal(z.next_in^) );
         Inc(z.next_in);
         Inc(z.next_in);
 
 
 
 
@@ -547,10 +547,10 @@ begin
         end;
         end;
         r := f;
         r := f;
 
 
-        {z.state^.sub.check.need := uLong(NEXTBYTE(z)) shl 24;}
+        {z.state^.sub.check.need := cardinal(NEXTBYTE(z)) shl 24;}
         Dec(z.avail_in);
         Dec(z.avail_in);
         Inc(z.total_in);
         Inc(z.total_in);
-        z.state^.sub.check.need :=  uLong(z.next_in^) shl 24;
+        z.state^.sub.check.need :=  cardinal(z.next_in^) shl 24;
         Inc(z.next_in);
         Inc(z.next_in);
 
 
         z.state^.mode := DICT3;        { falltrough }
         z.state^.mode := DICT3;        { falltrough }
@@ -563,10 +563,10 @@ begin
           exit;
           exit;
         end;
         end;
         r := f;
         r := f;
-        {Inc(z.state^.sub.check.need, uLong(NEXTBYTE(z)) shl 16);}
+        {Inc(z.state^.sub.check.need, cardinal(NEXTBYTE(z)) shl 16);}
         Dec(z.avail_in);
         Dec(z.avail_in);
         Inc(z.total_in);
         Inc(z.total_in);
-        Inc(z.state^.sub.check.need, uLong(z.next_in^) shl 16);
+        Inc(z.state^.sub.check.need, cardinal(z.next_in^) shl 16);
         Inc(z.next_in);
         Inc(z.next_in);
 
 
         z.state^.mode := DICT2;        { falltrough }
         z.state^.mode := DICT2;        { falltrough }
@@ -580,10 +580,10 @@ begin
         end;
         end;
         r := f;
         r := f;
 
 
-        {Inc(z.state^.sub.check.need, uLong(NEXTBYTE(z)) shl 8);}
+        {Inc(z.state^.sub.check.need, cardinal(NEXTBYTE(z)) shl 8);}
         Dec(z.avail_in);
         Dec(z.avail_in);
         Inc(z.total_in);
         Inc(z.total_in);
-        Inc(z.state^.sub.check.need, uLong(z.next_in^) shl 8);
+        Inc(z.state^.sub.check.need, cardinal(z.next_in^) shl 8);
         Inc(z.next_in);
         Inc(z.next_in);
 
 
         z.state^.mode := DICT1;        { falltrough }
         z.state^.mode := DICT1;        { falltrough }
@@ -596,10 +596,10 @@ begin
           exit;
           exit;
         end;
         end;
         { r := f;    ---  wird niemals benutzt }
         { r := f;    ---  wird niemals benutzt }
-        {Inc(z.state^.sub.check.need, uLong(NEXTBYTE(z)) );}
+        {Inc(z.state^.sub.check.need, cardinal(NEXTBYTE(z)) );}
         Dec(z.avail_in);
         Dec(z.avail_in);
         Inc(z.total_in);
         Inc(z.total_in);
-        Inc(z.state^.sub.check.need, uLong(z.next_in^) );
+        Inc(z.state^.sub.check.need, cardinal(z.next_in^) );
         Inc(z.next_in);
         Inc(z.next_in);
 
 
         z.adler := z.state^.sub.check.need;
         z.adler := z.state^.sub.check.need;
@@ -632,10 +632,10 @@ begin
 end;
 end;
 
 
 function inflateSetDictionary(var z : z_stream;
 function inflateSetDictionary(var z : z_stream;
-                              dictionary : pBytef; {const array of byte}
-                              dictLength : uInt) : int;
+                              dictionary : Pbyte; {const array of byte}
+                              dictLength : cardinal) : integer;
 var
 var
-  length : uInt;
+  length : cardinal;
 begin
 begin
   length := dictLength;
   length := dictLength;
 
 
@@ -644,14 +644,14 @@ begin
     inflateSetDictionary := Z_STREAM_ERROR;
     inflateSetDictionary := Z_STREAM_ERROR;
     exit;
     exit;
   end;
   end;
-  if (adler32(Long(1), dictionary, dictLength) <> z.adler) then
+  if (adler32(1, dictionary, dictLength) <> z.adler) then
   begin
   begin
     inflateSetDictionary := Z_DATA_ERROR;
     inflateSetDictionary := Z_DATA_ERROR;
     exit;
     exit;
   end;
   end;
-  z.adler := Long(1);
+  z.adler := 1;
 
 
-  if (length >= (uInt(1) shl z.state^.wbits)) then
+  if (length >= (1 shl z.state^.wbits)) then
   begin
   begin
     length := (1 shl z.state^.wbits)-1;
     length := (1 shl z.state^.wbits)-1;
     Inc( dictionary, dictLength - length);
     Inc( dictionary, dictLength - length);
@@ -662,14 +662,14 @@ begin
 end;
 end;
 
 
 
 
-function inflateSync(var z : z_stream) : int;
+function inflateSync(var z : z_stream) : integer;
 const
 const
   mark : packed array[0..3] of byte = (0, 0, $ff, $ff);
   mark : packed array[0..3] of byte = (0, 0, $ff, $ff);
 var
 var
-  n : uInt;       { number of bytes to look at }
-  p : pBytef;     { pointer to bytes }
-  m : uInt;       { number of marker bytes found in a row }
-  r, w : uLong;   { temporaries to save total_in and total_out }
+  n : cardinal;       { number of bytes to look at }
+  p : Pbyte;     { pointer to bytes }
+  m : cardinal;       { number of marker bytes found in a row }
+  r, w : cardinal;   { temporaries to save total_in and total_out }
 begin
 begin
   { set up }
   { set up }
   if (z.state = Z_NULL) then
   if (z.state = Z_NULL) then
@@ -706,7 +706,7 @@ begin
   end;
   end;
 
 
   { restore }
   { restore }
-  Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+  Inc(z.total_in, ptrint(p) - ptrint(z.next_in));
   z.next_in := p;
   z.next_in := p;
   z.avail_in := n;
   z.avail_in := n;
   z.state^.sub.marker := m;
   z.state^.sub.marker := m;
@@ -737,7 +737,7 @@ end;
   waiting for these length bytes.
   waiting for these length bytes.
 }
 }
 
 
-function inflateSyncPoint(var z : z_stream) : int;
+function inflateSyncPoint(var z : z_stream) : integer;
 begin
 begin
   if (z.state = Z_NULL) or (z.state^.blocks = Z_NULL) then
   if (z.state = Z_NULL) or (z.state^.blocks = Z_NULL) then
   begin
   begin

+ 14 - 14
packages/base/paszlib/zuncompr.pas

@@ -31,40 +31,40 @@ uses
    buffer, or Z_DATA_ERROR if the input data was corrupted.
    buffer, or Z_DATA_ERROR if the input data was corrupted.
 }
 }
 
 
-function uncompress (dest : pBytef;
-                     var destLen : uLong;
+function uncompress (dest : Pbyte;
+                     var destLen : cardinal;
                      const source : array of byte;
                      const source : array of byte;
-                     sourceLen : uLong) : int;
+                     sourceLen : cardinal) : integer;
 
 
 implementation
 implementation
 
 
-function uncompress (dest : pBytef;
-                     var destLen : uLong;
+function uncompress (dest : Pbyte;
+                     var destLen : cardinal;
                      const source : array of byte;
                      const source : array of byte;
-                     sourceLen : uLong) : int;
+                     sourceLen : cardinal) : integer;
 var
 var
   stream : z_stream;
   stream : z_stream;
-  err : int;
+  err : integer;
 begin
 begin
-  stream.next_in := pBytef(@source);
-  stream.avail_in := uInt(sourceLen);
+  stream.next_in := Pbyte(@source);
+  stream.avail_in := cardinal(sourceLen);
   { Check for source > 64K on 16-bit machine: }
   { Check for source > 64K on 16-bit machine: }
-  if (uLong(stream.avail_in) <> sourceLen) then
+  if (cardinal(stream.avail_in) <> sourceLen) then
   begin
   begin
     uncompress := Z_BUF_ERROR;
     uncompress := Z_BUF_ERROR;
     exit;
     exit;
   end;
   end;
 
 
   stream.next_out := dest;
   stream.next_out := dest;
-  stream.avail_out := uInt(destLen);
-  if (uLong(stream.avail_out) <> destLen) then
+  stream.avail_out := cardinal(destLen);
+  if (cardinal(stream.avail_out) <> destLen) then
   begin
   begin
     uncompress := Z_BUF_ERROR;
     uncompress := Z_BUF_ERROR;
     exit;
     exit;
   end;
   end;
 
 
-  stream.zalloc := NIL;       { alloc_func(0); }
-  stream.zfree := NIL;        { free_func(0); }
+  stream.zalloc := nil;       { alloc_func(0); }
+  stream.zfree := nil;        { free_func(0); }
 
 
   err := inflateInit(stream);
   err := inflateInit(stream);
   if (err <> Z_OK) then
   if (err <> Z_OK) then

+ 29 - 85
packages/base/paszlib/zutil.pas

@@ -9,47 +9,6 @@ interface
 
 
 {$I zconf.inc}
 {$I zconf.inc}
 
 
-{ Type declarations }
-
-type
-  {Byte   = usigned char;  8 bits}
-  Bytef  = byte;
-  charf  = byte;
-
-{$IFDEF FPC}
-  int    = longint;
-{$ELSE}
-  int    = integer;
-{$ENDIF}
-
-  intf   = int;
-{$IFDEF MSDOS}
-  uInt   = Word;
-{$ELSE}
-  {$IFDEF FPC}
-    uInt   = longint;     { 16 bits or more }
-    {$INFO Cardinal}
-  {$ELSE}
-    uInt   = cardinal;     { 16 bits or more }
-  {$ENDIF}
-{$ENDIF}
-  uIntf  = uInt;
-
-  Long   = longint;
-  uLong  = Cardinal;
-  uLongf = uLong;
-
-  voidp  = pointer;
-  voidpf = voidp;
-  pBytef = ^Bytef;
-  pIntf  = ^intf;
-  puIntf = ^uIntf;
-  puLong = ^uLongf;
-
-  ptr2int = uInt;
-{ a pointer to integer casting is used to do pointer arithmetic.
-  ptr2int must be an integer type and sizeof(ptr2int) must be less
-  than sizeof(pointer) - Nomssi }
 
 
 const
 const
   {$IFDEF MAXSEG_64K}
   {$IFDEF MAXSEG_64K}
@@ -59,42 +18,27 @@ const
   {$ENDIF}
   {$ENDIF}
 
 
 type
 type
-  zByteArray = array[0..(MaxMemBlock div SizeOf(Bytef))-1] of Bytef;
+  zByteArray = array[0..(MaxMemBlock div SizeOf(byte))-1] of byte;
   pzByteArray = ^zByteArray;
   pzByteArray = ^zByteArray;
 type
 type
-  zIntfArray = array[0..(MaxMemBlock div SizeOf(Intf))-1] of Intf;
+  zIntfArray = array[0..(MaxMemBlock div SizeOf(byte))-1] of integer;
   pzIntfArray = ^zIntfArray;
   pzIntfArray = ^zIntfArray;
 type
 type
-  zuIntArray = array[0..(MaxMemBlock div SizeOf(uInt))-1] of uInt;
+  zuIntArray = array[0..(MaxMemBlock div SizeOf(cardinal))-1] of cardinal;
   PuIntArray = ^zuIntArray;
   PuIntArray = ^zuIntArray;
 
 
-{ Type declarations - only for deflate }
-
-type
-  uch  = Byte;
-  uchf = uch; { FAR }
-  ush  = Word;
-  ushf = ush;
-  ulg  = LongInt;
-
-  unsigned = uInt;
-
-  pcharf = ^charf;
-  puchf = ^uchf;
-  pushf = ^ushf;
-
 type
 type
   zuchfArray = zByteArray;
   zuchfArray = zByteArray;
   puchfArray = ^zuchfArray;
   puchfArray = ^zuchfArray;
 type
 type
-  zushfArray = array[0..(MaxMemBlock div SizeOf(ushf))-1] of ushf;
+  zushfArray = array[0..(MaxMemBlock div SizeOf(word))-1] of word;
   pushfArray = ^zushfArray;
   pushfArray = ^zushfArray;
 
 
-procedure zmemcpy(destp : pBytef; sourcep : pBytef; len : uInt);
-function zmemcmp(s1p, s2p : pBytef; len : uInt) : int;
-procedure zmemzero(destp : pBytef; len : uInt);
-procedure zcfree(opaque : voidpf; ptr : voidpf);
-function zcalloc (opaque : voidpf; items : uInt; size : uInt) : voidpf;
+procedure zmemcpy(destp : Pbyte; sourcep : Pbyte; len : cardinal);
+function zmemcmp(s1p, s2p : Pbyte; len : cardinal) : integer;
+procedure zmemzero(destp : Pbyte; len : cardinal);
+procedure zcfree(opaque : pointer; ptr : pointer);
+function zcalloc (opaque : pointer; items : cardinal; size : cardinal) : pointer;
 
 
 implementation
 implementation
 
 
@@ -205,7 +149,7 @@ type
     size: Pointer;
     size: Pointer;
   end;
   end;
 type
 type
-  HugePtr = voidpf;
+  HugePtr = pointer;
 
 
 
 
  procedure IncPtr(var p:pointer;count:word);
  procedure IncPtr(var p:pointer;count:word);
@@ -295,7 +239,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure GetMemHuge(var p:HugePtr;memsize:Longint);
+procedure GetMemHuge(var p:HugePtr;memsize:longint);
 const
 const
   blocksize = $FFF0;
   blocksize = $FFF0;
 var
 var
@@ -376,16 +320,16 @@ end;
 
 
 {$ENDIF}
 {$ENDIF}
 
 
-procedure zmemcpy(destp : pBytef; sourcep : pBytef; len : uInt);
+procedure zmemcpy(destp : Pbyte; sourcep : Pbyte; len : cardinal);
 begin
 begin
   Move(sourcep^, destp^, len);
   Move(sourcep^, destp^, len);
 end;
 end;
 
 
-function zmemcmp(s1p, s2p : pBytef; len : uInt) : int;
+function zmemcmp(s1p, s2p : Pbyte; len : cardinal) : integer;
 var
 var
-  j : uInt;
+  j : cardinal;
   source,
   source,
-  dest : pBytef;
+  dest : Pbyte;
 begin
 begin
   source := s1p;
   source := s1p;
   dest := s2p;
   dest := s2p;
@@ -393,7 +337,7 @@ begin
   begin
   begin
     if (source^ <> dest^) then
     if (source^ <> dest^) then
     begin
     begin
-      zmemcmp := 2*Ord(source^ > dest^)-1;
+      zmemcmp := 2*ord(source^ > dest^)-1;
       exit;
       exit;
     end;
     end;
     Inc(source);
     Inc(source);
@@ -402,19 +346,19 @@ begin
   zmemcmp := 0;
   zmemcmp := 0;
 end;
 end;
 
 
-procedure zmemzero(destp : pBytef; len : uInt);
+procedure zmemzero(destp : Pbyte; len : cardinal);
 begin
 begin
   FillChar(destp^, len, 0);
   FillChar(destp^, len, 0);
 end;
 end;
 
 
-procedure zcfree(opaque : voidpf; ptr : voidpf);
+procedure zcfree(opaque : pointer; ptr : pointer);
 {$ifdef Delphi16}
 {$ifdef Delphi16}
 var
 var
   Handle : THandle;
   Handle : THandle;
 {$endif}
 {$endif}
 {$IFDEF FPC}
 {$IFDEF FPC}
 var
 var
-  memsize : uint;
+  memsize : cardinal;
 {$ENDIF}
 {$ENDIF}
 begin
 begin
   {$IFDEF DPMI}
   {$IFDEF DPMI}
@@ -432,9 +376,9 @@ begin
         GlobalFree(Handle);
         GlobalFree(Handle);
         {$else}
         {$else}
           {$IFDEF FPC}
           {$IFDEF FPC}
-          Dec(puIntf(ptr));
-          memsize := puIntf(ptr)^;
-          FreeMem(ptr, memsize+SizeOf(uInt));
+          dec(Pcardinal(ptr));
+          memsize := Pcardinal(ptr)^;
+          FreeMem(ptr, memsize+SizeOf(cardinal));
           {$ELSE}
           {$ELSE}
           FreeMem(ptr);  { Delphi 2,3,4 }
           FreeMem(ptr);  { Delphi 2,3,4 }
           {$ENDIF}
           {$ENDIF}
@@ -444,15 +388,15 @@ begin
   {$ENDIF}
   {$ENDIF}
 end;
 end;
 
 
-function zcalloc (opaque : voidpf; items : uInt; size : uInt) : voidpf;
+function zcalloc (opaque : pointer; items : cardinal; size : cardinal) : pointer;
 var
 var
-  p : voidpf;
-  memsize : uLong;
+  p : pointer;
+  memsize : cardinal;
 {$ifdef Delphi16}
 {$ifdef Delphi16}
   handle : THandle;
   handle : THandle;
 {$endif}
 {$endif}
 begin
 begin
-  memsize := uLong(items) * size;
+  memsize := items * size;
   {$IFDEF DPMI}
   {$IFDEF DPMI}
   p := GlobalAllocPtr(gmem_moveable, memsize);
   p := GlobalAllocPtr(gmem_moveable, memsize);
   {$ELSE}
   {$ELSE}
@@ -467,9 +411,9 @@ begin
         p := GlobalLock(Handle);
         p := GlobalLock(Handle);
         {$else}
         {$else}
           {$IFDEF FPC}
           {$IFDEF FPC}
-          GetMem(p, memsize+SizeOf(uInt));
-          puIntf(p)^:= memsize;
-          Inc(puIntf(p));
+          getmem(p, memsize+sizeOf(cardinal));
+          Pcardinal(p)^:= memsize;
+          inc(Pcardinal(p));
           {$ELSE}
           {$ELSE}
           GetMem(p, memsize);  { Delphi: p := AllocMem(memsize); }
           GetMem(p, memsize);  { Delphi: p := AllocMem(memsize); }
           {$ENDIF}
           {$ENDIF}

Some files were not shown because too many files changed in this diff