Procházet zdrojové kódy

+ New const MaxzbaseInt, set to maxlongint for FPC
to avoid range check errors within code if compiled
with range check enabled.

git-svn-id: trunk@17805 -

pierre před 14 roky
rodič
revize
0c210a9df3
2 změnil soubory, kde provedl 12 přidání a 10 odebrání
  1. 3 3
      packages/paszlib/src/trees.pas
  2. 9 7
      packages/paszlib/src/zbase.pas

+ 3 - 3
packages/paszlib/src/trees.pas

@@ -106,7 +106,7 @@ type
   dtree_type = array[0..2*D_CODES+1-1] of ct_data;  { distance tree }
   dtree_type = array[0..2*D_CODES+1-1] of ct_data;  { distance tree }
   htree_type = array[0..2*BL_CODES+1-1] of ct_data;  { Huffman tree for bit lengths }
   htree_type = array[0..2*BL_CODES+1-1] of ct_data;  { Huffman tree for bit lengths }
   { generic tree type }
   { generic tree type }
-  tree_type = array[0..(maxint div SizeOf(ct_data))-1] of ct_data;
+  tree_type = array[0..(maxzbaseint div SizeOf(ct_data))-1] of ct_data;
 
 
   tree_ptr = ^ct_data;
   tree_ptr = ^ct_data;
   ltree_ptr = ^ltree_type;
   ltree_ptr = ^ltree_type;
@@ -139,7 +139,7 @@ type
 
 
   pPosf = ^Posf;
   pPosf = ^Posf;
 
 
-  zPosfArray = array[0..(maxint div SizeOf(Posf))-1] of Posf;
+  zPosfArray = array[0..(maxzbaseint div SizeOf(Posf))-1] of Posf;
   pzPosfArray = ^zPosfArray;
   pzPosfArray = ^zPosfArray;
 
 
 { A Pos is an index in the character window. We use short instead of integer to
 { A Pos is an index in the character window. We use short instead of integer to
@@ -509,7 +509,7 @@ const
 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
 );
 );
 
 
-  
+
 { First normalized length for each code (0 = MIN_MATCH) }
 { First normalized length for each code (0 = MIN_MATCH) }
   base_length : array[0..LENGTH_CODES-1] of integer = (
   base_length : array[0..LENGTH_CODES-1] of integer = (
 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,

+ 9 - 7
packages/paszlib/src/zbase.pas

@@ -88,9 +88,11 @@ const
 { Maximum value for windowBits in deflateInit2 and inflateInit2 }
 { Maximum value for windowBits in deflateInit2 and inflateInit2 }
 const
 const
 {$IFDEF TP}
 {$IFDEF TP}
-  MAX_WBITS = 14; { 32K LZ77 window }
+  MAX_WBITS = 14; { 16K LZ77 window }
+  maxzbaseint = maxint;
 {$ELSE}
 {$ELSE}
   MAX_WBITS = 15; { 32K LZ77 window }
   MAX_WBITS = 15; { 32K LZ77 window }
+  maxzbaseint = maxlongint;
 {$ENDIF}
 {$ENDIF}
 
 
 { default windowBits for decompression. MAX_WBITS is for compression only }
 { default windowBits for decompression. MAX_WBITS is for compression only }
@@ -102,10 +104,10 @@ type  Pbytearray=^Tbytearray;
       Pwordarray=^Twordarray;
       Pwordarray=^Twordarray;
       Pcardinalarray=^Tcardinalarray;
       Pcardinalarray=^Tcardinalarray;
 
 
-      Tbytearray = array [0..maxint div sizeof(byte)-1] of byte;
-      Twordarray = array [0..maxint div sizeof(word)-1] of word;
-      Tintegerarray = array [0..maxint div sizeof(integer)-1] of integer;
-      Tcardinalarray = array [0..maxint div sizeof(cardinal)-1] of cardinal;
+      Tbytearray = array [0..maxzbaseint div sizeof(byte)-1] of byte;
+      Twordarray = array [0..maxzbaseint div sizeof(word)-1] of word;
+      Tintegerarray = array [0..maxzbaseint div sizeof(integer)-1] of integer;
+      Tcardinalarray = array [0..maxzbaseint div sizeof(cardinal)-1] of cardinal;
 
 
 
 
 { The memory requirements for deflate are (in bytes):
 { The memory requirements for deflate are (in bytes):
@@ -136,7 +138,7 @@ type
   End;
   End;
 
 
 type
 type
-  huft_field = Array[0..(maxint div SizeOf(inflate_huft))-1] of inflate_huft;
+  huft_field = Array[0..(maxzbaseint div SizeOf(inflate_huft))-1] of inflate_huft;
   huft_ptr = ^huft_field;
   huft_ptr = ^huft_field;
 type
 type
   ppInflate_huft = ^pInflate_huft;
   ppInflate_huft = ^pInflate_huft;
@@ -500,4 +502,4 @@ begin
     WriteLn(x);
     WriteLn(x);
 end;
 end;
 
 
-end.
+end.