mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-25 13:29:29 +01:00
pbot-vm: fix occasional "illegal escape sequence" in guest-gdb
This commit is contained in:
parent
bf8749ff9e
commit
01cefe462f
@ -142,9 +142,17 @@ sub gdb_read_result($out) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
sub gdbmi_to_json($text, $makejson = 1) {
|
||||
# convert gdb/mi text to hashtable, converting to JSON first if necessary
|
||||
sub gdbmi_to_hash($text, $makejson = 1) {
|
||||
# convert to JSON first if necessary (gdb/mi is nearly JSON already!)
|
||||
$text =~ s/([\w-]+)=/"$1":/g if $makejson;
|
||||
$text =~ s/\\(\d{3})/$1 >= 0x20 ? chr oct $1 : "\\$1"/ge;
|
||||
|
||||
# decode gdb octal escapes
|
||||
# (sometimes \\123, othertimes \123 and I can't be arsed to investigate
|
||||
# when and why the backslashes double up)
|
||||
$text =~ s/\\+(\d{3})/$1 >= 0x20 ? chr oct $1 : "\\\\$1"/ge;
|
||||
|
||||
# return hashtable decoded from json
|
||||
return decode_json("{$text}");
|
||||
}
|
||||
|
||||
@ -165,7 +173,7 @@ sub parse_gdbmi_output($line) {
|
||||
$text = "\"_text\":$text";
|
||||
}
|
||||
|
||||
my $output = gdbmi_to_json($text, $makejson);
|
||||
my $output = gdbmi_to_hash($text, $makejson);
|
||||
|
||||
if (exists $output->{_text}) {
|
||||
chomp $output->{_text};
|
||||
|
Loading…
Reference in New Issue
Block a user