Browse Source

* Further cleanup.
* Don't typecast 0 and nil to longint/pointer.
* Don't typecast 0 to char, use #0 instead.
* Use TP define for TP specific code.

git-svn-id: trunk@4808 -

daniel 19 years ago
parent
commit
30078a56dc

+ 8 - 10
packages/base/paszlib/gzio.pas

@@ -164,7 +164,7 @@ begin
 
 
   s^.path := path; { limit to 255 chars }
   s^.path := path; { limit to 255 chars }
 
 
-  s^.mode := chr(0);
+  s^.mode := #0;
   for i:=1 to Length(mode) do begin
   for i:=1 to Length(mode) do begin
     case mode[i] of
     case mode[i] of
       'r'      : s^.mode := 'r';
       'r'      : s^.mode := 'r';
@@ -174,9 +174,9 @@ begin
       'h'      : strategy := Z_HUFFMAN_ONLY;
       'h'      : strategy := Z_HUFFMAN_ONLY;
     end;
     end;
   end;
   end;
-  if (s^.mode=chr(0)) then begin
+  if s^.mode=#0 then begin
     destroy(s);
     destroy(s);
-    gzopen := gzFile(nil);
+    gzopen := nil;
     exit;
     exit;
   end;
   end;
 
 
@@ -305,17 +305,16 @@ end;
 function get_byte (s:gz_streamp) : integer;
 function get_byte (s:gz_streamp) : integer;
 
 
 begin
 begin
-
-  if (s^.z_eof = true) then begin
+  if s^.z_eof then begin
     get_byte := Z_EOF;
     get_byte := Z_EOF;
     exit;
     exit;
   end;
   end;
 
 
-  if (s^.stream.avail_in = 0) then begin
+  if s^.stream.avail_in=0 then begin
     {$I-}
     {$I-}
     blockread (s^.gzfile, s^.inbuf^, Z_BUFSIZE, s^.stream.avail_in);
     blockread (s^.gzfile, s^.inbuf^, Z_BUFSIZE, s^.stream.avail_in);
     {$I+}
     {$I+}
-    if (s^.stream.avail_in = 0) then begin
+    if s^.stream.avail_in=0 then begin
       s^.z_eof := true;
       s^.z_eof := true;
       if (IOResult <> 0) then s^.z_err := Z_ERRNO;
       if (IOResult <> 0) then s^.z_err := Z_ERRNO;
       get_byte := Z_EOF;
       get_byte := Z_EOF;
@@ -327,7 +326,6 @@ begin
   Dec(s^.stream.avail_in);
   Dec(s^.stream.avail_in);
   get_byte := s^.stream.next_in^;
   get_byte := s^.stream.next_in^;
   Inc(s^.stream.next_in);
   Inc(s^.stream.next_in);
-
 end;
 end;
 
 
 
 
@@ -377,7 +375,7 @@ begin
 {$endif}
 {$endif}
   if (c = Z_EOF) then
   if (c = Z_EOF) then
     s^.z_err := Z_DATA_ERROR;
     s^.z_err := Z_DATA_ERROR;
-  GetLong := cardinal(longint(x));
+  GetLong := cardinal(x);
 end;
 end;
 
 
 
 
@@ -712,7 +710,7 @@ begin
       inc (buf);
       inc (buf);
     until (len = 0) or (bytes <> 1) or (gzchar = Chr(13));
     until (len = 0) or (bytes <> 1) or (gzchar = Chr(13));
 
 
-    buf^ := Chr(0);
+    buf^ := #0;
     if (b = buf) and (len > 0) then gzgets := nil else gzgets := b;
     if (b = buf) and (len > 0) then gzgets := nil else gzgets := b;
 
 
 end;
 end;

+ 1 - 1
packages/base/paszlib/infblock.pas

@@ -115,7 +115,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(cardinal(0), Pbyte(NIL), 0);
+    s.check := s.checkfn(cardinal(0), nil, 0);
     z.adler := s.check;
     z.adler := s.check;
   end;
   end;
   {$IFDEF ZLIB_DEBUG}
   {$IFDEF ZLIB_DEBUG}

+ 2 - 2
packages/base/paszlib/trees.pas

@@ -2050,7 +2050,7 @@ begin
   begin
   begin
 {$endif}
 {$endif}
     { Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: }
     { Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: }
-    if (buf = Pchar(0)) then
+    if buf=nil then
       error ('block vanished');
       error ('block vanished');
 
 
     copy_block(buf, cardinal(stored_len), 0); { without header }
     copy_block(buf, cardinal(stored_len), 0); { without header }
@@ -2061,7 +2061,7 @@ begin
 {$endif} { STORED_FILE_OK }
 {$endif} { STORED_FILE_OK }
 
 
 {$ifdef FORCE_STORED}
 {$ifdef FORCE_STORED}
-  if (buf <> pchar(0)) then
+  if buf<>nil then
   begin { force stored block }
   begin { force stored block }
 {$else}
 {$else}
   if (stored_len+4 <= opt_lenb) and (buf <> nil) then
   if (stored_len+4 <= opt_lenb) and (buf <> nil) then

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

@@ -70,7 +70,7 @@ interface
 
 
 { Maximum value for memLevel in deflateInit2 }
 { Maximum value for memLevel in deflateInit2 }
 {$ifdef MAXSEG_64K}
 {$ifdef MAXSEG_64K}
-  {$IFDEF VER70}
+  {$IFDEF TP}
   const
   const
     MAX_MEM_LEVEL = 7;
     MAX_MEM_LEVEL = 7;
     DEF_MEM_LEVEL = MAX_MEM_LEVEL;  { default memLevel }
     DEF_MEM_LEVEL = MAX_MEM_LEVEL;  { default memLevel }
@@ -87,7 +87,7 @@ const
 
 
 { Maximum value for windowBits in deflateInit2 and inflateInit2 }
 { Maximum value for windowBits in deflateInit2 and inflateInit2 }
 const
 const
-{$IFDEF VER70}
+{$IFDEF TP}
   MAX_WBITS = 14; { 32K LZ77 window }
   MAX_WBITS = 14; { 32K LZ77 window }
 {$ELSE}
 {$ELSE}
   MAX_WBITS = 15; { 32K LZ77 window }
   MAX_WBITS = 15; { 32K LZ77 window }

+ 1 - 0
packages/base/paszlib/zconf.inc

@@ -7,6 +7,7 @@
 
 
 {- $DEFINE MAXSEG_64K}
 {- $DEFINE MAXSEG_64K}
 {$IFDEF VER70}
 {$IFDEF VER70}
+  {$DEFINE TP}
   {$DEFINE MAXSEG_64K}
   {$DEFINE MAXSEG_64K}
 {$ENDIF}
 {$ENDIF}
 {$IFNDEF WIN32}
 {$IFNDEF WIN32}