3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-30 07:49:38 +01:00

compiler_vm: Handle --version flag

This commit is contained in:
Pragmatic Software 2013-02-05 11:14:19 +00:00
parent 3d492ed76b
commit 57166ff734
3 changed files with 13 additions and 8 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 => 401, BUILD_REVISION => 402,
BUILD_DATE => "2013-02-01", BUILD_DATE => "2013-02-05",
}; };
1; 1;

View File

@ -950,6 +950,7 @@ if($output =~ m/^\s*$/) {
$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;
$output =~ s/ called by \?\? \(\)//g; $output =~ s/ called by \?\? \(\)//g;
$output =~ s/\s*Copyright\s*\(C\)\s*\d+\s*Free\s*Software\s*Foundation,\s*Inc.\s*This\s*is\s*free\s*software;\s*see\s*the\s*source\s*for\s*copying\s*conditions.\s*\s*There\s*is\s*NO\s*warranty;\s*not\s*even\s*for\s*MERCHANTABILITY\s*or\s*FITNESS\s*FOR\s*A\s*PARTICULAR\s*PURPOSE.//gs;
} }
if($warn_unterminated_define == 1) { if($warn_unterminated_define == 1) {

View File

@ -6,7 +6,7 @@ use strict;
my $USE_LOCAL = defined $ENV{'CC_LOCAL'}; my $USE_LOCAL = defined $ENV{'CC_LOCAL'};
my %languages = ( my %languages = (
'C' => { 'C89' => {
'cmdline' => 'gcc $file $args -o prog -ggdb -g3', 'cmdline' => 'gcc $file $args -o prog -ggdb -g3',
'args' => '-Wextra -Wall -Wno-unused -std=gnu89 -lm -Wfatal-errors', 'args' => '-Wextra -Wall -Wno-unused -std=gnu89 -lm -Wfatal-errors',
'file' => 'prog.c', 'file' => 'prog.c',
@ -64,7 +64,7 @@ sub runserver {
print $output "result:$result\n"; print $output "result:$result\n";
print $output "result:end\n"; print $output "result:end\n";
# system("rm *"); system("rm prog");
if(not defined $USE_LOCAL or $USE_LOCAL == 0) { if(not defined $USE_LOCAL or $USE_LOCAL == 0) {
print "input: "; print "input: ";
@ -117,9 +117,9 @@ sub interpret {
if(length $user_args) { if(length $user_args) {
print "Replacing args with $user_args\n"; print "Replacing args with $user_args\n";
$user_args = quotemeta($user_args); my $user_args_quoted = quotemeta($user_args);
$user_args =~ s/\\ / /g; $user_args_quoted =~ s/\\ / /g;
$cmdline =~ s/\$args/$user_args/; $cmdline =~ s/\$args/$user_args_quoted/;
} else { } else {
$cmdline =~ s/\$args/$languages{$lang}{'args'}/; $cmdline =~ s/\$args/$languages{$lang}{'args'}/;
} }
@ -136,10 +136,14 @@ sub interpret {
return $result; return $result;
} }
my $output = ""; if($user_args =~ m/--version/) {
# arg contained --version, so don't compile and just return the version output
return $result;
}
# no errors compiling, but if $result contains something, it must be a warning message # no errors compiling, but if $result contains something, it must be a warning message
# so prepend it to the output # so prepend it to the output
my $output = "";
if(length $result) { if(length $result) {
$result =~ s/^\s+//; $result =~ s/^\s+//;
$result =~ s/\s+$//; $result =~ s/\s+$//;