mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
compiler_vm: -input flag once again works with all languages
This commit is contained in:
parent
4c9496a2b3
commit
ff2beb1f14
@ -35,6 +35,20 @@ sub initialize {
|
|||||||
sub preprocess {
|
sub preprocess {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
my $input = $self->{input};
|
||||||
|
$input = "" if not defined $input;
|
||||||
|
|
||||||
|
print "writing input [$input]\n";
|
||||||
|
|
||||||
|
$input =~ s/(?<!\\)\\n/\n/mg;
|
||||||
|
$input =~ s/(?<!\\)\\r/\r/mg;
|
||||||
|
$input =~ s/(?<!\\)\\t/\t/mg;
|
||||||
|
$input =~ s/(?<!\\)\\b/\b/mg;
|
||||||
|
|
||||||
|
open(my $fh, '>', '.input');
|
||||||
|
print $fh "$input\n";
|
||||||
|
close $fh;
|
||||||
|
|
||||||
if ($self->{code} =~ m/print_last_statement\(.*\);$/m) {
|
if ($self->{code} =~ m/print_last_statement\(.*\);$/m) {
|
||||||
# remove print_last_statement wrapper in order to get warnings/errors from last statement line
|
# remove print_last_statement wrapper in order to get warnings/errors from last statement line
|
||||||
my $code = $self->{code};
|
my $code = $self->{code};
|
||||||
@ -63,7 +77,7 @@ sub preprocess {
|
|||||||
close $fh;
|
close $fh;
|
||||||
|
|
||||||
print "Executing [$self->{cmdline}]\n";
|
print "Executing [$self->{cmdline}]\n";
|
||||||
my ($retval, $result) = $self->execute(60, "date -s \@$self->{date} > /dev/null; ulimit -t 5; $self->{cmdline}");
|
my ($retval, $result) = $self->execute(60, "date -s \@$self->{date} > /dev/null; ulimit -t 5; $self->{cmdline} < .input");
|
||||||
$self->{output} = $result;
|
$self->{output} = $result;
|
||||||
$self->{error} = $retval;
|
$self->{error} = $retval;
|
||||||
}
|
}
|
||||||
@ -71,21 +85,6 @@ sub preprocess {
|
|||||||
|
|
||||||
sub postprocess {
|
sub postprocess {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
my $input = $self->{input};
|
|
||||||
|
|
||||||
print "writing input [$input]\n";
|
|
||||||
|
|
||||||
$input =~ s/(?<!\\)\\n/\n/mg;
|
|
||||||
$input =~ s/(?<!\\)\\r/\r/mg;
|
|
||||||
$input =~ s/(?<!\\)\\t/\t/mg;
|
|
||||||
$input =~ s/(?<!\\)\\b/\b/mg;
|
|
||||||
|
|
||||||
$input =~ s/\\\\/\\/mg;
|
|
||||||
|
|
||||||
open(my $fh, '>', '.input');
|
|
||||||
print $fh "$input\n";
|
|
||||||
close $fh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub execute {
|
sub execute {
|
||||||
|
Loading…
Reference in New Issue
Block a user