Prechádzať zdrojové kódy

* patch by alexvin to replace $ifopt by $push/$pop, resolves #20332

git-svn-id: trunk@19239 -
florian 14 rokov pred
rodič
commit
4868b09844

+ 2 - 7
compiler/aoptobj.pas

@@ -884,10 +884,8 @@ Unit AoptObj;
       end;
 
 
-{$ifopt r+}
-{$define rangewason}
+{$push}
 {$r-}
-{$endif}
     function tAOptObj.getlabelwithsym(sym: tasmlabel): tai;
       begin
         if (int64(sym.labelnr) >= int64(labelinfo^.lowlabel)) and
@@ -896,10 +894,7 @@ Unit AoptObj;
         else
           getlabelwithsym := nil;
       end;
-{$ifdef rangewason}
-{$r+}
-{$undef rangewason}
-{$endif}
+{$pop}
 
     function TAOptObj.GetFinalDestination(hp: taicpu; level: longint): boolean;
       {traces sucessive jumps to their final destination and sets it, e.g.

+ 4 - 30
compiler/cgobj.pas

@@ -1228,15 +1228,9 @@ implementation
                        some generic implementations
 ****************************************************************************}
 
-{$ifopt r+}
-{$define rangeon}
+{$push}
 {$r-}
-{$endif}
-
-{$ifopt q+}
-{$define overflowon}
 {$q-}
-{$endif}
 
    procedure tcg.a_load_subsetreg_reg(list : TAsmList; subsetsize, tosize: tcgsize; const sreg: tsubsetregister; destreg: tregister);
      var
@@ -2113,15 +2107,7 @@ implementation
       end;
 
 
-{$ifdef rangeon}
-{$r+}
-{$undef rangeon}
-{$endif}
-
-{$ifdef overflowon}
-{$q+}
-{$undef overflowon}
-{$endif}
+{$pop}
 
     { generic bit address calculation routines }
 
@@ -3790,14 +3776,9 @@ implementation
               { only optimize away if all bit patterns which fit in fromsize }
               { are valid for the todef                                      }
               begin
-{$ifopt Q+}
-{$define overflowon}
+{$push}
 {$Q-}
-{$endif}
-{$ifopt R+}
-{$define rangeon}
 {$R-}
-{$endif}
                 if to_signed then
                   begin
                     { calculation of the low/high ranges must not overflow 64 bit
@@ -3816,14 +3797,7 @@ implementation
                        (qword(hto) = (qword(-1) >> (64-(tosize * 8))) ) then
                       exit
                   end;
-{$ifdef overflowon}
-{$Q+}
-{$undef overflowon}
-{$endif}
-{$ifdef rangeon}
-{$R+}
-{$undef rangeon}
-{$endif}
+{$pop}
               end
           end;
 

+ 2 - 5
compiler/constexp.pas

@@ -32,9 +32,6 @@ interface
   {$R-}
 {$endif}
 
-{$ifopt q+}
-  {$define ena_q}
-{$endif}
 
 type  Tconstexprint=record
         overflow:boolean;
@@ -165,9 +162,9 @@ begin
 
   {Try if the result fits in an int64.}
   if (a.signed) and (a.svalue<0) then
-    {$Q-}
+    {$push}{$Q-}
     sspace:=qword(high(int64))+qword(-a.svalue)
-    {$ifdef ena_q}{$Q+}{$endif}
+    {$pop}
   else if not a.signed and (a.uvalue>qword(high(int64))) then
     goto try_qword
   else

+ 4 - 5
compiler/htypechk.pas

@@ -2241,13 +2241,12 @@ implementation
         cdoptions : tcompare_defs_options;
         n : tnode;
 
-    {$ifopt r+}{$define ena_r}{$r-}{$endif}
-    {$ifopt q+}{$define ena_q}{$q-}{$endif}
+    {$push}
+    {$r-}
+    {$q-}
       const
         inf=1.0/0.0;
-    {$ifdef ena_r}{$r+}{$endif}
-    {$ifdef ena_q}{$q+}{$endif}
-
+    {$pop}
       begin
         cdoptions:=[cdo_check_operator];
         if FAllowVariant then

+ 2 - 7
compiler/i386/daopt386.pas

@@ -2791,10 +2791,8 @@ begin
     pass_generate_code := false;
 end;
 
-{$ifopt r+}
-{$define rangewason}
+{$push}
 {$r-}
-{$endif}
 function tdfaobj.getlabelwithsym(sym: tasmlabel): tai;
 begin
   if (sym.labelnr >= lolab) and
@@ -2803,10 +2801,7 @@ begin
   else
     getlabelwithsym := nil;
 end;
-{$ifdef rangewason}
-{$r+}
-{$undef rangewason}
-{$endif}
+{$pop}
 
 
 procedure tdfaobj.clear;

+ 2 - 16
compiler/powerpc/nppcmat.pas

@@ -61,15 +61,9 @@ implementation
       cpubase,
       ncgutil,cgcpu;
 
-{$ifopt r+}
+{$push}
 {$r-}
-{$define rangeon}
-{$endif}
-
-{$ifopt q+}
 {$q-}
-{$define overflowon}
-{$endif}
 { helper functions }
 procedure getmagic_unsigned32(d : dword; out magic_m : dword; out magic_add : boolean; out magic_shift : dword);
 var
@@ -153,15 +147,7 @@ begin
     magic_s := p - 32; { resulting shift }
 end;
 
-{$ifdef rangeon}
-{$r+}
-{$undef rangeon}
-{$endif}
-
-{$ifdef overflowon}
-{$q+}
-{$undef overflowon}
-{$endif}
+{$pop}
 
 {*****************************************************************************
                              TPPCMODDIVNODE

+ 2 - 16
compiler/powerpc64/cgcpu.pas

@@ -175,15 +175,9 @@ begin
   end;
 end;
 
-{$ifopt r+}
+{$push}
 {$r-}
-{$define rangeon}
-{$endif}
-
-{$ifopt q+}
 {$q-}
-{$define overflowon}
-{$endif}
 { helper function which calculate "magic" values for replacement of unsigned
  division by constant operation by multiplication. See the PowerPC compiler
  developer manual for more information }
@@ -275,15 +269,7 @@ begin
   end;
   magic_s := p - N; { resulting shift }
 end;
-{$ifdef rangeon}
-{$r+}
-{$undef rangeon}
-{$endif}
-
-{$ifdef overflowon}
-{$q+}
-{$undef overflowon}
-{$endif}
+{$pop}
 
 { finds positive and negative powers of two of the given value, returning the
  power and whether it's a negative power or not in addition to the actual result

+ 2 - 17
compiler/ptconst.pas

@@ -72,15 +72,9 @@ implementation
       end;
 
 
-{$ifopt r+}
-{$define rangeon}
+{$push}
 {$r-}
-{$endif}
-
-{$ifopt q+}
-{$define overflowon}
 {$q-}
-{$endif}
     { (values between quotes below refer to fields of bp; fields not         }
     {  mentioned are unused by this routine)                                 }
     { bitpacks "value" as bitpacked value of bitsize "packedbitsize" into    }
@@ -113,16 +107,7 @@ implementation
         inc(bp.curbitoffset,bp.packedbitsize);
       end;
 
-{$ifdef rangeon}
-{$r+}
-{$undef rangeon}
-{$endif}
-
-{$ifdef overflowon}
-{$q+}
-{$undef overflowon}
-{$endif}
-
+{$pop}
 
     procedure flush_packed_value(list: tasmlist; var bp: tbitpackedval);
       var

+ 2 - 7
packages/chm/src/chmbase.pas

@@ -171,10 +171,7 @@ var
 begin
   bit := 28; //((sizeof(dWord)*8)div 7)*7; // = 28
   buf := @Value;
-  {$undef rangeon}
-  {$ifopt R+}
-     {$define rangeon}
-  {$endif}
+  {$push}
   {$R-}
   while True do begin
     mask := $7f shl bit;
@@ -190,9 +187,7 @@ begin
     Inc(TheEnd);
   end;
 
-  {$ifdef rangeon}
-    {$R+}
-  {$endif}
+  {$pop}
   
   buf := @Value;
   Result := TheEnd+1;

+ 2 - 1
packages/chm/src/itolitlsreader.pas

@@ -372,6 +372,7 @@ begin
   StreamPos:=HeaderSectionTable[1].OffSet;
   fStream.Read(IFCM, SizeOf(IFCM));
   StartOfChunks := fstream.Position;
+  {$push}
   {$R-}
   ChunkIndex:=PostHeader.ListChunkInfo.TopAOLIChunkIndex;
   if ChunkIndex = -1 then
@@ -423,7 +424,7 @@ begin
 
 
   end;
-  {$R+}
+  {$pop}
   Chunk.Free;
   Result := fCachedEntry.DecompressedLength;
 

+ 6 - 6
packages/fcl-base/examples/poolmm1.pp

@@ -40,9 +40,9 @@ begin
   AMyRecord:=PMyRecord(FFirstFree);
   PMyRecord(FFirstFree):=AMyRecord^.Next;
   Dispose(AMyRecord);
-  {$R-}
+  {$push}{$R-}
   inc(FFreedCount);
-  {$IfDef RangeChecksOn}{$R+}{$Endif}
+  {$pop}
 end;
 
 procedure TMyRecordMemManager.DisposeMyRecord(AMyRecord: PMyRecord);
@@ -56,9 +56,9 @@ begin
   end else begin
     // free list full -> free the item
     Dispose(AMyRecord);
-    {$R-}
+    {$push}{$R-}
     inc(FFreedCount);
-    {$IfDef RangeChecksOn}{$R+}{$Endif}
+    {$pop}
   end;
   dec(FCount);
 end;
@@ -73,9 +73,9 @@ begin
   end else begin
     // free list empty -> create new item
     New(Result);
-    {$R-}
+    {$push}{$R-}
     inc(FAllocatedCount);
-    {$IfDef RangeChecksOn}{$R+}{$Endif}
+    {$pop}
   end;
   FillChar(Result^, SizeOf(TMyRecord), 0);
   inc(FCount);

+ 4 - 4
packages/fcl-base/src/pooledmm.pp

@@ -133,9 +133,9 @@ begin
     end else begin
       // free list full -> free the ANode
       //FreeItem(AnItem);
-      {$R-}
+      {$push}{$R-}
       inc(FFreedCount);
-      {$IfDef RangeChecksOn}{$R+}{$Endif}
+      {$pop}
     end;
     dec(FCount);
   end;
@@ -152,9 +152,9 @@ begin
   end else begin
     // free list empty -> create new node
     New(Result);
-    {$R-}
+    {$push}{$R-}
     inc(FAllocatedCount);
-    {$IfDef RangeChecksOn}{$R+}{$Endif}
+    {$pop}
   end;
   inc(FCount);
 end;

+ 17 - 10
packages/fcl-db/src/sqldb/interbase/ibconnection.pp

@@ -551,6 +551,7 @@ begin
         CheckError('PrepareStatement', Status);
       if in_SQLDA^.SQLD > in_SQLDA^.SQLN then
         DatabaseError(SParameterCountIncorrect,self);
+      {$push}
       {$R-}
       for x := 0 to in_SQLDA^.SQLD - 1 do with in_SQLDA^.SQLVar[x] do
         begin
@@ -565,7 +566,7 @@ begin
         sqltype := sqltype or 1;
         new(sqlind);
         end;
-      {$R+}
+      {$pop}
       end
     else
       AllocSQLDA(in_SQLDA,0);
@@ -594,6 +595,7 @@ begin
         if isc_dsql_describe(@Status[0], @Statement, 1, SQLDA) <> 0 then
           CheckError('PrepareSelect', Status);
         end;
+      {$push}
       {$R-}
       for x := 0 to SQLDA^.SQLD - 1 do with SQLDA^.SQLVar[x] do
         begin
@@ -603,7 +605,7 @@ begin
           SQLData := AllocMem(SQLDA^.SQLVar[x].SQLLen);
         if (SQLType and 1) = 1 then New(SQLInd);
         end;
-      {$R+}
+      {$pop}
       end;
     FPrepared := True;
     end;
@@ -627,6 +629,7 @@ procedure TIBConnection.FreeSQLDABuffer(var aSQLDA : PXSQLDA);
 var x : Smallint;
 
 begin
+{$push}
 {$R-}
   if assigned(aSQLDA) then
     for x := 0 to aSQLDA^.SQLN - 1 do
@@ -639,7 +642,7 @@ begin
         end
         
       end;
-{$R+}
+{$pop}
 end;
 
 function TIBConnection.IsDialectStored: boolean;
@@ -683,6 +686,7 @@ var
   FD        : TFieldDef;
 
 begin
+  {$push}
   {$R-}
   with cursor as TIBCursor do
     begin
@@ -705,7 +709,7 @@ begin
       FieldBinding[FD.FieldNo-1] := x;
       end;
     end;
-  {$R+}
+  {$pop}
 end;
 
 function TIBConnection.GetHandle: pointer;
@@ -745,7 +749,8 @@ var ParNr,SQLVarNr : integer;
   procedure SetBlobParam;
   
   begin
-{$R-}
+    {$push}
+    {$R-}
     with cursor as TIBCursor do
       begin
       TransactionHandle := aTransation.Handle;
@@ -772,7 +777,7 @@ var ParNr,SQLVarNr : integer;
         CheckError('TIBConnection.CreateBlobStream isc_close_blob', FStatus);
       Move(blobId, in_sqlda^.SQLvar[SQLVarNr].SQLData^, in_SQLDA^.SQLVar[SQLVarNr].SQLLen);
       end;
-{$R+}
+      {$pop}
   end;
 
 var
@@ -782,7 +787,8 @@ var
   d : double;
   
 begin
-{$R-}
+  {$push}
+  {$R-}
   with cursor as TIBCursor do for SQLVarNr := 0 to High(ParamBinding){AParams.count-1} do
     begin
     ParNr := ParamBinding[SQLVarNr];
@@ -858,7 +864,7 @@ begin
       end {case}
       end;
     end;
-{$R+}
+{$pop}
 end;
 
 function TIBConnection.LoadField(cursor : TSQLCursor;FieldDef : TfieldDef;buffer : pointer; out CreateBlob : boolean) : boolean;
@@ -877,7 +883,8 @@ begin
   CreateBlob := False;
   with cursor as TIBCursor do
     begin
-{$R-}
+    {$push}
+    {$R-}
     x := FieldBinding[FieldDef.FieldNo-1];
 
     // Joost, 5 jan 2006: I disabled the following, since it's useful for
@@ -984,7 +991,7 @@ begin
           end
       end;  { case }
       end; { if/else }
-{$R+}
+      {$pop}
     end; { with cursor }
 end;
 

+ 2 - 2
packages/fcl-image/src/fpreadxwd.pas

@@ -65,7 +65,7 @@ implementation
 //
 // Copied from LCLProc unit
 //==============================================================================
-{$R-}
+{$push}{$R-}
 function BEtoN(const AValue: DWord): DWord;
 begin
   {$IFDEF ENDIAN_BIG}
@@ -77,7 +77,7 @@ begin
            or (AValue shr 24);
   {$ENDIF}
 end;
-{$R+}
+{$pop}
 
 constructor TFPReaderXWD.create;
 begin

+ 8 - 56
packages/graph/src/go32v2/graph.pp

@@ -2187,23 +2187,11 @@ End;
     ScrOfs:=y*ScrWidth+x div 8 + VideoOfs;
     HLength:=x2 div 8-x div 8;
     LMask:=$ff shr (x and 7);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
     RMask:=$ff shl (7-(x2 and 7));
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
     if HLength=0 then
       LMask:=LMask and RMask;
     If CurrentWriteMode <> NotPut Then
@@ -2224,23 +2212,11 @@ End;
     end;
 
     PortW[$3ce]:=(LMask shl 8) or 8;
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
     Mem[SegA000:ScrOfs]:=Mem[SegA000:ScrOfs]+1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
     {Port[$3ce]:=8;}{not needed, the register is already selected}
     if HLength>0 then
       begin
@@ -2257,23 +2233,11 @@ End;
               ScrOfs:=ScrOfs+HLength;
            end;
          Port[$3cf]:=RMask;
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
          Mem[Sega000:ScrOfs]:=Mem[SegA000:ScrOfs]+1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
       end;
     { clean up }
     {Port[$3cf]:=0;}{not needed, the register is reset by the next operation:}
@@ -2328,23 +2292,11 @@ End;
     end;
     for i:=y to y2 do
       begin
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
          Mem[SegA000:ScrOfs]:=Mem[Sega000:ScrOfs]+1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
          ScrOfs:=ScrOfs+ScrWidth;
       end;
     { clean up }

+ 6 - 42
packages/graph/src/go32v2/vesa.inc

@@ -1620,23 +1620,11 @@ end;
     SetWriteBank(smallint(ScrOfs shr 16));
     HLength:=x2 div 8-x div 8;
     LMask:=$ff shr (x and 7);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
     RMask:=$ff shl (7-(x2 and 7));
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
     if HLength=0 then
       LMask:=LMask and RMask;
     If CurrentWriteMode <> NotPut Then
@@ -1657,23 +1645,11 @@ end;
     end;
 
     PortW[$3ce]:=(LMask shl 8) or 8;
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
     Mem[WinWriteSeg:word(ScrOfs)]:=Mem[WinReadSeg:word(ScrOfs)]+1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
     {Port[$3ce]:=8;}{not needed, the register is already selected}
     if HLength>0 then
       begin
@@ -1699,23 +1675,11 @@ end;
          SetReadBank(smallint(ScrOfs shr 16));
          SetWriteBank(smallint(ScrOfs shr 16));
          Port[$3cf]:=RMask;
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
          Mem[WinWriteSeg:word(ScrOfs)]:=Mem[WinReadSeg:word(ScrOfs)]+1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
       end;
     { clean up }
     {Port[$3cf]:=0;}{not needed, the register is reset by the next operation:}

+ 2 - 6
packages/graph/src/inc/fills.inc

@@ -31,10 +31,8 @@ end;
 procedure fillpoly(numpoints : Word; var polypoints);
 
 { disable range check mode }
-{$ifopt R+}
-{$define OPT_R_WAS_ON}
+{$push}
 {$R-}
-{$endif}
 type
   pedge = ^tedge;
   tedge = packed record
@@ -539,6 +537,4 @@ var
   End;
 
 { restore previous range check mode }
-{$ifdef OPT_R_WAS_ON}
-{$R+}
-{$endif}
+{$pop}

+ 2 - 6
packages/graph/src/inc/gtext.inc

@@ -208,10 +208,8 @@ end;
        { bit 0..7 only which are considered }
        { signed values.                     }
 { disable range check mode }
-{$ifopt R+}
-{$define OPT_R_WAS_ON}
+{$push}
 {$R-}
-{$endif}
        b1:=b1 and $7f;
        b2:=b2 and $7f;
        { Now if the MSB of these values are set }
@@ -222,9 +220,7 @@ end;
        x:=smallint(b1);
        y:=smallint(b2);
 { restore previous range check mode }
-{$ifdef OPT_R_WAS_ON}
-{$R+}
-{$endif}
+{$pop}
      end;
 
 

+ 8 - 56
packages/graph/src/unix/graph16.inc

@@ -267,23 +267,11 @@ begin
   ScrOfs := y * ScrWidth + x div 8;
   HLength := x2 div 8 - x div 8;
   LMask := $ff shr (x and 7);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
   RMask:=$ff shl (7 - (x2 and 7));
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
   if HLength=0 then
     LMask:=LMask and RMask;
   WritePortB($3ce, 0);
@@ -308,23 +296,11 @@ begin
 
   WritePortB($3ce, 8);
   WritePortB($3cf, LMask);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
   VidMem^[ScrOfs] := VidMem^[ScrOfs] + 1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
   if HLength>0 then
   begin
     Dec(HLength);
@@ -337,23 +313,11 @@ begin
     end else
       WritePortB($3ce, 8);
     WritePortB($3cf, RMask);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
     VidMem^[ScrOfs] := VidMem^[ScrOfs] + 1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
   end;
 end;
 
@@ -405,23 +369,11 @@ begin
   end;
   for i:=y to y2 do
   begin
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
-{$endif}
     VidMem^[ScrOfs]:=VidMem^[ScrOfs]+1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
     Inc(ScrOfs, ScrWidth);
   end;
 end;

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

@@ -752,8 +752,9 @@ begin
   { If not enough room in bi_buf, use (valid) bits from bi_buf and
     (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
     unused bits in value. }
-  {$IFOPT Q+} {$Q-} {$DEFINE NoOverflowCheck} {$ENDIF}
-  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+  {$PUSH}
+  {$Q-}
+  {$R-}
   if (s.bi_valid > integer(Buf_size) - length) then
   begin
     s.bi_buf := s.bi_buf or integer(value shl s.bi_valid);
@@ -771,8 +772,7 @@ begin
     s.bi_buf := s.bi_buf or integer(value shl s.bi_valid);
     inc(s.bi_valid, length);
   end;
-  {$IFDEF NoOverflowCheck} {$Q+} {$UNDEF NoOverflowCheck} {$ENDIF}
-  {$IFDEF NoRangeCheck} {$Q+} {$UNDEF NoRangeCheck} {$ENDIF}
+  {$POP}
 end;
 
 {$else} { !ZLIB_DEBUG }

+ 8 - 8
packages/paszlib/src/zdeflate.pas

@@ -1304,11 +1304,11 @@ distances are limited to MAX_DIST instead of WSIZE. }
 {$ifdef DO_UNALIGNED_OK}
         { This code assumes sizeof(cardinal short) = 2. Do not use
           UNALIGNED_OK if your compiler uses a different size. }
-  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+  {$PUSH} {$R-}
         if (match[best_len-1]<>scan_end) or
            (match^ <> scan_start) then
           goto nextstep; {continue;}
-  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+  {$POP}
 
         { It is not necessary to compare scan[2] and match[2] since they are
           always equal when the other bytes match, given that the hash keys
@@ -1334,11 +1334,11 @@ distances are limited to MAX_DIST instead of WSIZE. }
 
         { Here, scan <= window+strstart+257 }
         {$IFDEF ZLIB_DEBUG}
-        {$ifopt R+} {$define RangeCheck} {$endif} {$R-}
+        {$PUSH} {$R-}
         Assert(ptruint(scan) <=
                ptruint(@(s.window^[cardinal(s.window_size-1)])),
                'wild scan');
-        {$ifdef RangeCheck} {$R+} {$undef RangeCheck} {$endif}
+        {$POP}
         {$ENDIF}
         if scan^=match^ then
           inc(scan);
@@ -1349,12 +1349,12 @@ distances are limited to MAX_DIST instead of WSIZE. }
 
 {$else} { UNALIGNED_OK }
 
-  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+  {$PUSH} {$R-}
         if (Pbytearray(match)^[best_len]   <> scan_end) or
            (Pbytearray(match)^[best_len-1] <> scan_end1) or
            (match^ <> scan^) then
           goto nextstep; {continue;}
-  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+  {$POP}
         inc(match);
         if (match^ <> Pbytearray(scan)^[1]) then
           goto nextstep; {continue;}
@@ -1402,14 +1402,14 @@ distances are limited to MAX_DIST instead of WSIZE. }
             best_len := len;
             if (len >= nice_match) then
               break;
-  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+  {$PUSH} {$R-}
 {$ifdef UNALIGNED_OK}
             scan_end   := Pbytearray(scan)^[best_len-1];
 {$else}
             scan_end1  := Pbytearray(scan)^[best_len-1];
             scan_end   := Pbytearray(scan)^[best_len];
 {$endif}
-  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+  {$POP}
         end;
     nextstep:
       cur_match := prev^[cur_match and wmask];