mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-07 23:12:21 +02:00
* quote strings in TGDBController.PrintCommand and .PrintFormattedCommand to
allow evaluating expressions which contain spaces git-svn-id: trunk@30057 -
This commit is contained in:
parent
547e20f1a2
commit
1709006ad3
@ -302,7 +302,7 @@ end;
|
||||
{ print }
|
||||
function TGDBController.PrintCommand(const expr : string): AnsiString;
|
||||
begin
|
||||
Command('-data-evaluate-expression '+expr);
|
||||
Command('-data-evaluate-expression '+QuoteString(expr));
|
||||
if GDB.ResultRecord.Success then
|
||||
PrintCommand:=GDB.ResultRecord.Parameters['value'].AsString
|
||||
else
|
||||
@ -315,7 +315,7 @@ const
|
||||
|
||||
function TGDBController.PrintFormattedCommand(const expr : string; Format : TPrintFormatType): ansistring;
|
||||
begin
|
||||
Command('-var-evaluate-expression -f '+PrintFormatName[Format]+' '+expr);
|
||||
Command('-var-evaluate-expression -f '+PrintFormatName[Format]+' '+QuoteString(expr));
|
||||
if GDB.ResultRecord.Success then
|
||||
PrintFormattedCommand:=GDB.ResultRecord.Parameters['value'].AsString
|
||||
else
|
||||
|
@ -113,8 +113,38 @@ type
|
||||
property Alive: Boolean read IsAlive;
|
||||
end;
|
||||
|
||||
function QuoteString(S: string): string;
|
||||
|
||||
implementation
|
||||
|
||||
function QuoteString(S: string): string;
|
||||
var
|
||||
I: LongInt;
|
||||
begin
|
||||
I := 1;
|
||||
Result := '';
|
||||
while I <= Length(S) do
|
||||
begin
|
||||
case S[I] of
|
||||
'''': Result := Result + '\''';
|
||||
'"': Result := Result + '\"';
|
||||
#10: Result := Result + '\n';
|
||||
#13: Result := Result + '\r';
|
||||
#9: Result := Result + '\t';
|
||||
#11: Result := Result + '\v';
|
||||
#8: Result := Result + '\b';
|
||||
#12: Result := Result + '\f';
|
||||
#7: Result := Result + '\a';
|
||||
'\': Result := Result + '\\';
|
||||
'?': Result := Result + '\?';
|
||||
else
|
||||
Result := Result + S[I];
|
||||
end;
|
||||
Inc(I);
|
||||
end;
|
||||
Result := '"' + Result + '"';
|
||||
end;
|
||||
|
||||
function TGDBMI_Value.AsString: string;
|
||||
begin
|
||||
Result := (self as TGDBMI_StringValue).StringValue;
|
||||
|
Loading…
Reference in New Issue
Block a user