mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-23 18:44:33 +01:00
Move backspace handling to base class for all languages
This commit is contained in:
parent
0d69796e6f
commit
ef22f9578d
@ -202,7 +202,7 @@ sub preprocess_code {
|
|||||||
my $has_main = 0;
|
my $has_main = 0;
|
||||||
|
|
||||||
my $prelude = '';
|
my $prelude = '';
|
||||||
while($precode =~ s/^\s*(#.*\n{1,2})//g) {
|
while($precode =~ s/^\s*(#.*\n{1,2}|using.*\n{1,2})//g) {
|
||||||
$prelude .= $1;
|
$prelude .= $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,6 +417,8 @@ sub postprocess_output {
|
|||||||
$output =~ s/ called by gdb \(\) at statement: void gdb\(\) { __asm__\(""\); }//g;
|
$output =~ s/ called by gdb \(\) at statement: void gdb\(\) { __asm__\(""\); }//g;
|
||||||
$output =~ s/called by \?\? \(\) //g;
|
$output =~ s/called by \?\? \(\) //g;
|
||||||
$output =~ s/\s0x[a-z0-9]+: note: pointer points here.*?\^//gms;
|
$output =~ s/\s0x[a-z0-9]+: note: pointer points here.*?\^//gms;
|
||||||
|
$output =~ s/\s0x[a-z0-9]+: note: pointer points here\s+<memory cannot be printed>//gms;
|
||||||
|
$output =~ s/store to address 0x[a-z0-9]+ with insufficient space/store to location with insufficient space/gms;
|
||||||
|
|
||||||
my $removed_warning = 0;
|
my $removed_warning = 0;
|
||||||
|
|
||||||
@ -431,22 +433,6 @@ sub postprocess_output {
|
|||||||
|
|
||||||
$output =~ s/^\[\s+(warning:|info:)/[$1/; # remove leading spaces in first warning/info
|
$output =~ s/^\[\s+(warning:|info:)/[$1/; # remove leading spaces in first warning/info
|
||||||
|
|
||||||
# backspace
|
|
||||||
my $boutput = "";
|
|
||||||
my $active_position = 0;
|
|
||||||
$output =~ s/\n$//;
|
|
||||||
while($output =~ /(.)/gms) {
|
|
||||||
my $c = $1;
|
|
||||||
if($c eq "\b") {
|
|
||||||
if(--$active_position <= 0) {
|
|
||||||
$active_position = 0;
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
substr($boutput, $active_position++, 1) = $c;
|
|
||||||
}
|
|
||||||
$output = $boutput;
|
|
||||||
|
|
||||||
if($self->{warn_unterminated_define} == 1) {
|
if($self->{warn_unterminated_define} == 1) {
|
||||||
if($output =~ m/^\[(warning:|info:)/) {
|
if($output =~ m/^\[(warning:|info:)/) {
|
||||||
$output =~ s/^\[/[warning: preprocessor directive not terminated by \\n, the remainder of the line will be part of this directive /;
|
$output =~ s/^\[/[warning: preprocessor directive not terminated by \\n, the remainder of the line will be part of this directive /;
|
||||||
|
@ -133,6 +133,22 @@ sub postprocess_output {
|
|||||||
print FILE "$self->{output}\n";
|
print FILE "$self->{output}\n";
|
||||||
close FILE;
|
close FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# backspace
|
||||||
|
my $boutput = "";
|
||||||
|
my $active_position = 0;
|
||||||
|
$self->{output} =~ s/\n$//;
|
||||||
|
while($self->{output} =~ /(.)/gms) {
|
||||||
|
my $c = $1;
|
||||||
|
if($c eq "\b") {
|
||||||
|
if(--$active_position <= 0) {
|
||||||
|
$active_position = 0;
|
||||||
|
}
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
substr($boutput, $active_position++, 1) = $c;
|
||||||
|
}
|
||||||
|
$self->{output} = $boutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub show_output {
|
sub show_output {
|
||||||
|
@ -256,29 +256,4 @@ sub preprocess_code {
|
|||||||
print "final code: [$self->{code}]\n" if $self->{debug};
|
print "final code: [$self->{code}]\n" if $self->{debug};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub postprocess_output {
|
|
||||||
my $self = shift;
|
|
||||||
$self->SUPER::postprocess_output;
|
|
||||||
|
|
||||||
my $output = $self->{output};
|
|
||||||
|
|
||||||
# backspace
|
|
||||||
my $boutput = "";
|
|
||||||
my $active_position = 0;
|
|
||||||
$output =~ s/\n$//;
|
|
||||||
while($output =~ /(.)/gms) {
|
|
||||||
my $c = $1;
|
|
||||||
if($c eq "\b") {
|
|
||||||
if(--$active_position <= 0) {
|
|
||||||
$active_position = 0;
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
substr($boutput, $active_position++, 1) = $c;
|
|
||||||
}
|
|
||||||
$output = $boutput;
|
|
||||||
|
|
||||||
$self->{output} = $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user