From 9205736b3f6159c7190317e90c7951ed48a28620 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 29 Dec 2012 16:19:51 +0000 Subject: [PATCH] Don't add {}'s around single statements following if/for/etc; add -naked flag to prevent wrapping code with a main function --- PBot/VERSION.pm | 4 ++-- modules/compiler_vm/compiler_vm_client.pl | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 828924e4..4b19ce65 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 => 398, - BUILD_DATE => "2012-11-21", + BUILD_REVISION => 399, + BUILD_DATE => "2012-12-29", }; 1; diff --git a/modules/compiler_vm/compiler_vm_client.pl b/modules/compiler_vm/compiler_vm_client.pl index 65bce9bf..4bd07dd5 100755 --- a/modules/compiler_vm/compiler_vm_client.pl +++ b/modules/compiler_vm/compiler_vm_client.pl @@ -39,7 +39,7 @@ sub pretty { print $fh $code; close $fh; - system("astyle", "-UHjfnq", "prog.c"); + system("astyle", "-UHfenq", "prog.c"); open $fh, "; @@ -154,7 +154,10 @@ my $input = ""; $input = $1 if $code =~ s/-(?:input|stdin)=(.*)$//i; my $got_paste = undef; -$got_paste = 1 if $code =~ s/^\s*-paste\s*//i; +$got_paste = 1 if $code =~ s/\s*-paste\s*//i; + +my $got_naked = undef; +$got_naked = 1 if $code =~ s/\s*-naked\s*//i; my $args = ""; $args .= "$1 " while $code =~ s/^\s*(-[^ ]+)\s*//; @@ -820,7 +823,7 @@ if($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') { $precode =~ s/^{(.*)}$/$1/s; - if(not $has_main) { + if(not $has_main and not $got_naked) { $code = "$prelude\n\n$code\n\nint main(void) {\n$precode\n;\nreturn 0;\n}\n"; $nooutput = "No warnings, errors or output."; } else { @@ -941,6 +944,8 @@ if($output =~ m/^\s*$/) { # $output =~ s/maxSet\((.*?)\s*@\s*\)/$1/g; $output =~ s/\s*Unable to resolve constraint: requires .*? >= [^ \]]+//gs; $output =~ s/\s*To\s*allow\s*arbitrary\s*integral\s*types\s*to\s*match\s*any\s*integral\s*type,\s*use\s*\+matchanyintegral.//gs; + $output =~ s/\s+//g; + $output =~ s/Make breakpoint pending on future shared library load\? \(y or \[n\]\) \[answered N; input not from terminal\]//g; $output =~ s/\s*Storage\s*.*?\s*becomes\s*static//gs; $output =~ s/Possibly\s*null\s*storage\s*passed\s*as\s*non-null\s*param:/Possibly null storage passed to function:/g; $output =~ s/A\s*possibly\s*null\s*pointer\s*is\s*passed\s*as\s*a\s*parameter\s*corresponding\s*to\s*a\s*formal\s*parameter\s*with\s*no\s*\/\*\@null\@\*\/\s*annotation.\s*If\s*NULL\s*may\s*be\s*used\s*for\s*this\s*parameter,\s*add\s*a\s*\/\*\@null\@\*\/\s*annotation\s*to\s*the\s*function\s*parameter\s*declaration./A possibly null pointer is passed as a parameter to a function./gs;