mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
Update c2english with -f force option, and hide certain errors
This commit is contained in:
parent
5a61f57f3c
commit
29316b23ba
@ -13,7 +13,7 @@ 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 => 478,
|
BUILD_REVISION => 479,
|
||||||
BUILD_DATE => "2014-02-04",
|
BUILD_DATE => "2014-02-04",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,6 +8,11 @@ use Text::Balanced qw(extract_codeblock extract_delimited);
|
|||||||
my $code = join ' ', @ARGV;
|
my $code = join ' ', @ARGV;
|
||||||
my $output;
|
my $output;
|
||||||
|
|
||||||
|
my $force;
|
||||||
|
if($code =~ s/^-f\s+//) {
|
||||||
|
$force = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$code =~ s/#include <([^>]+)>/\n#include <$1>\n/g;
|
$code =~ s/#include <([^>]+)>/\n#include <$1>\n/g;
|
||||||
$code =~ s/#([^ ]+) (.*?)\\n/\n#$1 $2\n/g;
|
$code =~ s/#([^ ]+) (.*?)\\n/\n#$1 $2\n/g;
|
||||||
$code =~ s/#([\w\d_]+)\\n/\n#$1\n/g;
|
$code =~ s/#([\w\d_]+)\\n/\n#$1\n/g;
|
||||||
@ -74,7 +79,7 @@ close $fh;
|
|||||||
|
|
||||||
my ($ret, $result) = execute(10, "gcc -std=c89 -pedantic -Werror -Wno-unused -fsyntax-only -fno-diagnostics-show-option code.c");
|
my ($ret, $result) = execute(10, "gcc -std=c89 -pedantic -Werror -Wno-unused -fsyntax-only -fno-diagnostics-show-option code.c");
|
||||||
|
|
||||||
if($ret != 0) {
|
if(not $force and $ret != 0) {
|
||||||
$output = $result;
|
$output = $result;
|
||||||
|
|
||||||
$output =~ s/code\.c:\d+:\d+://g;
|
$output =~ s/code\.c:\d+:\d+://g;
|
||||||
@ -129,9 +134,19 @@ if($ret != 0) {
|
|||||||
$output =~ s/= (-?\d+) ''/= $1/g;
|
$output =~ s/= (-?\d+) ''/= $1/g;
|
||||||
$output =~ s/, <incomplete sequence >//g;
|
$output =~ s/, <incomplete sequence >//g;
|
||||||
$output =~ s/\s*error: expected ';' before 'return'//g;
|
$output =~ s/\s*error: expected ';' before 'return'//g;
|
||||||
|
$output =~ s/^\s+//;
|
||||||
|
$output =~ s/\s+$//;
|
||||||
|
$output =~ s/error: ISO C forbids nested functions\s+//g;
|
||||||
|
|
||||||
print "$output\n";
|
# don't error about undeclared objects
|
||||||
exit 0;
|
$output =~ s/error: '[^']+' undeclared\s*//g;
|
||||||
|
|
||||||
|
if(length $output) {
|
||||||
|
print "$output\n";
|
||||||
|
exit 0;
|
||||||
|
} else {
|
||||||
|
$output = undef;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = `./c2e 2>/dev/null code.c` if not defined $output;
|
$output = `./c2e 2>/dev/null code.c` if not defined $output;
|
||||||
|
Loading…
Reference in New Issue
Block a user