mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-03 13:59:35 +01:00
codetools: h2p: auto replacing special macro chars
git-svn-id: trunk@14646 -
This commit is contained in:
parent
e159c54b13
commit
2fc48743e4
@ -197,6 +197,7 @@ type
|
||||
procedure WriteGlobalEnumerationTypeNode(H2PNode: TH2PNode);
|
||||
procedure WriteGlobalRecordTypeNode(H2PNode: TH2PNode);
|
||||
procedure WriteDirectiveNode(DirNode: TH2PDirectiveNode);
|
||||
function CreateDirectiveValue(const s: string): string;
|
||||
|
||||
procedure SimplifyUndefineDirective(Node: TH2PDirectiveNode;
|
||||
var NextNode: TH2PDirectiveNode);
|
||||
@ -1255,7 +1256,7 @@ begin
|
||||
h2pdnError:
|
||||
begin
|
||||
SetPasSection(ctnNone);
|
||||
W('{$Error '+dbgstr(DirNode.Expression)+'}');
|
||||
W('{$Error '+CreateDirectiveValue(DirNode.Expression)+'}');
|
||||
end;
|
||||
h2pdnUndefine:
|
||||
begin
|
||||
@ -1268,7 +1269,7 @@ begin
|
||||
if DirNode.Expression='' then begin
|
||||
W('{$Define '+DirNode.MacroName+'}');
|
||||
end else begin
|
||||
W('{$Define '+DirNode.MacroName+':='+dbgstr(DirNode.Expression)+'}');
|
||||
W('{$Define '+DirNode.MacroName+':='+CreateDirectiveValue(DirNode.Expression)+'}');
|
||||
end;
|
||||
end else begin
|
||||
DebugLn(['TH2PasTool.WriteDirectiveNode SKIPPING ',DirNode.DescAsString(CTool)]);
|
||||
@ -1278,6 +1279,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TH2PasTool.CreateDirectiveValue(const s: string): string;
|
||||
var
|
||||
p: Integer;
|
||||
begin
|
||||
Result:=s;
|
||||
p:=length(Result);
|
||||
while p>=1 do begin
|
||||
if (Result[p] in [#0..#31,'{','}']) then begin
|
||||
Result:=copy(Result,1,p-1)+'#'+IntToStr(ord(Result[p]))+copy(Result,p+1,length(Result));
|
||||
end;
|
||||
dec(p);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TH2PasTool.SimplifyUndefineDirective(Node: TH2PDirectiveNode;
|
||||
var NextNode: TH2PDirectiveNode);
|
||||
begin
|
||||
|
||||
Loading…
Reference in New Issue
Block a user