Wrong calculation {$ifopt o-} state in TLinkScanner.IfOptDirective
Original Reporter info from Mantis: in0k
-
Reporter name: mangust
Original Reporter info from Mantis: in0k
- Reporter name: mangust
Description:
In function TLinkScanner.IfOptDirective
one condition to check is missing.
If OPT
not define in Values
Values.Variables[CompilerSwitchesNames[Option]]
Steps to reproduce:
Try use {$ifopt o-} when the switch
is off or undefined.
For example: {$ifopt D-}.
Additional information:
My version of the fix that is currently working for me.
function TLinkScanner.IfOptDirective: boolean;
// {$ifopt o+} or {$ifopt o-}
var Option, c: char;
var v:string;
begin
inc(IfLevel);
if StoreDirectives then
FDirectives[FDirectivesCount-1].Kind:=lsdkIfOpt;
if FSkippingDirectives<>lssdNone then exit(true);
Result:=true;
inc(SrcPos);
Option:=UpChars[Src[SrcPos]];
if (IsWordChar[Option]) and (CompilerSwitchesNames[Option]<>'')
then begin
inc(SrcPos);
if (SrcPos<=SrcLen) then begin
c:=Src[SrcPos];
//--> in0k
if c in ['+','-'] then begin
v:=Values.Variables[CompilerSwitchesNames[Option]];
if ( (c='+')AND(v='1') ) or
( (c='-')AND( (v='0')or(v='') ))
then exit
else begin
SkipTillEndifElse(lssdTillElse);
exit;
end;
end;
//--< in0k
(* wrong version
if c in ['+','-'] then begin
if (c='-')<>(Values.Variables[CompilerSwitchesNames[Option]]='0') then
begin
SkipTillEndifElse(lssdTillElse);
exit;
end;
end; *)
end;
end;
end;
Mantis conversion info:
- Mantis ID: 34767
- Fixed in revision: 59914 (#0e5d9ae3).