summaryrefslogtreecommitdiff
path: root/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
diff options
context:
space:
mode:
Diffstat (limited to 'dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm')
-rw-r--r--dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm64
1 files changed, 36 insertions, 28 deletions
diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
index ca71735a2e..bd832f5bbd 100644
--- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
+++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
@@ -308,34 +308,8 @@ EOF
my $ln = shift(@{ $self->{line} });
print $ln, "\n";
next unless $ln =~ /^\#\s*((if)(?:n?def)?|elsif|else|endif)\b/;
- my $statement = $+;
- if ($statement eq 'if') {
- $XSS_work_idx = @{ $self->{XSStack} };
- push(@{ $self->{XSStack} }, {type => 'if'});
- }
- else {
- death ("Error: `$statement' with no matching `if'")
- if $self->{XSStack}->[-1]{type} ne 'if';
- if ($self->{XSStack}->[-1]{varname}) {
- push(@{ $self->{InitFileCode} }, "#endif\n");
- push(@{ $BootCode_ref }, "#endif");
- }
-
- my(@fns) = keys %{$self->{XSStack}->[-1]{functions}};
- if ($statement ne 'endif') {
- # Hide the functions defined in other #if branches, and reset.
- @{$self->{XSStack}->[-1]{other_functions}}{@fns} = (1) x @fns;
- @{$self->{XSStack}->[-1]}{qw(varname functions)} = ('', {});
- }
- else {
- my($tmp) = pop(@{ $self->{XSStack} });
- 0 while (--$XSS_work_idx
- && $self->{XSStack}->[$XSS_work_idx]{type} ne 'if');
- # Keep all new defined functions
- push(@fns, keys %{$tmp->{other_functions}});
- @{$self->{XSStack}->[$XSS_work_idx]{functions}}{@fns} = (1) x @fns;
- }
- }
+ ( $XSS_work_idx, $BootCode_ref ) =
+ print_preprocessor_statements( $self, $XSS_work_idx, $BootCode_ref );
}
next PARAGRAPH unless @{ $self->{line} };
@@ -1947,4 +1921,38 @@ sub death {
exit 1;
}
+sub print_preprocessor_statements {
+ my ($self, $XSS_work_idx, $BootCode_ref) = @_;
+
+ my $statement = $+;
+ if ($statement eq 'if') {
+ $XSS_work_idx = @{ $self->{XSStack} };
+ push(@{ $self->{XSStack} }, {type => 'if'});
+ }
+ else {
+ death ("Error: `$statement' with no matching `if'")
+ if $self->{XSStack}->[-1]{type} ne 'if';
+ if ($self->{XSStack}->[-1]{varname}) {
+ push(@{ $self->{InitFileCode} }, "#endif\n");
+ push(@{ $BootCode_ref }, "#endif");
+ }
+
+ my(@fns) = keys %{$self->{XSStack}->[-1]{functions}};
+ if ($statement ne 'endif') {
+ # Hide the functions defined in other #if branches, and reset.
+ @{$self->{XSStack}->[-1]{other_functions}}{@fns} = (1) x @fns;
+ @{$self->{XSStack}->[-1]}{qw(varname functions)} = ('', {});
+ }
+ else {
+ my($tmp) = pop(@{ $self->{XSStack} });
+ 0 while (--$XSS_work_idx
+ && $self->{XSStack}->[$XSS_work_idx]{type} ne 'if');
+ # Keep all new defined functions
+ push(@fns, keys %{$tmp->{other_functions}});
+ @{$self->{XSStack}->[$XSS_work_idx]{functions}}{@fns} = (1) x @fns;
+ }
+ }
+ return ($XSS_work_idx, $BootCode_ref);
+}
+
1;