compiler_vm: added -paste flag to send formatted source/output to paste site and show link instead of output; e.g. `cc -paste <code>` --> http://somepastesite.com

This commit is contained in:
Pragmatic Software 2012-11-14 18:36:04 +00:00
parent 39a38b58f8
commit 3f771df8bc
2 changed files with 6 additions and 3 deletions

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 392,
BUILD_DATE => "2012-11-04",
BUILD_REVISION => 393,
BUILD_DATE => "2012-11-14",
};
1;

View File

@ -151,6 +151,9 @@ $lang = uc $1 if $code =~ s/-lang=([^\b\s]+)//i;
my $input = "";
$input = $1 if $code =~ s/-(?:input|stdin)=(.*)$//i;
my $got_paste = undef;
$got_paste = 1 if $code =~ s/^\s*-paste\s*//i;
my $args = "";
$args .= "$1 " while $code =~ s/^\s*(-[^ ]+)\s*//;
$args =~ s/\s+$//;
@ -938,7 +941,7 @@ unless($got_run) {
close FILE;
}
if(defined $got_run and $got_run eq "paste") {
if(defined $got_paste or (defined $got_run and $got_run eq "paste")) {
$code .= "\n\n/************* OUTPUT *************\n$output************** OUTPUT **************/\n";
my $uri = paste_sprunge(pretty($code));
print "$nick: $uri\n";