mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-01 23:14:09 +01:00
compiler_vm:
Fix comment stripping logic regarding C89 comments versus C99 comments in code like `int i = 10 //**/ 2\n;` Code history now includes argument flags Improved regex parsing of diff tags
This commit is contained in:
parent
4adedc2a90
commit
522b9770dd
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 425,
|
||||
BUILD_DATE => "2013-08-24",
|
||||
BUILD_REVISION => 426,
|
||||
BUILD_DATE => "2013-08-26",
|
||||
};
|
||||
|
||||
1;
|
||||
|
@ -189,8 +189,8 @@ if($code =~ m/^\s*diff\s*$/i) {
|
||||
if($diff !~ /(?:<del>|<ins>)/) {
|
||||
$diff = "No difference.";
|
||||
} else {
|
||||
$diff =~ s/<del>([^\s]+)(\s+)<\/del>/<del>$1<\/del>$2/g;
|
||||
$diff =~ s/<ins>([^\s]+)(\s+)<\/ins>/<ins>$1<\/ins>$2/g;
|
||||
$diff =~ s/<del>(.*?)(\s+)<\/del>/<del>$1<\/del>$2/g;
|
||||
$diff =~ s/<ins>(.*?)(\s+)<\/ins>/<ins>$1<\/ins>$2/g;
|
||||
$diff =~ s/<del>((?:(?!<del>).)*)<\/del>\s*<ins>((?:(?!<ins>).)*)<\/ins>/<[replaced `$1` with `$2`]>/g;
|
||||
$diff =~ s/<del>(.*?)<\/del>/<[removed `$1`]>/g;
|
||||
$diff =~ s/<ins>(.*?)<\/ins>/<[inserted `$1`]>/g;
|
||||
@ -468,7 +468,9 @@ if($code =~ m/^\s*(run|paste)\s*$/i) {
|
||||
};
|
||||
|
||||
if($@) {
|
||||
print "$nick: $@\n";
|
||||
my $foo = $@;
|
||||
$foo =~ s/ at \.\/compiler_vm_client.pl line \d+\.\s*//;
|
||||
print "$nick: $foo\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
@ -551,7 +553,9 @@ if($code =~ m/^\s*(run|paste)\s*$/i) {
|
||||
};
|
||||
|
||||
if($@) {
|
||||
print "$nick: $@\n";
|
||||
my $foo = $@;
|
||||
$foo =~ s/ at \.\/compiler_vm_client.pl line \d+\.\s*//;
|
||||
print "$nick: $foo\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
@ -574,7 +578,7 @@ if($code =~ m/^\s*(run|paste)\s*$/i) {
|
||||
open FILE, "> last_code.txt";
|
||||
|
||||
unless ($got_undo and not $got_changes) {
|
||||
unshift @last_code, $code;
|
||||
unshift @last_code, length $args ? $args . ' ' . $code : $code;
|
||||
}
|
||||
|
||||
my $i = 0;
|
||||
@ -771,7 +775,13 @@ if($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') {
|
||||
print "*** prelude: [$prelude]\n precode: [$precode]\n" if $debug;
|
||||
|
||||
# strip C and C++ style comments
|
||||
$precode =~ s#/\*[^*]*\*+([^/*][^*]*\*+)*/|//([^\\]|[^\n][\n]?)*?\n|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#defined $3 ? $3 : " "#gse;
|
||||
if($lang eq 'C89' or $args =~ m/-std=(gnu89|c89)/i) {
|
||||
$precode =~ s#/\*[^*]*\*+([^/*][^*]*\*+)*/# #gs;
|
||||
$precode =~ s#|//([^\\]|[^\n][\n]?)*?\n|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#defined $2 ? $2 : " "#gse;
|
||||
} else {
|
||||
$precode =~ s#|//([^\\]|[^\n][\n]?)*?\n|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#defined $2 ? $2 : " "#gse;
|
||||
$precode =~ s#/\*[^*]*\*+([^/*][^*]*\*+)*/# #gs;
|
||||
}
|
||||
|
||||
print " precode: [$precode]\n" if $debug;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user