* fix conversion of true/false macro definitions to boolean values

(mantis #38492)
   o since the macro lookups are recursive, "mac" will usually be nil
     afterwards (unless we found an undefined macro)

git-svn-id: trunk@49160 -
This commit is contained in:
Jonas Maebe 2021-04-10 10:56:02 +00:00
parent 500e29e5e2
commit ff3f812d97
3 changed files with 19 additions and 2 deletions

1
.gitattributes vendored
View File

@ -18768,6 +18768,7 @@ tests/webtbs/tw3841.pp svneol=native#text/plain
tests/webtbs/tw38412.pp svneol=native#text/pascal
tests/webtbs/tw38413.pp svneol=native#text/pascal
tests/webtbs/tw38429.pp svneol=native#text/pascal
tests/webtbs/tw38492.pp svneol=native#text/plain
tests/webtbs/tw38497.pp svneol=native#text/pascal
tests/webtbs/tw38527.pp svneol=native#text/plain
tests/webtbs/tw38549.pp svneol=native#text/plain

View File

@ -1649,6 +1649,7 @@ type
mac: tmacro;
macrocount,
len: integer;
foundmacro: boolean;
begin
if not eval then
begin
@ -1657,6 +1658,7 @@ type
end;
mac:=nil;
foundmacro:=false;
{ Substitue macros and compiler variables with their content/value.
For real macros also do recursive substitution. }
macrocount:=0;
@ -1684,6 +1686,7 @@ type
move(mac.buftext^,hs[1],len);
searchstr:=upcase(hs);
mac.is_used:=true;
foundmacro:=true;
end
else
begin
@ -1702,9 +1705,9 @@ type
result:=texprvalue.try_parse_number(searchstr);
if not assigned(result) then
begin
if assigned(mac) and (searchstr='FALSE') then
if foundmacro and (searchstr='FALSE') then
result:=texprvalue.create_bool(false)
else if assigned(mac) and (searchstr='TRUE') then
else if foundmacro and (searchstr='TRUE') then
result:=texprvalue.create_bool(true)
else if (m_mac in current_settings.modeswitches) and
(not assigned(mac) or not mac.defined) and

13
tests/webtbs/tw38492.pp Normal file
View File

@ -0,0 +1,13 @@
{ %opt=-Sm -dmydefine:=false }
{$mode macpas}
{$setc def := mydefine}
program setcbug;
begin
{$ifc def}
writeln( 'mydefine is true')
halt(1);
{$elsec}
writeln( 'mydefine is false')
{$endc}
end.