瀏覽代碼

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

git-svn-id: trunk@19239 -
florian 14 年之前
父節點
當前提交
4868b09844

+ 2 - 7
compiler/aoptobj.pas

@@ -884,10 +884,8 @@ Unit AoptObj;
       end;
       end;
 
 
 
 
-{$ifopt r+}
-{$define rangewason}
+{$push}
 {$r-}
 {$r-}
-{$endif}
     function tAOptObj.getlabelwithsym(sym: tasmlabel): tai;
     function tAOptObj.getlabelwithsym(sym: tasmlabel): tai;
       begin
       begin
         if (int64(sym.labelnr) >= int64(labelinfo^.lowlabel)) and
         if (int64(sym.labelnr) >= int64(labelinfo^.lowlabel)) and
@@ -896,10 +894,7 @@ Unit AoptObj;
         else
         else
           getlabelwithsym := nil;
           getlabelwithsym := nil;
       end;
       end;
-{$ifdef rangewason}
-{$r+}
-{$undef rangewason}
-{$endif}
+{$pop}
 
 
     function TAOptObj.GetFinalDestination(hp: taicpu; level: longint): boolean;
     function TAOptObj.GetFinalDestination(hp: taicpu; level: longint): boolean;
       {traces sucessive jumps to their final destination and sets it, e.g.
       {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
                        some generic implementations
 ****************************************************************************}
 ****************************************************************************}
 
 
-{$ifopt r+}
-{$define rangeon}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-
-{$ifopt q+}
-{$define overflowon}
 {$q-}
 {$q-}
-{$endif}
 
 
    procedure tcg.a_load_subsetreg_reg(list : TAsmList; subsetsize, tosize: tcgsize; const sreg: tsubsetregister; destreg: tregister);
    procedure tcg.a_load_subsetreg_reg(list : TAsmList; subsetsize, tosize: tcgsize; const sreg: tsubsetregister; destreg: tregister);
      var
      var
@@ -2113,15 +2107,7 @@ implementation
       end;
       end;
 
 
 
 
-{$ifdef rangeon}
-{$r+}
-{$undef rangeon}
-{$endif}
-
-{$ifdef overflowon}
-{$q+}
-{$undef overflowon}
-{$endif}
+{$pop}
 
 
     { generic bit address calculation routines }
     { generic bit address calculation routines }
 
 
@@ -3790,14 +3776,9 @@ implementation
               { only optimize away if all bit patterns which fit in fromsize }
               { only optimize away if all bit patterns which fit in fromsize }
               { are valid for the todef                                      }
               { are valid for the todef                                      }
               begin
               begin
-{$ifopt Q+}
-{$define overflowon}
+{$push}
 {$Q-}
 {$Q-}
-{$endif}
-{$ifopt R+}
-{$define rangeon}
 {$R-}
 {$R-}
-{$endif}
                 if to_signed then
                 if to_signed then
                   begin
                   begin
                     { calculation of the low/high ranges must not overflow 64 bit
                     { calculation of the low/high ranges must not overflow 64 bit
@@ -3816,14 +3797,7 @@ implementation
                        (qword(hto) = (qword(-1) >> (64-(tosize * 8))) ) then
                        (qword(hto) = (qword(-1) >> (64-(tosize * 8))) ) then
                       exit
                       exit
                   end;
                   end;
-{$ifdef overflowon}
-{$Q+}
-{$undef overflowon}
-{$endif}
-{$ifdef rangeon}
-{$R+}
-{$undef rangeon}
-{$endif}
+{$pop}
               end
               end
           end;
           end;
 
 

+ 2 - 5
compiler/constexp.pas

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

+ 4 - 5
compiler/htypechk.pas

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

+ 2 - 7
compiler/i386/daopt386.pas

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

+ 2 - 16
compiler/powerpc/nppcmat.pas

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

+ 2 - 16
compiler/powerpc64/cgcpu.pas

@@ -175,15 +175,9 @@ begin
   end;
   end;
 end;
 end;
 
 
-{$ifopt r+}
+{$push}
 {$r-}
 {$r-}
-{$define rangeon}
-{$endif}
-
-{$ifopt q+}
 {$q-}
 {$q-}
-{$define overflowon}
-{$endif}
 { helper function which calculate "magic" values for replacement of unsigned
 { helper function which calculate "magic" values for replacement of unsigned
  division by constant operation by multiplication. See the PowerPC compiler
  division by constant operation by multiplication. See the PowerPC compiler
  developer manual for more information }
  developer manual for more information }
@@ -275,15 +269,7 @@ begin
   end;
   end;
   magic_s := p - N; { resulting shift }
   magic_s := p - N; { resulting shift }
 end;
 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
 { 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
  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;
       end;
 
 
 
 
-{$ifopt r+}
-{$define rangeon}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-
-{$ifopt q+}
-{$define overflowon}
 {$q-}
 {$q-}
-{$endif}
     { (values between quotes below refer to fields of bp; fields not         }
     { (values between quotes below refer to fields of bp; fields not         }
     {  mentioned are unused by this routine)                                 }
     {  mentioned are unused by this routine)                                 }
     { bitpacks "value" as bitpacked value of bitsize "packedbitsize" into    }
     { bitpacks "value" as bitpacked value of bitsize "packedbitsize" into    }
@@ -113,16 +107,7 @@ implementation
         inc(bp.curbitoffset,bp.packedbitsize);
         inc(bp.curbitoffset,bp.packedbitsize);
       end;
       end;
 
 
-{$ifdef rangeon}
-{$r+}
-{$undef rangeon}
-{$endif}
-
-{$ifdef overflowon}
-{$q+}
-{$undef overflowon}
-{$endif}
-
+{$pop}
 
 
     procedure flush_packed_value(list: tasmlist; var bp: tbitpackedval);
     procedure flush_packed_value(list: tasmlist; var bp: tbitpackedval);
       var
       var

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -1620,23 +1620,11 @@ end;
     SetWriteBank(smallint(ScrOfs shr 16));
     SetWriteBank(smallint(ScrOfs shr 16));
     HLength:=x2 div 8-x div 8;
     HLength:=x2 div 8-x div 8;
     LMask:=$ff shr (x and 7);
     LMask:=$ff shr (x and 7);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
 {$q-}
-{$endif}
     RMask:=$ff shl (7-(x2 and 7));
     RMask:=$ff shl (7-(x2 and 7));
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
     if HLength=0 then
     if HLength=0 then
       LMask:=LMask and RMask;
       LMask:=LMask and RMask;
     If CurrentWriteMode <> NotPut Then
     If CurrentWriteMode <> NotPut Then
@@ -1657,23 +1645,11 @@ end;
     end;
     end;
 
 
     PortW[$3ce]:=(LMask shl 8) or 8;
     PortW[$3ce]:=(LMask shl 8) or 8;
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
 {$q-}
-{$endif}
     Mem[WinWriteSeg:word(ScrOfs)]:=Mem[WinReadSeg:word(ScrOfs)]+1;
     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}
     {Port[$3ce]:=8;}{not needed, the register is already selected}
     if HLength>0 then
     if HLength>0 then
       begin
       begin
@@ -1699,23 +1675,11 @@ end;
          SetReadBank(smallint(ScrOfs shr 16));
          SetReadBank(smallint(ScrOfs shr 16));
          SetWriteBank(smallint(ScrOfs shr 16));
          SetWriteBank(smallint(ScrOfs shr 16));
          Port[$3cf]:=RMask;
          Port[$3cf]:=RMask;
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
 {$q-}
-{$endif}
          Mem[WinWriteSeg:word(ScrOfs)]:=Mem[WinReadSeg:word(ScrOfs)]+1;
          Mem[WinWriteSeg:word(ScrOfs)]:=Mem[WinReadSeg:word(ScrOfs)]+1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
       end;
       end;
     { clean up }
     { clean up }
     {Port[$3cf]:=0;}{not needed, the register is reset by the next operation:}
     {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);
 procedure fillpoly(numpoints : Word; var polypoints);
 
 
 { disable range check mode }
 { disable range check mode }
-{$ifopt R+}
-{$define OPT_R_WAS_ON}
+{$push}
 {$R-}
 {$R-}
-{$endif}
 type
 type
   pedge = ^tedge;
   pedge = ^tedge;
   tedge = packed record
   tedge = packed record
@@ -539,6 +537,4 @@ var
   End;
   End;
 
 
 { restore previous range check mode }
 { 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 }
        { bit 0..7 only which are considered }
        { signed values.                     }
        { signed values.                     }
 { disable range check mode }
 { disable range check mode }
-{$ifopt R+}
-{$define OPT_R_WAS_ON}
+{$push}
 {$R-}
 {$R-}
-{$endif}
        b1:=b1 and $7f;
        b1:=b1 and $7f;
        b2:=b2 and $7f;
        b2:=b2 and $7f;
        { Now if the MSB of these values are set }
        { Now if the MSB of these values are set }
@@ -222,9 +220,7 @@ end;
        x:=smallint(b1);
        x:=smallint(b1);
        y:=smallint(b2);
        y:=smallint(b2);
 { restore previous range check mode }
 { restore previous range check mode }
-{$ifdef OPT_R_WAS_ON}
-{$R+}
-{$endif}
+{$pop}
      end;
      end;
 
 
 
 

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

@@ -267,23 +267,11 @@ begin
   ScrOfs := y * ScrWidth + x div 8;
   ScrOfs := y * ScrWidth + x div 8;
   HLength := x2 div 8 - x div 8;
   HLength := x2 div 8 - x div 8;
   LMask := $ff shr (x and 7);
   LMask := $ff shr (x and 7);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
 {$q-}
-{$endif}
   RMask:=$ff shl (7 - (x2 and 7));
   RMask:=$ff shl (7 - (x2 and 7));
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
   if HLength=0 then
   if HLength=0 then
     LMask:=LMask and RMask;
     LMask:=LMask and RMask;
   WritePortB($3ce, 0);
   WritePortB($3ce, 0);
@@ -308,23 +296,11 @@ begin
 
 
   WritePortB($3ce, 8);
   WritePortB($3ce, 8);
   WritePortB($3cf, LMask);
   WritePortB($3cf, LMask);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
 {$q-}
-{$endif}
   VidMem^[ScrOfs] := VidMem^[ScrOfs] + 1;
   VidMem^[ScrOfs] := VidMem^[ScrOfs] + 1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
   if HLength>0 then
   if HLength>0 then
   begin
   begin
     Dec(HLength);
     Dec(HLength);
@@ -337,23 +313,11 @@ begin
     end else
     end else
       WritePortB($3ce, 8);
       WritePortB($3ce, 8);
     WritePortB($3cf, RMask);
     WritePortB($3cf, RMask);
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
 {$q-}
-{$endif}
     VidMem^[ScrOfs] := VidMem^[ScrOfs] + 1;
     VidMem^[ScrOfs] := VidMem^[ScrOfs] + 1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
   end;
   end;
 end;
 end;
 
 
@@ -405,23 +369,11 @@ begin
   end;
   end;
   for i:=y to y2 do
   for i:=y to y2 do
   begin
   begin
-{$ifopt r+}
-{$define rangeOn}
+{$push}
 {$r-}
 {$r-}
-{$endif}
-{$ifopt q+}
-{$define overflowOn}
 {$q-}
 {$q-}
-{$endif}
     VidMem^[ScrOfs]:=VidMem^[ScrOfs]+1;
     VidMem^[ScrOfs]:=VidMem^[ScrOfs]+1;
-{$ifdef rangeOn}
-{$undef rangeOn}
-{$r+}
-{$endif}
-{$ifdef overflowOn}
-{$undef overflowOn}
-{$q+}
-{$endif}
+{$pop}
     Inc(ScrOfs, ScrWidth);
     Inc(ScrOfs, ScrWidth);
   end;
   end;
 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
   { 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))
     (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
     unused bits in value. }
     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
   if (s.bi_valid > integer(Buf_size) - length) then
   begin
   begin
     s.bi_buf := s.bi_buf or integer(value shl s.bi_valid);
     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);
     s.bi_buf := s.bi_buf or integer(value shl s.bi_valid);
     inc(s.bi_valid, length);
     inc(s.bi_valid, length);
   end;
   end;
-  {$IFDEF NoOverflowCheck} {$Q+} {$UNDEF NoOverflowCheck} {$ENDIF}
-  {$IFDEF NoRangeCheck} {$Q+} {$UNDEF NoRangeCheck} {$ENDIF}
+  {$POP}
 end;
 end;
 
 
 {$else} { !ZLIB_DEBUG }
 {$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}
 {$ifdef DO_UNALIGNED_OK}
         { This code assumes sizeof(cardinal short) = 2. Do not use
         { This code assumes sizeof(cardinal short) = 2. Do not use
           UNALIGNED_OK if your compiler uses a different size. }
           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
         if (match[best_len-1]<>scan_end) or
            (match^ <> scan_start) then
            (match^ <> scan_start) then
           goto nextstep; {continue;}
           goto nextstep; {continue;}
-  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+  {$POP}
 
 
         { It is not necessary to compare scan[2] and match[2] since they are
         { 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
           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 }
         { Here, scan <= window+strstart+257 }
         {$IFDEF ZLIB_DEBUG}
         {$IFDEF ZLIB_DEBUG}
-        {$ifopt R+} {$define RangeCheck} {$endif} {$R-}
+        {$PUSH} {$R-}
         Assert(ptruint(scan) <=
         Assert(ptruint(scan) <=
                ptruint(@(s.window^[cardinal(s.window_size-1)])),
                ptruint(@(s.window^[cardinal(s.window_size-1)])),
                'wild scan');
                'wild scan');
-        {$ifdef RangeCheck} {$R+} {$undef RangeCheck} {$endif}
+        {$POP}
         {$ENDIF}
         {$ENDIF}
         if scan^=match^ then
         if scan^=match^ then
           inc(scan);
           inc(scan);
@@ -1349,12 +1349,12 @@ distances are limited to MAX_DIST instead of WSIZE. }
 
 
 {$else} { UNALIGNED_OK }
 {$else} { UNALIGNED_OK }
 
 
-  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+  {$PUSH} {$R-}
         if (Pbytearray(match)^[best_len]   <> scan_end) or
         if (Pbytearray(match)^[best_len]   <> scan_end) or
            (Pbytearray(match)^[best_len-1] <> scan_end1) or
            (Pbytearray(match)^[best_len-1] <> scan_end1) or
            (match^ <> scan^) then
            (match^ <> scan^) then
           goto nextstep; {continue;}
           goto nextstep; {continue;}
-  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+  {$POP}
         inc(match);
         inc(match);
         if (match^ <> Pbytearray(scan)^[1]) then
         if (match^ <> Pbytearray(scan)^[1]) then
           goto nextstep; {continue;}
           goto nextstep; {continue;}
@@ -1402,14 +1402,14 @@ distances are limited to MAX_DIST instead of WSIZE. }
             best_len := len;
             best_len := len;
             if (len >= nice_match) then
             if (len >= nice_match) then
               break;
               break;
-  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+  {$PUSH} {$R-}
 {$ifdef UNALIGNED_OK}
 {$ifdef UNALIGNED_OK}
             scan_end   := Pbytearray(scan)^[best_len-1];
             scan_end   := Pbytearray(scan)^[best_len-1];
 {$else}
 {$else}
             scan_end1  := Pbytearray(scan)^[best_len-1];
             scan_end1  := Pbytearray(scan)^[best_len-1];
             scan_end   := Pbytearray(scan)^[best_len];
             scan_end   := Pbytearray(scan)^[best_len];
 {$endif}
 {$endif}
-  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+  {$POP}
         end;
         end;
     nextstep:
     nextstep:
       cur_match := prev^[cur_match and wmask];
       cur_match := prev^[cur_match and wmask];