mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-07-20 02:39:33 +02:00
* fixed checking for defined/undefined macro's in the configuration file
(#undef'ed macro's still caused #ifdef/#ifndef to return resp. true/false) git-svn-id: trunk@10872 -
This commit is contained in:
parent
0919c1112f
commit
a324744cbe
@ -1658,7 +1658,7 @@ begin
|
|||||||
RemoveSep(opts);
|
RemoveSep(opts);
|
||||||
s:=upper(GetName(opts));
|
s:=upper(GetName(opts));
|
||||||
if level=0 then
|
if level=0 then
|
||||||
skip[level]:=not (assigned(search_macro(s)) or (s='COMMON'));
|
skip[level]:=not defined_macro(s) or (s='COMMON');
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (s='IFDEF') then
|
if (s='IFDEF') then
|
||||||
@ -1670,7 +1670,7 @@ begin
|
|||||||
stopOptions(1);
|
stopOptions(1);
|
||||||
end;
|
end;
|
||||||
inc(Level);
|
inc(Level);
|
||||||
skip[level]:=(skip[level-1] or not assigned(search_macro(upper(GetName(opts)))));
|
skip[level]:=(skip[level-1] or not defined_macro(upper(GetName(opts))));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (s='IFNDEF') then
|
if (s='IFNDEF') then
|
||||||
@ -1682,7 +1682,7 @@ begin
|
|||||||
stopOptions(1);
|
stopOptions(1);
|
||||||
end;
|
end;
|
||||||
inc(Level);
|
inc(Level);
|
||||||
skip[level]:=(skip[level-1] or assigned(search_macro(upper(GetName(opts)))));
|
skip[level]:=(skip[level-1] or defined_macro(upper(GetName(opts))));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (s='ELSE') then
|
if (s='ELSE') then
|
||||||
|
@ -432,10 +432,7 @@ implementation
|
|||||||
valuedescr:= hs;
|
valuedescr:= hs;
|
||||||
if hs='' then
|
if hs='' then
|
||||||
Message(scan_e_error_in_preproc_expr);
|
Message(scan_e_error_in_preproc_expr);
|
||||||
mac:=tmacro(search_macro(hs));
|
isdef:=defined_macro(hs);
|
||||||
if assigned(mac) then
|
|
||||||
mac.is_used:=true;
|
|
||||||
isdef:= assigned(mac) and mac.defined;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure dir_ifdef;
|
procedure dir_ifdef;
|
||||||
@ -453,10 +450,7 @@ implementation
|
|||||||
valuedescr:= hs;
|
valuedescr:= hs;
|
||||||
if hs='' then
|
if hs='' then
|
||||||
Message(scan_e_error_in_preproc_expr);
|
Message(scan_e_error_in_preproc_expr);
|
||||||
mac:=tmacro(search_macro(hs));
|
isnotdef:=not defined_macro(hs);
|
||||||
if assigned(mac) then
|
|
||||||
mac.is_used:=true;
|
|
||||||
isnotdef:= not (assigned(mac) and mac.defined);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure dir_ifndef;
|
procedure dir_ifndef;
|
||||||
|
@ -203,6 +203,9 @@ interface
|
|||||||
{Looks for macro s (must be given in upper case) in the macrosymbolstack, }
|
{Looks for macro s (must be given in upper case) in the macrosymbolstack, }
|
||||||
{and returns it if found. Returns nil otherwise.}
|
{and returns it if found. Returns nil otherwise.}
|
||||||
function search_macro(const s : string):tsym;
|
function search_macro(const s : string):tsym;
|
||||||
|
{ Additionally to searching for a macro, also checks whether it's still }
|
||||||
|
{ actually defined (could be disable using "undef") }
|
||||||
|
function defined_macro(const s : string):boolean;
|
||||||
|
|
||||||
{*** Object Helpers ***}
|
{*** Object Helpers ***}
|
||||||
procedure search_class_overloads(aprocsym : tprocsym);
|
procedure search_class_overloads(aprocsym : tprocsym);
|
||||||
@ -1876,6 +1879,21 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function defined_macro(const s : string):boolean;
|
||||||
|
var
|
||||||
|
mac: tmacro;
|
||||||
|
begin
|
||||||
|
mac:=tmacro(search_macro(s));
|
||||||
|
if assigned(mac) then
|
||||||
|
begin
|
||||||
|
mac.is_used:=true;
|
||||||
|
defined_macro:=mac.defined;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
defined_macro:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
Object Helpers
|
Object Helpers
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
Loading…
Reference in New Issue
Block a user