3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

Don't add {}'s around single statements following if/for/etc; add -naked flag to prevent wrapping code with a main function

This commit is contained in:
Pragmatic Software 2012-12-29 16:19:51 +00:00
parent e93ac26062
commit 9205736b3f
2 changed files with 10 additions and 5 deletions

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 398, BUILD_REVISION => 399,
BUILD_DATE => "2012-11-21", BUILD_DATE => "2012-12-29",
}; };
1; 1;

View File

@ -39,7 +39,7 @@ sub pretty {
print $fh $code; print $fh $code;
close $fh; close $fh;
system("astyle", "-UHjfnq", "prog.c"); system("astyle", "-UHfenq", "prog.c");
open $fh, "<prog.c" or die "Couldn't read prog.c: $!"; open $fh, "<prog.c" or die "Couldn't read prog.c: $!";
$result = join '', <$fh>; $result = join '', <$fh>;
@ -154,7 +154,10 @@ my $input = "";
$input = $1 if $code =~ s/-(?:input|stdin)=(.*)$//i; $input = $1 if $code =~ s/-(?:input|stdin)=(.*)$//i;
my $got_paste = undef; 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 = ""; my $args = "";
$args .= "$1 " while $code =~ s/^\s*(-[^ ]+)\s*//; $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; $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"; $code = "$prelude\n\n$code\n\nint main(void) {\n$precode\n;\nreturn 0;\n}\n";
$nooutput = "No warnings, errors or output."; $nooutput = "No warnings, errors or output.";
} else { } else {
@ -941,6 +944,8 @@ if($output =~ m/^\s*$/) {
# $output =~ s/maxSet\((.*?)\s*@\s*\)/$1/g; # $output =~ s/maxSet\((.*?)\s*@\s*\)/$1/g;
$output =~ s/\s*Unable to resolve constraint: requires .*? >= [^ \]]+//gs; $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*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/<Function "main" not defined.>\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/\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/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; $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;