From f5b5cdd09180352fa9b6c05d24264098c59462c5 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 27 Mar 2008 23:38:56 +0000 Subject: [PATCH] codetools: h2p: fixed test if ifdef block is empty git-svn-id: trunk@14671 - --- components/codetools/h2pastool.pas | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/codetools/h2pastool.pas b/components/codetools/h2pastool.pas index 86e7de3e12..e11131045c 100644 --- a/components/codetools/h2pastool.pas +++ b/components/codetools/h2pastool.pas @@ -1464,10 +1464,13 @@ procedure TH2PasTool.SimplifyIfDirective(Node: TH2PDirectiveNode; const Expression: string; var NextNode: TH2PDirectiveNode; var Changed: boolean); begin - if Node.H2PNode<>nil then - MarkMacrosAsRead(Node.H2PNode,Expression); + if Node.H2PNode=nil then exit; + MarkMacrosAsRead(Node.H2PNode,Expression); - if (Node.FirstChild=nil) and (Node.H2PNode.FirstChild=nil) then begin + if (Node.FirstChild=nil) and (Node.H2PNode.FirstChild=nil) + and ((Node.NextBrother=nil) + or (TH2PDirectiveNode(Node.NextBrother).H2PNode=Node.H2PNode.NextBrother)) + then begin // no content DebugLn(['TH2PasTool.SimplifyIfDirective REMOVING empty if directive: ',Node.DescAsString(CTool)]); if (NextNode=Node.NextBrother) and (NextNode.Desc=h2pdnEndIf) then @@ -1475,7 +1478,7 @@ begin DeleteDirectiveNode(Node,true,true); Changed:=true; end else begin - + DebugLn(['TH2PasTool.SimplifyIfDirective AAA1 Node=',Node.DescAsString(CTool),' Node.NextBrother=',TH2PDirectiveNode(Node.NextBrother).DescAsString(CTool)]); end; end;