3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-26 20:52:37 +01:00

modules/compiler_vm: fix -noheaders; manually #including a header once again replaces default includes

This commit is contained in:
Pragmatic Software 2021-09-17 13:30:46 -07:00
parent e00ba2e62f
commit eae16b14b8
3 changed files with 14 additions and 10 deletions

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4390,
BUILD_DATE => "2021-09-14",
BUILD_REVISION => 4405,
BUILD_DATE => "2021-09-17",
};
sub initialize {}

View File

@ -68,7 +68,11 @@ sub process_custom_options {
my $self = shift;
$self->add_option("-nomain") if $self->{code} =~ s/(?:^|(?<=\s))-nomain\s*//i;
$self->add_option("-noheaders") if $self->{code} =~ s/(?:^|(?<=\s))-noheaders\s*//i;
if ($self->{code} =~ s/(?:^|(?<=\s))-noheaders\s*//i) {
$self->add_option("-noheaders");
$self->{no_gdb_extensions} = 1;
}
$self->{include_options} = "";
while ($self->{code} =~ s/(?:^|(?<=\s))-include\s+(\S+)\s+//) {
@ -99,7 +103,7 @@ sub pretty_format {
sub preprocess_code {
my $self = shift;
$self->SUPER::preprocess_code;
$self->SUPER::preprocess_code(omit_prelude => 1);
my $default_prelude = exists $self->{options}->{'-noheaders'} ? '' : $self->{prelude};
@ -208,7 +212,7 @@ sub preprocess_code {
}
}
if (not $self->{no_gdb_extensions} and $prelude !~ m/^#include <prelude.h>/mg) {
if (not exists $self->{options}->{'-noheaders'} and not $self->{no_gdb_extensions} and $prelude !~ m/^#include <prelude.h>/mg) {
$prelude .= "\n#include <prelude.h>\n";
}

View File

@ -60,7 +60,7 @@ sub pretty_format {
}
sub preprocess_code {
my $self = shift;
my ($self, %opts) = @_;
if ($self->{only_show}) {
print "$self->{code}\n";
@ -74,10 +74,6 @@ sub preprocess_code {
close FILE;
}
if (exists $self->{prelude}) {
$self->{code} = "$self->{prelude}\n$self->{code}";
}
# replace \n outside of quotes with literal newline
my $new_code = "";
@ -133,6 +129,10 @@ sub preprocess_code {
$new_code .= $ch;
}
if (!$opts{omit_prelude} && exists $self->{prelude}) {
$self->{code} = "$self->{prelude}\n$self->{code}";
}
$self->{code} = $new_code;
}