From b8d2d0797ecfd72b2831ce145eef36a5fa2fbecb Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 2 Nov 2012 22:08:20 +0000 Subject: [PATCH] compiler_vm: Show output from program when using `paste` command google search: Show "No results found" if no results found c99std/c11std: Minor clean-up of output --- PBot/VERSION.pm | 4 ++-- modules/c11std.pl | 7 +++++++ modules/c99std.pl | 7 +++++++ modules/compiler_vm/compiler_vm_client.pl | 18 ++++++++++-------- modules/g.pl | 4 ++++ modules/get_title.pl | 2 ++ 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index ca130365..c42c2f13 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,8 +13,8 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 390, - BUILD_DATE => "2012-10-27", + BUILD_REVISION => 391, + BUILD_DATE => "2012-11-02", }; 1; diff --git a/modules/c11std.pl b/modules/c11std.pl index b2d06c4e..c8ade361 100755 --- a/modules/c11std.pl +++ b/modules/c11std.pl @@ -220,4 +220,11 @@ if($comma eq "") { print "[", $found_section_title, "]\n\n" if length $found_section_title; } +$result =~ s/\s*Constraints\s*$//; +$result =~ s/\s*Semantics\s*$//; +$result =~ s/\s*Description\s*$//; +$result =~ s/\s*Returns\s*$//; +$result =~ s/\s*Runtime-constraints\s*$//; +$result =~ s/\s*Recommended practice\s*$//; + print "$result\n"; diff --git a/modules/c99std.pl b/modules/c99std.pl index f7c4c5e3..df4dbfc7 100755 --- a/modules/c99std.pl +++ b/modules/c99std.pl @@ -214,4 +214,11 @@ if($comma eq "") { print "[", $found_section_title, "]\n\n" if length $found_section_title; } +$result =~ s/\s*Constraints\s*$//; +$result =~ s/\s*Semantics\s*$//; +$result =~ s/\s*Description\s*$//; +$result =~ s/\s*Returns\s*$//; +$result =~ s/\s*Runtime-constraints\s*$//; +$result =~ s/\s*Recommended practice\s*$//; + print "$result\n"; diff --git a/modules/compiler_vm/compiler_vm_client.pl b/modules/compiler_vm/compiler_vm_client.pl index 9142a60f..87fc33fd 100755 --- a/modules/compiler_vm/compiler_vm_client.pl +++ b/modules/compiler_vm/compiler_vm_client.pl @@ -829,13 +829,7 @@ $code =~ s/(?:\n\n)+/\n\n/g; print "final code: [$code]\n" if $debug; -if(defined $got_run and $got_run eq "paste") { - my $uri = paste_sprunge(pretty($code)); - print "$nick: $uri\n"; - exit 0; -} - -print FILE "$nick: [lang:$lang][args:$args][input:$input]\n", pretty($code), "\n"; +print FILE "$nick: [lang:$lang][args:$args][input:$input]\n", pretty($code), "\n" unless $got_run; $input = "Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet." if not length $input; @@ -902,6 +896,7 @@ if($output =~ m/^\s*$/) { $output =~ s/preprocessor macro>\s+/preprocessor macro>/g; $output =~ s/\s*//g; $output =~ s/cc1: all warnings being treated as; errors//g; + $output =~ s/, note: this is the location of the previous definition//g; # remove duplicate warnings/infos $output =~ s/(\[*.*warning:.*?\s*)\1/$1/g; @@ -911,7 +906,7 @@ if($output =~ m/^\s*$/) { # splint $output =~ s/Splint 3.1.2 --- 03 May 2009\s*//; $output =~ s/Finished checking --- \d+ code warning\s*//; - print FILE "splint: [$output]\n"; + print FILE "splint: [$output]\n" unless $got_run; $output =~ s/\s*\(in function main\)\s*Fresh\s*storage\s*.*?\s*not\s*released.*?reference\s+to\s+it\s+is\s+lost.\s*//msg; $output =~ s/\s*\(in function main\)\s*//g; $output =~ s/\s*\(Use\s+.*?\s+to\s+inhibit\s+warning\)//msg; @@ -943,4 +938,11 @@ unless($got_run) { close FILE; } +if(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"; + exit 0; +} + print "$nick: $output\n"; diff --git a/modules/g.pl b/modules/g.pl index 0ff88be6..c7924aa3 100755 --- a/modules/g.pl +++ b/modules/g.pl @@ -32,7 +32,11 @@ my $search = Google::Search->Web(query => $arguments, referrer => 'http://blacks print "$nick: "; if(not $search->first) { + if($search->error) { print $search->error->reason, "\n"; + } else { + print "No results found\n"; + } exit; } diff --git a/modules/get_title.pl b/modules/get_title.pl index c5a445da..f4e64f82 100755 --- a/modules/get_title.pl +++ b/modules/get_title.pl @@ -16,6 +16,8 @@ if ($#ARGV <= 0) my $nick = shift(@ARGV); $arguments = join("%20", @ARGV); +exit if($arguments =~ m/stackoverflow.com/i); +exit if($arguments =~ m/scratch.mit.edu/i); exit if($arguments =~ m/sprunge.us/i); exit if($arguments =~ m/hastebin.com/i); exit if($arguments =~ m/lmgtfy.com/i);