/home/cpancover/.cpan/build/Inline-0.54_02-0/blib/lib/Inline/C.pm

filter: Statementstmt 55.6% 287 / 516 Branchbran 26.7% 84 / 314 Conditioncond 26.5% 22 / 83 MC/DCmcdc 6.1% 3 / 49 Subroutinesub 77.0% 37 / 48 Podpod 0.0% 0 / 39 totaltotal 41.2% 433 / 1049 CC 200 SCAR 65.7
CC
200
Cov
43%
validate
2773.6
quote_space
240.0
xs_bindings
66.8
CRAP 713.6
↑ Summary blib/lib/Inline/C.pm »
1 package Inline::C;
2 1 $Inline::C::VERSION = '0.54_02';
3 1 $Inline::C::VERSION = eval $Inline::C::VERSION;
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 require Inline;
7 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Cwd qw(cwd abs_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 @Inline::C::ISA = qw(Inline);
14  
15 #==============================================================================
16 # Register this module as an Inline language support module
17 #==============================================================================
18 sub register {
19 return {
20 language => 'C',
21 # XXX Breaking this on purpose; let's see who screams
22 # aliases => ['c'],
23 type => 'compiled',
24 suffix => $Config{dlext},
25 0 ▶ };
Subroutine register: not called CC=1 SCAR=6.9
Pod undocumented
26 }
27  
28 #==============================================================================
29 # Validate the C config options
30 #==============================================================================
31 sub usage_validate {
32 0 ▶ my $key = shift;
Subroutine usage_validate: not called CC=1 SCAR=6.9
Pod undocumented
33 0 return <<END;
34 The value of config option '$key' must be a string or an array ref
35  
36 END
37 }
38  
39 sub validate {
40 4 ▶ my $o = shift;
Subroutine validate: called CC=61 SCAR=79.3
Pod undocumented
41  
42 4 ▶ print STDERR "validate Stage\n" if $o->{CONFIG}{BUILD_NOISY};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"BUILD_NOISY"} 0 4 4
43 4 ▶ $o->{ILSM} ||= {};
Condition50%1/2
$o->{"ILSM"} ||= {}
l!l
04
MC/DC0%0/1
$o->{"ILSM"} ||= {}
$o->{"ILSM"}
Truth table50%1/2
A
A= $o->{"ILSM"}
Aresult
11
00
44 4 ▶ $o->{ILSM}{XS} ||= {};
Condition50%1/2
$o->{"ILSM"}{"XS"} ||= {}
l!l
04
MC/DC0%0/1
$o->{"ILSM"}{"XS"} ||= {}
$o->{"ILSM"}{"XS"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"XS"}
Aresult
11
00
45 4 ▶ $o->{ILSM}{MAKEFILE} ||= {};
Condition50%1/2
$o->{"ILSM"}{"MAKEFILE"} ||= {}
l!l
04
MC/DC0%0/1
$o->{"ILSM"}{"MAKEFILE"} ||= {}
$o->{"ILSM"}{"MAKEFILE"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"MAKEFILE"}
Aresult
11
00
46 4 ▶ if (not $o->UNTAINT) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($o->UNTAINT) 0 4 4
47 0 require FindBin;
48 0 ▶ $o->{ILSM}{MAKEFILE}{INC} = "-I\"$FindBin::Bin\"" if not defined $o->{ILSM}{MAKEFILE}{INC};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o->{"ILSM"}{"MAKEFILE"}{"INC"} 0 0 0
49 }
50 4 ▶ $o->{ILSM}{AUTOWRAP} = 0 if not defined $o->{ILSM}{AUTOWRAP};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o->{"ILSM"}{"AUTOWRAP"} 4 0 4
51 4 ▶ $o->{ILSM}{XSMODE} = 0 if not defined $o->{ILSM}{XSMODE};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o->{"ILSM"}{"XSMODE"} 4 0 4
52 4 ▶ $o->{ILSM}{AUTO_INCLUDE} ||= <<END;
Condition50%1/2
$o->{"ILSM"}{"AUTO_INCLUDE"} ||= qq[#include "EXTERN.h"\n#include "perl.h"\n#include "XSUB.h"\n#include "INLINE.h"\n]
l!l
04
MC/DC0%0/1
$o->{"ILSM"}{"AUTO_INCLUDE"} ||= qq[#include "EXTERN.h"\n#include "perl.h"\n#include "XSUB.h"\n#include "INLINE.h"\n]
$o->{"ILSM"}{"AUTO_INCLUDE"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"AUTO_INCLUDE"}
Aresult
11
00
53 #include "EXTERN.h"
54 #include "perl.h"
55 #include "XSUB.h"
56 #include "INLINE.h"
57 END
58 4 ▶ $o->{ILSM}{FILTERS} ||= [];
Condition50%1/2
$o->{"ILSM"}{"FILTERS"} ||= []
l!l
04
MC/DC0%0/1
$o->{"ILSM"}{"FILTERS"} ||= []
$o->{"ILSM"}{"FILTERS"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"FILTERS"}
Aresult
11
00
59 $o->{STRUCT} ||= {
60 4 ▶ '.macros' => '',
Condition50%1/2
$o->{"STRUCT"} ||= {".macros", "", ".xs", "", ".any", 0, ".all", 0}
l!l
04
MC/DC0%0/1
$o->{"STRUCT"} ||= {".macros", "", ".xs", "", ".any", 0, ".all", 0}
$o->{"STRUCT"}
Truth table50%1/2
A
A= $o->{"STRUCT"}
Aresult
11
00
61 '.xs' => '',
62 '.any' => 0,
63 '.all' => 0,
64 };
65  
66 4 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 4 4
67 0 my ($key, $value) = (shift, shift);
68 0 ▶ if ($key eq 'PRE_HEAD') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "PRE_HEAD") 0 0 0
69 0 ▶ unless( -f $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $value) { } 0 0 0
70 0 $o->{ILSM}{AUTO_INCLUDE} = $value . "\n" . $o->{ILSM}{AUTO_INCLUDE};
71 }
72 else {
73 0 my $insert;
74 0 ▶ open RD, '<', $value or die "Couldn't open $value for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open RD, "<", $value or die "Couldn't open $value for reading: $!" 0 0 0
75 0 ▶ while(<RD>) {$insert .= $_}
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline RD)) 0 0 0
76 0 ▶ close RD or die "Couldn't close $value after reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
close RD or die "Couldn't close $value after reading: $!" 0 0 0
77 0 $o->{ILSM}{AUTO_INCLUDE} = $insert . "\n" . $o->{ILSM}{AUTO_INCLUDE};
78 }
79 0 next;
80 }
81 0 ▶ if ($key eq 'MAKE' or
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "MAKE" or $key eq "AUTOWRAP" or $key eq "XSMODE") 0 0 0
Condition0%0/6
$key eq "MAKE" or $key eq "AUTOWRAP" or $key eq "XSMODE"
l!l&&r!l&&!r
000
$key eq "MAKE" or $key eq "AUTOWRAP"
l!l&&r!l&&!r
000
MC/DC0%0/3
$key eq "MAKE" or $key eq "AUTOWRAP" or $key eq "XSMODE"
$key eq "MAKE" $key eq "AUTOWRAP" $key eq "XSMODE"
Truth table0%0/4
A or B or C
A= $key eq "MAKE"B= $key eq "AUTOWRAP"C= $key eq "XSMODE"
ABCresult
1XX1
01X1
0011
0000
82 $key eq 'AUTOWRAP' or
83 $key eq 'XSMODE'
84 ) {
85 0 $o->{ILSM}{$key} = $value;
86 0 next;
87 }
88 0 ▶ if ($key eq 'CC' or
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "CC" or $key eq "LD") 0 0 0
Condition0%0/3
$key eq "CC" or $key eq "LD"
l!l&&r!l&&!r
000
MC/DC0%0/2
$key eq "CC" or $key eq "LD"
$key eq "CC" $key eq "LD"
Truth table0%0/3
A or B
A= $key eq "CC"B= $key eq "LD"
ABresult
1X1
011
000
89 $key eq 'LD') {
90 0 $o->{ILSM}{MAKEFILE}{$key} = $value;
91 0 next;
92 }
93 0 ▶ if ($key eq 'LIBS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "LIBS") 0 0 0
94 0 $o->add_list($o->{ILSM}{MAKEFILE}, $key, $value, []);
95 0 next;
96 }
97 0 ▶ if ($key eq 'INC') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "INC") 0 0 0
98 0 $o->add_string($o->{ILSM}{MAKEFILE}, $key, quote_space($value), '');
99 0 next;
100 }
101 0 ▶ if ($key eq 'MYEXTLIB' or
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "MYEXTLIB" or $key eq "OPTIMIZE" or $key eq "CCFLAGS" or $key eq "LDDLFLAGS") 0 0 0
Condition0%0/9
$key eq "MYEXTLIB" or $key eq "OPTIMIZE" or $key eq "CCFLAGS" or $key eq "LDDLFLAGS"
l!l&&r!l&&!r
000
$key eq "MYEXTLIB" or $key eq "OPTIMIZE" or $key eq "CCFLAGS"
l!l&&r!l&&!r
000
$key eq "MYEXTLIB" or $key eq "OPTIMIZE"
l!l&&r!l&&!r
000
MC/DC0%0/4
$key eq "MYEXTLIB" or $key eq "OPTIMIZE" or $key eq "CCFLAGS" or $key eq "LDDLFLAGS"
$key eq "MYEXTLIB" $key eq "OPTIMIZE" $key eq "CCFLAGS" $key eq "LDDLFLAGS"
Truth table0%0/5
A or B or C or D
A= $key eq "MYEXTLIB"B= $key eq "OPTIMIZE"C= $key eq "CCFLAGS"D= $key eq "LDDLFLAGS"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
102 $key eq 'OPTIMIZE' or
103 $key eq 'CCFLAGS' or
104 $key eq 'LDDLFLAGS') {
105 0 $o->add_string($o->{ILSM}{MAKEFILE}, $key, $value, '');
106 0 next;
107 }
108 0 ▶ if ($key eq 'CCFLAGSEX') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "CCFLAGSEX") 0 0 0
109 0 $o->add_string($o->{ILSM}{MAKEFILE}, 'CCFLAGS', $Config{ccflags} . ' ' . $value, '');
110 0 next;
111 }
112 0 ▶ if ($key eq 'TYPEMAPS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "TYPEMAPS") 0 0 0
113 0 ▶ unless(ref($value) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 0 0 0
114 0 ▶ croak "TYPEMAPS file '$value' not found"
Branch: 1 branch
BranchTrueFalseTotal
unless -f $value 0 0 0
115 unless -f $value;
116 0 $value = File::Spec->rel2abs($value);
117 }
118 else {
119 0 ▶ for (my $i = 0; $i < scalar(@$value); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$value) 0 0 0
120 0 croak "TYPEMAPS file '${$value}[$i]' not found"
121 0 ▶ unless -f ${$value}[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless -f do { $value }->[$i] 0 0 0
122 0 ${$value}[$i] = File::Spec->rel2abs(${$value}[$i]);
123 }
124 }
125 0 $o->add_list($o->{ILSM}{MAKEFILE}, $key, $value, []);
126 0 next;
127 }
128 0 ▶ if ($key eq 'AUTO_INCLUDE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "AUTO_INCLUDE") 0 0 0
129 0 $o->add_text($o->{ILSM}, $key, $value, '');
130 0 next;
131 }
132 0 ▶ if ($key eq 'BOOT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "BOOT") 0 0 0
133 0 $o->add_text($o->{ILSM}{XS}, $key, $value, '');
134 0 next;
135 }
136 0 ▶ if ($key eq 'PREFIX') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "PREFIX") 0 0 0
137 0 ▶ croak "Invalid value for 'PREFIX' option"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^\w*$/ and not $value =~ /\n/ 0 0 0
Condition0%0/3
$value =~ /^\w*$/ and not $value =~ /\n/
!ll&&!rl&&r
000
MC/DC0%0/2
$value =~ /^\w*$/ and not $value =~ /\n/
$value =~ /^\w*$/ not $value =~ /\n/
Truth table0%0/3
A and not(B)
A= $value =~ /^\w*$/B= not $value =~ /\n/
ABresult
0X0
100
111
138 unless ($value =~ /^\w*$/ and
139 $value !~ /\n/);
140 0 $o->{ILSM}{XS}{PREFIX} = $value;
141 0 next;
142 }
143 0 ▶ if ($key eq 'FILTERS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "FILTERS") 0 0 0
144 0 ▶ next if $value eq '1' or $value eq '0'; # ignore ENABLE, DISABLE
Branch: 1 branch
BranchTrueFalseTotal
if $value eq 1 or $value eq 0 0 0 0
Condition0%0/3
$value eq 1 or $value eq 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$value eq 1 or $value eq 0
$value eq 1 $value eq 0
Truth table0%0/3
A or B
A= $value eq 1B= $value eq 0
ABresult
1X1
011
000
145 0 ▶ $value = [$value] unless ref($value) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "ARRAY" 0 0 0
146 0 my %filters;
147 0 for my $val (@$value) {
148 0 ▶ if (ref($val) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq 'CODE') { } 0 0 0
149 0 $o->add_list($o->{ILSM}, $key, $val, []);
150 }
151 else {
152 0 eval { require Inline::Filters };
153 0 ▶ croak "'FILTERS' option requires Inline::Filters to be installed."
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
154 if $@;
155 %filters = Inline::Filters::get_filters($o->{API}{language})
156 0 ▶ unless keys %filters;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %filters 0 0 0
157 0 ▶ if (defined $filters{$val}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $filters{$val}) { } 0 0 0
158 my $filter = Inline::Filters->new($val,
159 0 $filters{$val});
160 0 $o->add_list($o->{ILSM}, $key, $filter, []);
161 }
162 else {
163 0 croak "Invalid filter $val specified.";
164 }
165 }
166 }
167 0 next;
168 }
169 0 ▶ if ($key eq 'STRUCTS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "STRUCTS") 0 0 0
170 # A list of struct names
171 0 ▶ if (ref($value) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 0 0 0
elsif ($value =~ /^\d+$/) { } 0 0 0
172 0 for my $val (@$value) {
173 0 ▶ croak "Invalid value for 'STRUCTS' option"
Branch: 1 branch
BranchTrueFalseTotal
unless $val =~ /^[_a-z][_0-9a-z]*$/i 0 0 0
174 unless ($val =~ /^[_a-z][_0-9a-z]*$/i);
175 0 $o->{STRUCT}{$val}++;
176 }
177 }
178 # Enable or disable
179 elsif ($value =~ /^\d+$/) {
180 0 $o->{STRUCT}{'.any'} = $value;
181 }
182 # A single struct name
183 else {
184 0 ▶ croak "Invalid value for 'STRUCTS' option"
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[_a-z][_0-9a-z]*$/i 0 0 0
185 unless ($value =~ /^[_a-z][_0-9a-z]*$/i);
186 0 $o->{STRUCT}{$value}++;
187 }
188 0 eval { require Inline::Struct };
189 0 ▶ croak "'STRUCTS' option requires Inline::Struct to be installed."
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
190 if $@;
191 0 $o->{STRUCT}{'.any'} = 1;
192 0 next;
193 }
194 0 ▶ if($key eq 'PROTOTYPES') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "PROTOTYPES") 0 0 0
195 0 $o->{CONFIG}{PROTOTYPES} = $value;
196 0 ▶ next if $value eq 'ENABLE';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "ENABLE" 0 0 0
197 0 ▶ next if $value eq 'DISABLE';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "DISABLE" 0 0 0
198 0 die "PROTOTYPES can be only either 'ENABLE' or 'DISABLE' - not $value";
199 }
200 0 ▶ if($key eq 'PROTOTYPE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "PROTOTYPE") 0 0 0
201 0 ▶ die "PROTOTYPE configure arg must specify a hash reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 0 0 0
202 unless ref($value) eq 'HASH';
203 0 $o->{CONFIG}{PROTOTYPE} = $value;
204 0 next;
205 }
206 0 my $class = ref $o; # handles subclasses correctly.
207 0 croak "'$key' is not a valid config option for $class\n";
208 }
209 }
210  
211 sub add_list {
212 0 ▶ my $o = shift;
Subroutine add_list: not called CC=4 SCAR=30.0
Pod undocumented
213 0 my ($ref, $key, $value, $default) = @_;
214 0 ▶ $value = [$value] unless ref $value eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "ARRAY" 0 0 0
215 0 for (@$value) {
216 0 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 0 0
217 0 push @{$ref->{$key}}, $_;
218 }
219 else {
220 0 $ref->{$key} = $default;
221 }
222 }
223 }
224  
225 sub add_string {
226 0 ▶ my $o = shift;
Subroutine add_string: not called CC=5 SCAR=34.0
Pod undocumented
227 0 my ($ref, $key, $value, $default) = @_;
228 0 ▶ $value = [$value] unless ref $value;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value 0 0 0
229 0 ▶ croak usage_validate($key) unless ref($value) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "ARRAY" 0 0 0
230 0 for (@$value) {
231 0 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 0 0
232 0 $ref->{$key} .= ' ' . $_;
233 }
234 else {
235 0 $ref->{$key} = $default;
236 }
237 }
238 }
239  
240 sub add_text {
241 0 ▶ my $o = shift;
Subroutine add_text: not called CC=5 SCAR=34.0
Pod undocumented
242 0 my ($ref, $key, $value, $default) = @_;
243 0 ▶ $value = [$value] unless ref $value;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value 0 0 0
244 0 ▶ croak usage_validate($key) unless ref($value) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "ARRAY" 0 0 0
245 0 for (@$value) {
246 0 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 0 0
247 0 chomp;
248 0 $ref->{$key} .= $_ . "\n";
249 }
250 else {
251 0 $ref->{$key} = $default;
252 }
253 }
254 }
255  
256 #==============================================================================
257 # Return a small report about the C code..
258 #==============================================================================
259 sub info {
260 0 ▶ my $o = shift;
Subroutine info: not called CC=5 SCAR=34.0
Pod undocumented
261 0 ▶ return <<END if $o->{ILSM}{XSMODE};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"ILSM"}{"XSMODE"} 0 0 0
262 No information is currently generated when using XSMODE.
263  
264 END
265 0 my $text = '';
266 0 $o->preprocess;
267 0 $o->parse;
268 0 ▶ if (defined $o->{ILSM}{parser}{data}{functions}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o->{'ILSM'}{'parser'}{'data'}{'functions'}) { } 0 0 0
269 0 $text .= "The following Inline $o->{API}{language} function(s) have been successfully bound to Perl:\n";
270 0 my $parser = $o->{ILSM}{parser};
271 0 my $data = $parser->{data};
272 0 for my $function (sort @{$data->{functions}}) {
273 0 my $return_type = $data->{function}{$function}{return_type};
274 0 my @arg_names = @{$data->{function}{$function}{arg_names}};
275 0 my @arg_types = @{$data->{function}{$function}{arg_types}};
276 0 my @args = map {$_ . ' ' . shift @arg_names} @arg_types;
277 0 $text .= "\t$return_type $function(" . join(', ', @args) . ")\n";
278 }
279 }
280 else {
281 0 $text .= "No $o->{API}{language} functions have been successfully bound to Perl.\n\n";
282 }
283 0 ▶ $text .= Inline::Struct::info($o) if $o->{STRUCT}{'.any'};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"STRUCT"}{".any"} 0 0 0
284 0 return $text;
285 }
286  
287 sub config {
288 0 ▶ my $o = shift;
Subroutine config: not called CC=1 SCAR=6.9
Pod undocumented
289 }
290  
291 #==============================================================================
292 # Parse and compile C code
293 #==============================================================================
294 1 my $total_build_time;
295 sub build {
296 4 ▶ my $o = shift;
Subroutine build: called CC=4 SCAR=17.5
Pod undocumented
297  
298 4 ▶ if ($o->{CONFIG}{BUILD_TIMERS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"CONFIG"}{"BUILD_TIMERS"}) 0 4 4
299 0 eval {require Time::HiRes};
300 0 ▶ croak "You need Time::HiRes for BUILD_TIMERS option:\n$@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
301 0 $total_build_time = Time::HiRes::time();
302 }
303 4 $o->call('preprocess', 'Build Preprocess');
304 4 $o->call('parse', 'Build Parse');
305 4 $o->call('write_XS', 'Build Glue 1');
306 4 $o->call('write_Inline_headers', 'Build Glue 2');
307 4 $o->call('write_Makefile_PL', 'Build Glue 3');
308 4 $o->call('compile', 'Build Compile');
309 4 ▶ if ($o->{CONFIG}{BUILD_TIMERS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"CONFIG"}{"BUILD_TIMERS"}) 0 4 4
310 0 $total_build_time = Time::HiRes::time() - $total_build_time;
311 0 printf STDERR "Total Build Time: %5.4f secs\n", $total_build_time;
312 }
313 }
314  
315 sub call {
316 40 ▶ my ($o, $method, $header, $indent) = (@_, 0);
Subroutine call: called CC=7 SCAR=20.8
Pod undocumented
317 40 my $time;
318 40 my $i = ' ' x $indent;
319 40 ▶ print STDERR "${i}Starting $header Stage\n" if $o->{CONFIG}{BUILD_NOISY};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"BUILD_NOISY"} 0 40 40
320 $time = Time::HiRes::time()
321 40 ▶ if $o->{CONFIG}{BUILD_TIMERS};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"BUILD_TIMERS"} 0 40 40
322  
323 40 $o->$method();
324  
325 $time = Time::HiRes::time() - $time
326 40 ▶ if $o->{CONFIG}{BUILD_TIMERS};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"BUILD_TIMERS"} 0 40 40
327 40 ▶ print STDERR "${i}Finished $header Stage\n" if $o->{CONFIG}{BUILD_NOISY};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"BUILD_NOISY"} 0 40 40
328 printf STDERR "${i}Time for $header Stage: %5.4f secs\n", $time
329 40 ▶ if $o->{CONFIG}{BUILD_TIMERS};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"BUILD_TIMERS"} 0 40 40
330 40 ▶ print STDERR "\n" if $o->{CONFIG}{BUILD_NOISY};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"BUILD_NOISY"} 0 40 40
331 }
332  
333 #==============================================================================
334 # Apply any
335 #==============================================================================
336 sub preprocess {
337 4 ▶ my $o = shift;
Subroutine preprocess: called CC=2 SCAR=7.0
Pod undocumented
338 4 ▶ return if $o->{ILSM}{parser};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"ILSM"}{"parser"} 0 4 4
339 4 $o->get_maps;
340 4 $o->get_types;
341 4 $o->{ILSM}{code} = $o->filter(@{$o->{ILSM}{FILTERS}});
342 }
343  
344 #==============================================================================
345 # Parse the function definition information out of the C code
346 #==============================================================================
347 sub parse {
348 4 ▶ my $o = shift;
Subroutine parse: called CC=5 SCAR=17.3
Pod undocumented
349 4 ▶ return if $o->{ILSM}{parser};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"ILSM"}{"parser"} 0 4 4
350 4 ▶ return if $o->{ILSM}{XSMODE};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"ILSM"}{"XSMODE"} 0 4 4
351 4 my $parser = $o->{ILSM}{parser} = $o->get_parser;
352 4 $parser->{data}{typeconv} = $o->{ILSM}{typeconv};
353 4 $parser->{data}{AUTOWRAP} = $o->{ILSM}{AUTOWRAP};
354 4 ▶ Inline::Struct::parse($o) if $o->{STRUCT}{'.any'};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"STRUCT"}{".any"} 0 4 4
355 $parser->code($o->{ILSM}{code})
356 4 ▶ or croak <<END;
Branch: 1 branch
BranchTrueFalseTotal
$parser->code($o->{"ILSM"}{"code"}) or croak(qq[Bad $o->{"API"}{"language"} code passed to Inline at @{[&CORE::GLOBAL::caller(2)];}\n]) 0 4 4
357 0 Bad $o->{API}{language} code passed to Inline at @{[caller(2)]}
358 END
359 }
360  
361 # Create and initialize a parser
362 sub get_parser {
363 4 ▶ my $o = shift;
Subroutine get_parser: called CC=2 SCAR=7.0
Pod undocumented
364 4 ▶ Inline::C::_parser_test("Inline::C::get_parser called\n") if $o->{CONFIG}{_TESTING};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"_TESTING"} 0 4 4
365 4 require Inline::C::ParseRecDescent;
366 4 Inline::C::ParseRecDescent::get_parser($o);
367 }
368  
369 #==============================================================================
370 # Gather the path names of all applicable typemap files.
371 #==============================================================================
372 sub get_maps {
373 4 ▶ my $o = shift;
Subroutine get_maps: called CC=10 SCAR=29.8
Pod undocumented
374  
375 4 ▶ print STDERR "get_maps Stage\n" if $o->{CONFIG}{BUILD_NOISY};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"CONFIG"}{"BUILD_NOISY"} 0 4 4
376 4 my $typemap = '';
377 4 my $file;
378 4 $file = File::Spec->catfile($Config::Config{installprivlib},"ExtUtils","typemap");
379 4 ▶ $typemap = $file if -f $file;
Branch: 1 branch
BranchTrueFalseTotal
if -f $file 4 0 4
380 4 $file = File::Spec->catfile($Config::Config{privlibexp} ,"ExtUtils","typemap");
381 4 ▶ $typemap = $file
Branch: 1 branch
BranchTrueFalseTotal
if not $typemap and -f $file 0 4 4
Condition33%1/3
not $typemap and -f $file
!ll&&!rl&&r
400
MC/DC0%0/2
not $typemap and -f $file
not $typemap -f $file
Truth table33%1/3
not(A) and B
A= not $typemapB= -f $file
ABresult
0X0
100
111
382 if (not $typemap and -f $file);
383 4 ▶ warn "Can't find the default system typemap file"
Branch: 1 branch
BranchTrueFalseTotal
if not $typemap and $^W 0 4 4
Condition33%1/3
not $typemap and $^W
!ll&&!rl&&r
400
MC/DC0%0/2
not $typemap and $^W
not $typemap $^W
Truth table33%1/3
not(A) and B
A= not $typemapB= $^W
ABresult
0X0
100
111
384 if (not $typemap and $^W);
385  
386 4 ▶ unshift(@{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}, $typemap) if $typemap;
Branch: 1 branch
BranchTrueFalseTotal
if $typemap 4 0 4
387  
388 4 ▶ if (not $o->UNTAINT) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $o->UNTAINT) 0 4 4
389 0 require FindBin;
390 0 $file = File::Spec->catfile($FindBin::Bin,"typemap");
391 0 ▶ if ( -f $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $file) 0 0 0
392 0 push(@{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}, $file);
393 }
394 }
395 }
396  
397 #==============================================================================
398 # This routine parses XS typemap files to get a list of valid types to create
399 # bindings to. This code is mostly hacked out of Larry Wall's xsubpp program.
400 #==============================================================================
401 sub get_types {
402 4 ▶ my (%type_kind, %proto_letter, %input_expr, %output_expr);
Subroutine get_types: called CC=19 SCAR=29.8
Pod undocumented
403 4 my $o = shift;
404 4 local $_;
405 croak "No typemaps specified for Inline C code"
406 4 ▶ unless @{$o->{ILSM}{MAKEFILE}{TYPEMAPS}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$o->{"ILSM"}{"MAKEFILE"}{"TYPEMAPS"};} 0 4 4
407  
408 4 my $proto_re = "[" . quotemeta('\$%&*@;') . "]";
409 4 foreach my $typemap (@{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}) {
410 4 ▶ next unless -e $typemap;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $typemap 0 4 4
411 # skip directories, binary files etc.
412 4 ▶ warn("Warning: ignoring non-text typemap file '$typemap'\n"), next
Branch: 1 branch
BranchTrueFalseTotal
unless -T $typemap 0 4 4
413 unless -T $typemap;
414 4 ▶ open(TYPEMAP, $typemap)
Branch: 1 branch
BranchTrueFalseTotal
open TYPEMAP, $typemap or warn("Warning: could not open typemap file '${typemap}': $!\n"), next 0 4 4
415 or warn ("Warning: could not open typemap file '$typemap': $!\n"), next;
416 4 my $mode = 'Typemap';
417 4 my $junk = "";
418 4 my $current = \$junk;
419 4 ▶ while (<TYPEMAP>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline TYPEMAP)) 1908 4 1912
420 1908 ▶ next if /^\s*\#/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*\#/ 56 1852 1908
421 1852 my $line_no = $. + 1;
422 1852 ▶ if (/^INPUT\s*$/) {$mode = 'Input'; $current = \$junk; next}
Branch: 1 branch
BranchTrueFalseTotal
if (/^INPUT\s*$/) 4 1848 1852
423 1848 ▶ if (/^OUTPUT\s*$/) {$mode = 'Output'; $current = \$junk; next}
Branch: 1 branch
BranchTrueFalseTotal
if (/^OUTPUT\s*$/) 4 1844 1848
424 1844 ▶ if (/^TYPEMAP\s*$/) {$mode = 'Typemap'; $current = \$junk; next}
Branch: 1 branch
BranchTrueFalseTotal
if (/^TYPEMAP\s*$/) 0 1844 1844
425 1844 ▶ if ($mode eq 'Typemap') {
Branch: 3 branches
BranchTrueFalseTotal
if ($mode eq 'Typemap') { } 220 1624 1844
elsif (/^\s/) { } 1280 344 1624
elsif ($mode eq 'Input') { } 172 172 344
426 220 chomp;
427 220 my $line = $_;
428 220 TrimWhitespace($_);
429 # skip blank lines and comment lines
430 220 ▶ next if /^$/ or /^\#/;
Branch: 1 branch
BranchTrueFalseTotal
if /^$/ or /^\#/ 16 204 220
Condition66%2/3
/^$/ or /^\#/
l!l&&r!l&&!r
160204
MC/DC50%1/2
/^$/ or /^\#/
/^$/ /^\#/
Truth table66%2/3
A or B
A= /^$/B= /^\#/
ABresult
1X1
011
000
431 204 ▶ my ($type,$kind, $proto) =
Branch: 1 branch
BranchTrueFalseTotal
() = /^\s*(.*?\S)\s+(\S+)\s*($proto_re*)\s*$/ or warn("Warning: File '${typemap}' Line $. '${line}' TYPEMAP entry needs 2 or 3 columns\n"), next 0 204 204
432 /^\s*(.*?\S)\s+(\S+)\s*($proto_re*)\s*$/ or
433 warn("Warning: File '$typemap' Line $. '$line' TYPEMAP entry needs 2 or 3 columns\n"), next;
434 204 $type = TidyType($type);
435 204 $type_kind{$type} = $kind;
436 # prototype defaults to '$'
437 204 ▶ $proto = "\$" unless $proto;
Branch: 1 branch
BranchTrueFalseTotal
unless $proto 204 0 204
438 204 ▶ warn("Warning: File '$typemap' Line $. '$line' Invalid prototype '$proto'\n")
Branch: 1 branch
BranchTrueFalseTotal
unless &ValidProtoString($proto) 0 204 204
439 unless ValidProtoString($proto);
440 204 $proto_letter{$type} = C_string($proto);
441 }
442 elsif (/^\s/) {
443 1280 $$current .= $_;
444 }
445 elsif ($mode eq 'Input') {
446 172 s/\s+$//;
447 172 $input_expr{$_} = '';
448 172 $current = \$input_expr{$_};
449 }
450 else {
451 172 s/\s+$//;
452 172 $output_expr{$_} = '';
453 172 $current = \$output_expr{$_};
454 }
455 }
456 4 close(TYPEMAP);
457 }
458  
459 my %valid_types =
460 204 map {($_, 1)}
461 4 grep {defined $input_expr{$type_kind{$_}}}
462 keys %type_kind;
463  
464 my %valid_rtypes =
465 208 map {($_, 1)}
466 4 (grep {defined $output_expr{$type_kind{$_}}}
467 keys %type_kind), 'void';
468  
469 4 $o->{ILSM}{typeconv}{type_kind} = \%type_kind;
470 4 $o->{ILSM}{typeconv}{input_expr} = \%input_expr;
471 4 $o->{ILSM}{typeconv}{output_expr} = \%output_expr;
472 4 $o->{ILSM}{typeconv}{valid_types} = \%valid_types;
473 4 $o->{ILSM}{typeconv}{valid_rtypes} = \%valid_rtypes;
474 }
475  
476 sub ValidProtoString ($) {
477 204 ▶ my $string = shift;
Subroutine ValidProtoString: called CC=2 SCAR=7.1
Pod undocumented
478 204 my $proto_re = "[" . quotemeta('\$%&*@;') . "]";
479 204 ▶ return ($string =~ /^$proto_re+$/) ? $string : 0;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ /^$proto_re+$/ ? : 204 0 204
480 }
481  
482 sub TrimWhitespace {
483 424 ▶ $_[0] =~ s/^\s+|\s+$//go;
Subroutine TrimWhitespace: called CC=1 SCAR=0.0
Pod undocumented
484 }
485  
486 sub TidyType {
487 204 ▶ local $_ = shift;
Subroutine TidyType: called CC=1 SCAR=0.0
Pod undocumented
488 204 s|\s*(\*+)\s*|$1|g;
489 204 s|(\*+)| $1 |g;
490 204 s|\s+| |g;
491 204 TrimWhitespace($_);
492 204 $_;
493 }
494  
495 sub C_string ($) {
496 204 ▶ (my $string = shift) =~ s|\\|\\\\|g;
Subroutine C_string: called CC=1 SCAR=0.0
Pod undocumented
497 204 $string;
498 }
499  
500 #==============================================================================
501 # Write the XS code
502 #==============================================================================
503 sub write_XS {
504 4 ▶ my $o = shift;
Subroutine write_XS: called CC=5 SCAR=20.4
Pod undocumented
505 4 my $modfname = $o->{API}{modfname};
506 4 my $module = $o->{API}{module};
507 4 $o->mkpath($o->{API}{build_dir});
508 4 ▶ open XS, "> ".File::Spec->catfile($o->{API}{build_dir},"$modfname.xs")
Branch: 1 branch
BranchTrueFalseTotal
open XS, '> ' . "File::Spec"->catfile($o->{"API"}{"build_dir"}, "$modfname.xs") or croak($!) 0 4 4
509 or croak $!;
510 4 ▶ if ($o->{ILSM}{XSMODE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{'ILSM'}{'XSMODE'}) { } 0 4 4
511 0 ▶ warn <<END if $^W and $o->{ILSM}{code} !~ /MODULE\s*=\s*$module\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $^W and not $o->{"ILSM"}{"code"} =~ /MODULE\s*=\s*$module\b/ 0 0 0
Condition0%0/3
$^W and not $o->{"ILSM"}{"code"} =~ /MODULE\s*=\s*$module\b/
!ll&&!rl&&r
000
MC/DC0%0/2
$^W and not $o->{"ILSM"}{"code"} =~ /MODULE\s*=\s*$module\b/
$^W not $o->{"ILSM"}{"code"} =~ /MODULE\s*=\s*$module\b/
Truth table0%0/3
A and not(B)
A= $^WB= not $o->{"ILSM"}{"code"} =~ /MODULE\s*=\s*$module\b/
ABresult
0X0
100
111
512 While using Inline XSMODE, your XS code does not have a line with
513  
514 MODULE = $module
515  
516 You should use the Inline NAME config option, and it should match the
517 XS MODULE name.
518  
519 END
520 0 print XS $o->xs_code;
521 }
522 else {
523 4 print XS $o->xs_generate;
524 }
525 4 close XS;
526 }
527  
528 #==============================================================================
529 # Generate the XS glue code (piece together lots of snippets)
530 #==============================================================================
531 sub xs_generate {
532 4 ▶ my $o = shift;
Subroutine xs_generate: called CC=1 SCAR=0.0
Pod undocumented
533 4 return join '', ($o->xs_includes,
534 $o->xs_struct_macros,
535 $o->xs_code,
536 $o->xs_struct_code,
537 $o->xs_bindings,
538 $o->xs_boot,
539 );
540 }
541  
542 sub xs_includes {
543 4 ▶ my $o = shift;
Subroutine xs_includes: called CC=1 SCAR=0.0
Pod undocumented
544 4 return $o->{ILSM}{AUTO_INCLUDE};
545 }
546  
547 sub xs_struct_macros {
548 4 ▶ my $o = shift;
Subroutine xs_struct_macros: called CC=1 SCAR=0.0
Pod undocumented
549 4 return $o->{STRUCT}{'.macros'};
550 }
551  
552 sub xs_code {
553 4 ▶ my $o = shift;
Subroutine xs_code: called CC=1 SCAR=0.0
Pod undocumented
554 4 return $o->{ILSM}{code};
555 }
556  
557 sub xs_struct_code {
558 4 ▶ my $o = shift;
Subroutine xs_struct_code: called CC=1 SCAR=0.0
Pod undocumented
559 4 return $o->{STRUCT}{'.xs'};
560 }
561  
562 sub xs_boot {
563 4 ▶ my $o = shift;
Subroutine xs_boot: called CC=3 SCAR=13.3
Pod undocumented
564 4 ▶ if (defined $o->{ILSM}{XS}{BOOT} and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o->{"ILSM"}{"XS"}{"BOOT"} and $o->{"ILSM"}{"XS"}{"BOOT"}) 0 4 4
Condition33%1/3
defined $o->{"ILSM"}{"XS"}{"BOOT"} and $o->{"ILSM"}{"XS"}{"BOOT"}
!ll&&!rl&&r
400
MC/DC0%0/2
defined $o->{"ILSM"}{"XS"}{"BOOT"} and $o->{"ILSM"}{"XS"}{"BOOT"}
defined $o->{"ILSM"}{"XS"}{"BOOT"} $o->{"ILSM"}{"XS"}{"BOOT"}
Truth table33%1/3
A and B
A= defined $o->{"ILSM"}{"XS"}{"BOOT"}B= $o->{"ILSM"}{"XS"}{"BOOT"}
ABresult
0X0
100
111
565 $o->{ILSM}{XS}{BOOT}) {
566 0 return <<END;
567 BOOT:
568 $o->{ILSM}{XS}{BOOT}
569 END
570 }
571 4 return '';
572 }
573  
574 sub xs_bindings {
575 4 ▶ my $o = shift;
Subroutine xs_bindings: called CC=21 SCAR=42.0
Pod undocumented
576 4 my $dir = '_Inline_test';
577  
578 4 ▶ if($o->{CONFIG}{_TESTING}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"CONFIG"}{"_TESTING"}) 0 4 4
579 0 ▶ if(! -d $dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
580 0 my $ok = mkdir $dir;
581 0 ▶ warn $! if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
582 }
583  
584 0 ▶ if(! -f "$dir/void_test") {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f "$dir/void_test") 0 0 0
585 0 ▶ warn $! if !open(TEST_FH, '>', "$dir/void_test");
Branch: 1 branch
BranchTrueFalseTotal
unless open TEST_FH, ">", "$dir/void_test" 0 0 0
586 0 ▶ warn $! if !close(TEST_FH);
Branch: 1 branch
BranchTrueFalseTotal
unless close TEST_FH 0 0 0
587 }
588 }
589  
590 4 my ($pkg, $module) = @{$o->{API}}{qw(pkg module)};
591 4 ▶ my $prefix = (($o->{ILSM}{XS}{PREFIX}) ?
Branch: 1 branch
BranchTrueFalseTotal
$o->{'ILSM'}{'XS'}{'PREFIX'} ? : 0 4 4
592 "PREFIX = $o->{ILSM}{XS}{PREFIX}" :
593 '');
594  
595 my $prototypes = defined($o->{CONFIG}{PROTOTYPES}) ? $o->{CONFIG}{PROTOTYPES}
596 4 ▶ : 'DISABLE';
Branch: 1 branch
BranchTrueFalseTotal
defined $o->{'CONFIG'}{'PROTOTYPES'} ? : 0 4 4
597  
598 4 my $XS = <<END;
599  
600 MODULE = $module PACKAGE = $pkg $prefix
601  
602 PROTOTYPES: $prototypes
603  
604 END
605  
606 4 my $parser = $o->{ILSM}{parser};
607 4 my $data = $parser->{data};
608  
609 warn("Warning. No Inline C functions bound to Perl in ", $o->{API}{script}, "\n" .
610 "Check your C function definition(s) for Inline compatibility\n\n")
611 4 ▶ if ((not defined$data->{functions}) and ($^W));
Branch: 1 branch
BranchTrueFalseTotal
if not defined $data->{"functions"} and $^W 0 4 4
Condition33%1/3
not defined $data->{"functions"} and $^W
!ll&&!rl&&r
400
MC/DC0%0/2
not defined $data->{"functions"} and $^W
not defined $data->{"functions"} $^W
Truth table33%1/3
not(A) and B
A= not defined $data->{"functions"}B= $^W
ABresult
0X0
100
111
612  
613 4 for my $function (@{$data->{functions}}) {
614 4 my $return_type = $data->{function}->{$function}->{return_type};
615 4 my @arg_names = @{$data->{function}->{$function}->{arg_names}};
616 4 my @arg_types = @{$data->{function}->{$function}->{arg_types}};
617  
618 4 $XS .= join '', ("\n$return_type\n$function (",
619 join(', ', @arg_names), ")\n");
620  
621 4 for my $arg_name (@arg_names) {
622 7 my $arg_type = shift @arg_types;
623 7 ▶ last if $arg_type eq '...';
Branch: 1 branch
BranchTrueFalseTotal
if $arg_type eq "..." 0 7 7
624 7 $XS .= "\t$arg_type\t$arg_name\n";
625 }
626  
627 4 my %h;
628 4 ▶ if (defined($o->{CONFIG}{PROTOTYPE})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o->{"CONFIG"}{"PROTOTYPE"}) 0 4 4
629 0 %h = %{$o->{CONFIG}{PROTOTYPE}};
630 }
631  
632 4 ▶ if(defined($h{$function})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $h{$function}) 0 4 4
633 0 $XS .= " PROTOTYPE: $h{$function}\n";
634 }
635  
636 4 my $listargs = '';
637 4 ▶ $listargs = pop @arg_names if (@arg_names and
Branch: 1 branch
BranchTrueFalseTotal
if @arg_names and $arg_names[-1] eq "..." 0 4 4
Condition33%1/3
@arg_names and $arg_names[-1] eq "..."
!ll&&!rl&&r
040
MC/DC0%0/2
@arg_names and $arg_names[-1] eq "..."
@arg_names $arg_names[-1] eq "..."
Truth table33%1/3
A and B
A= @arg_namesB= $arg_names[-1] eq "..."
ABresult
0X0
100
111
638 $arg_names[-1] eq '...');
639 4 my $arg_name_list = join(', ', @arg_names);
640  
641 4 ▶ if ($return_type eq 'void') {
Branch: 2 branches
BranchTrueFalseTotal
if ($return_type eq 'void') { } 0 4 4
elsif ($listargs) { } 0 4 4
642 0 ▶ if($o->{CONFIG}{_TESTING}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{'CONFIG'}{'_TESTING'}) { } 0 0 0
643 0 $XS .= <<END;
644 PREINIT:
645 PerlIO* stream;
646 I32* temp;
647 PPCODE:
648 temp = PL_markstack_ptr++;
649 $function($arg_name_list);
650 stream = PerlIO_open(\"$dir/void_test\", \"a\");
651 if(stream == NULL) warn(\"%s\\n\", \"Unable to open $dir/void_test for appending\");
652 if (PL_markstack_ptr != temp) {
653 PerlIO_printf(stream, \"%s\\n\", \"TRULY_VOID\");
654 PerlIO_close(stream);
655 PL_markstack_ptr = temp;
656 XSRETURN_EMPTY; /* return empty stack */
657 }
658 PerlIO_printf(stream, \"%s\\n\", \"LIST_CONTEXT\");
659 PerlIO_close(stream);
660 return; /* assume stack size is correct */
661 END
662 }
663 else {
664 0 $XS .= <<END;
665 PREINIT:
666 I32* temp;
667 PPCODE:
668 temp = PL_markstack_ptr++;
669 $function($arg_name_list);
670 if (PL_markstack_ptr != temp) {
671 /* truly void, because dXSARGS not invoked */
672 PL_markstack_ptr = temp;
673 XSRETURN_EMPTY; /* return empty stack */
674 }
675 /* must have used dXSARGS; list context implied */
676 return; /* assume stack size is correct */
677 END
678 }
679 }
680 elsif ($listargs) {
681 0 $XS .= <<END;
682 PREINIT:
683 I32* temp;
684 CODE:
685 temp = PL_markstack_ptr++;
686 RETVAL = $function($arg_name_list);
687 PL_markstack_ptr = temp;
688 OUTPUT:
689 RETVAL
690 END
691 }
692 }
693 4 $XS .= "\n";
694 4 return $XS;
695 }
696  
697 #==============================================================================
698 # Generate the INLINE.h file.
699 #==============================================================================
700 sub write_Inline_headers {
701 4 ▶ my $o = shift;
Subroutine write_Inline_headers: called CC=2 SCAR=7.0
Pod undocumented
702  
703 4 ▶ open HEADER, "> ".File::Spec->catfile($o->{API}{build_dir},"INLINE.h")
Branch: 1 branch
BranchTrueFalseTotal
open HEADER, '> ' . "File::Spec"->catfile($o->{"API"}{"build_dir"}, "INLINE.h") or croak() 0 4 4
704 or croak;
705  
706 4 print HEADER <<'END';
707 #define Inline_Stack_Vars dXSARGS
708 #define Inline_Stack_Items items
709 #define Inline_Stack_Item(x) ST(x)
710 #define Inline_Stack_Reset sp = mark
711 #define Inline_Stack_Push(x) XPUSHs(x)
712 #define Inline_Stack_Done PUTBACK
713 #define Inline_Stack_Return(x) XSRETURN(x)
714 #define Inline_Stack_Void XSRETURN(0)
715  
716 #define INLINE_STACK_VARS Inline_Stack_Vars
717 #define INLINE_STACK_ITEMS Inline_Stack_Items
718 #define INLINE_STACK_ITEM(x) Inline_Stack_Item(x)
719 #define INLINE_STACK_RESET Inline_Stack_Reset
720 #define INLINE_STACK_PUSH(x) Inline_Stack_Push(x)
721 #define INLINE_STACK_DONE Inline_Stack_Done
722 #define INLINE_STACK_RETURN(x) Inline_Stack_Return(x)
723 #define INLINE_STACK_VOID Inline_Stack_Void
724  
725 #define inline_stack_vars Inline_Stack_Vars
726 #define inline_stack_items Inline_Stack_Items
727 #define inline_stack_item(x) Inline_Stack_Item(x)
728 #define inline_stack_reset Inline_Stack_Reset
729 #define inline_stack_push(x) Inline_Stack_Push(x)
730 #define inline_stack_done Inline_Stack_Done
731 #define inline_stack_return(x) Inline_Stack_Return(x)
732 #define inline_stack_void Inline_Stack_Void
733 END
734  
735 4 close HEADER;
736 }
737  
738 #==============================================================================
739 # Generate the Makefile.PL
740 #==============================================================================
741 sub write_Makefile_PL {
742 4 ▶ my $o = shift;
Subroutine write_Makefile_PL: called CC=4 SCAR=13.9
Pod undocumented
743 4 $o->{ILSM}{xsubppargs} = '';
744 4 my $i = 0;
745 4 for (@{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}) {
746 4 $o->{ILSM}{xsubppargs} .= "-typemap \"$_\" ";
747 4 $o->{ILSM}{MAKEFILE}{TYPEMAPS}->[$i++] = fix_space($_);
748 }
749  
750 my %options = (
751 VERSION => $o->{API}{version} || '0.00',
752 4 %{$o->{ILSM}{MAKEFILE}},
753 NAME => $o->{API}{module},
754 4 ▶ );
Condition50%1/2
$o->{'API'}{'version'} || '0.00'
l!l
04
MC/DC0%0/1
$o->{'API'}{'version'} || '0.00'
$o->{'API'}{'version'}
Truth table50%1/2
A
A= $o->{'API'}{'version'}
Aresult
11
00
755  
756 4 ▶ open MF, "> ".File::Spec->catfile($o->{API}{build_dir},"Makefile.PL")
Branch: 1 branch
BranchTrueFalseTotal
open MF, '> ' . "File::Spec"->catfile($o->{"API"}{"build_dir"}, "Makefile.PL") or croak() 0 4 4
757 or croak;
758  
759 4 print MF <<END;
760 use ExtUtils::MakeMaker;
761 my %options = %\{
762 END
763  
764 4 local $Data::Dumper::Terse = 1;
765 4 local $Data::Dumper::Indent = 1;
766 4 print MF Data::Dumper::Dumper(\ %options);
767  
768 4 print MF <<END;
769 \};
770 WriteMakefile(\%options);
771  
772 # Remove the Makefile dependency. Causes problems on a few systems.
773 sub MY::makefile { '' }
774 END
775 4 close MF;
776 }
777  
778 #==============================================================================
779 # Run the build process.
780 #==============================================================================
781 sub compile {
782 4 ▶ my $o = shift;
Subroutine compile: called CC=3 SCAR=11.0
Pod undocumented
783  
784 4 my $build_dir = $o->{API}{build_dir};
785 4 my $cwd = &cwd;
786 4 ▶ ($cwd) = $cwd =~ /(.*)/ if $o->UNTAINT;
Branch: 1 branch
BranchTrueFalseTotal
if $o->UNTAINT 4 0 4
787  
788 4 chdir $build_dir;
789 # Run these in an eval block, so that we get to chdir back to
790 # $cwd if there's a failure. (Ticket #81375.)
791 4 eval {
792 4 $o->call('makefile_pl', '"perl Makefile.PL"', 2);
793 4 $o->call('make', '"make"', 2);
794 4 $o->call('make_install', '"make install"', 2);
795 };
796 4 chdir $cwd;
797 4 ▶ die if $@; #Die now that we've done the chdir back to $cwd. (#81375)
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 4 4
798 4 $o->call('cleanup', 'Cleaning Up', 2);
799 }
800  
801 sub makefile_pl {
802 4 ▶ my ($o) = @_;
Subroutine makefile_pl: called CC=4 SCAR=15.0
Pod undocumented
803 4 my $perl;
804 -f ($perl = $Config::Config{perlpath})
805 4 ▶ or ($perl = $^X)
Branch: 1 branch
BranchTrueFalseTotal
-f ($perl = $Config::Config{"perlpath"}) or $perl = $^X or croak("Can't locate your perl binary") 0 4 4
Condition33%1/3
-f ($perl = $Config::Config{"perlpath"}) or $perl = $^X
l!l&&r!l&&!r
400
MC/DC0%0/2
-f ($perl = $Config::Config{"perlpath"}) or $perl = $^X
-f ($perl = $Config::Config{"perlpath"}) $perl = $^X
Truth table33%1/3
A or B
A= -f ($perl = $Config::Config{"perlpath"})B= $perl = $^X
ABresult
1X1
011
000
806 or croak "Can't locate your perl binary";
807 4 ▶ $perl = qq{"$perl"} if $perl =~ m/\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $perl =~ /\s/ 0 4 4
808 4 $o->system_call("$perl Makefile.PL", 'out.Makefile_PL');
809 4 $o->fix_make;
810 }
811 sub make {
812 4 ▶ my ($o) = @_;
Subroutine make: called CC=3 SCAR=12.0
Pod undocumented
813 my $make = $o->{ILSM}{MAKE} || $Config::Config{make}
814 4 ▶ or croak "Can't locate your make binary";
Branch: 1 branch
BranchTrueFalseTotal
my $make = $o->{"ILSM"}{"MAKE"} || $Config::Config{"make"} or croak("Can't locate your make binary") 0 4 4
Condition33%1/3
$o->{'ILSM'}{'MAKE'} || $Config::Config{'make'}
l!l&&r!l&&!r
040
MC/DC0%0/2
$o->{'ILSM'}{'MAKE'} || $Config::Config{'make'}
$o->{'ILSM'}{'MAKE'} $Config::Config{'make'}
Truth table33%1/3
A || B
A= $o->{'ILSM'}{'MAKE'}B= $Config::Config{'make'}
ABresult
1X1
011
000
815 4 local $ENV{MAKEFLAGS} = $ENV{MAKEFLAGS} =~ s/(--jobserver-fds=[\d,]+)//;
816 4 $o->system_call("$make", 'out.make');
817 }
818 sub make_install {
819 4 ▶ my ($o) = @_;
Subroutine make_install: called CC=3 SCAR=12.0
Pod undocumented
820 my $make = $o->{ILSM}{MAKE} || $Config::Config{make}
821 4 ▶ or croak "Can't locate your make binary";
Branch: 1 branch
BranchTrueFalseTotal
my $make = $o->{"ILSM"}{"MAKE"} || $Config::Config{"make"} or croak("Can't locate your make binary") 0 4 4
Condition33%1/3
$o->{'ILSM'}{'MAKE'} || $Config::Config{'make'}
l!l&&r!l&&!r
040
MC/DC0%0/2
$o->{'ILSM'}{'MAKE'} || $Config::Config{'make'}
$o->{'ILSM'}{'MAKE'} $Config::Config{'make'}
Truth table33%1/3
A || B
A= $o->{'ILSM'}{'MAKE'}B= $Config::Config{'make'}
ABresult
1X1
011
000
822 4 local $ENV{MAKEFLAGS} = $ENV{MAKEFLAGS} =~ s/(--jobserver-fds=[\d,]+)//;
823 4 $o->system_call("$make pure_install", 'out.make_install');
824 }
825 sub cleanup {
826 4 ▶ my ($o) = @_;
Subroutine cleanup: called CC=2 SCAR=7.0
Pod undocumented
827 my ($modpname, $modfname, $install_lib) =
828 4 @{$o->{API}}{qw(modpname modfname install_lib)};
829 4 ▶ if ($o->{API}{cleanup}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->{"API"}{"cleanup"}) 4 0 4
830 4 $o->rmpath(File::Spec->catdir($o->{API}{directory},'build'),
831 $modpname);
832 4 my $autodir = File::Spec->catdir($install_lib,'auto',$modpname);
833 4 unlink (File::Spec->catfile($autodir,'.packlist'),
834 File::Spec->catfile($autodir,'$modfname.bs'),
835 File::Spec->catfile($autodir,'$modfname.exp'), #MSWin32
836 File::Spec->catfile($autodir,'$modfname.lib'), #MSWin32
837 );
838 }
839 }
840  
841 sub system_call {
842 12 ▶ my ($o, $cmd, $output_file) = @_;
Subroutine system_call: called CC=8 SCAR=24.7
Pod undocumented
843 my $build_noisy =
844 defined $ENV{PERL_INLINE_BUILD_NOISY}
845 ? $ENV{PERL_INLINE_BUILD_NOISY}
846 12 ▶ : $o->{CONFIG}{BUILD_NOISY};
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{'PERL_INLINE_BUILD_NOISY'} ? : 0 12 12
847 12 ▶ $build_noisy = undef if $build_noisy and $^O eq 'MSWin32' and $Config::Config{sh} =~ /^cmd/;
Branch: 1 branch
BranchTrueFalseTotal
if $build_noisy and $^O eq "MSWin32" and $Config::Config{"sh"} =~ /^cmd/ 0 12 12
Condition33%2/6
$build_noisy and $^O eq "MSWin32" and $Config::Config{"sh"} =~ /^cmd/
!ll&&!rl&&r
1200
$build_noisy and $^O eq "MSWin32"
!ll&&!rl&&r
1200
MC/DC0%0/3
$build_noisy and $^O eq "MSWin32" and $Config::Config{"sh"} =~ /^cmd/
$build_noisy $^O eq "MSWin32" $Config::Config{"sh"} =~ /^cmd/
Truth table25%1/4
A and B and C
A= $build_noisyB= $^O eq "MSWin32"C= $Config::Config{"sh"} =~ /^cmd/
ABCresult
0XX0
10X0
1100
1111
848 12 ▶ if (not $build_noisy) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($build_noisy) 12 0 12
849 12 $cmd = "$cmd > $output_file 2>&1";
850 }
851 12 ▶ ($cmd) = $cmd =~ /(.*)/ if $o->UNTAINT;
Branch: 1 branch
BranchTrueFalseTotal
if $o->UNTAINT 12 0 12
852 12 ▶ system($cmd) == 0
Branch: 1 branch
BranchTrueFalseTotal
system($cmd) == 0 or croak($o->build_error_message($cmd, $output_file, $build_noisy)) 0 12 12
853 or croak($o->build_error_message($cmd, $output_file, $build_noisy));
854 }
855  
856 sub build_error_message {
857 0 ▶ my ($o, $cmd, $output_file, $build_noisy) = @_;
Subroutine build_error_message: not called CC=6 SCAR=37.4
Pod undocumented
858 0 my $build_dir = $o->{API}{build_dir};
859 0 my $output = '';
860 0 ▶ if (not $build_noisy and
Branch: 1 branch
BranchTrueFalseTotal
if (not $build_noisy and open OUTPUT, $output_file) 0 0 0
Condition0%0/3
not $build_noisy and open OUTPUT, $output_file
!ll&&!rl&&r
000
MC/DC0%0/2
not $build_noisy and open OUTPUT, $output_file
not $build_noisy open OUTPUT, $output_file
Truth table0%0/3
not(A) and B
A= not $build_noisyB= open OUTPUT, $output_file
ABresult
0X0
100
111
861 open(OUTPUT, $output_file)
862 ) {
863 0 local $/;
864 0 $output = <OUTPUT>;
865 0 close OUTPUT;
866 }
867  
868 0 my $errcode = $? >> 8;
869 0 $output .= <<END;
870  
871 A problem was encountered while attempting to compile and install your Inline
872 $o->{API}{language} code. The command that failed was:
873 \"$cmd\" with error code $errcode
874  
875 The build directory was:
876 $build_dir
877  
878 To debug the problem, cd to the build directory, and inspect the output files.
879  
880 END
881 0 ▶ if ($cmd =~ /^make >/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^make >/) 0 0 0
882 0 for (sort keys %ENV) {
883 0 ▶ $output .= "$_ = $ENV{$_}\n" if /^MAKE/;
Branch: 1 branch
BranchTrueFalseTotal
if /^MAKE/ 0 0 0
884 }
885 }
886 0 return $output;
887 }
888  
889 #==============================================================================
890 # This routine fixes problems with the MakeMaker Makefile.
891 #==============================================================================
892 1 my %fixes = (
893 INSTALLSITEARCH => 'install_lib',
894 INSTALLDIRS => 'installdirs',
895 XSUBPPARGS => 'xsubppargs',
896 INSTALLSITELIB => 'install_lib',
897 );
898  
899 sub fix_make {
900 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
901 4 ▶ my (@lines, $fix);
Subroutine fix_make: called CC=7 SCAR=19.5
Pod undocumented
902 4 my $o = shift;
903  
904 4 $o->{ILSM}{install_lib} = $o->{API}{install_lib};
905 4 $o->{ILSM}{installdirs} = 'site';
906  
907 4 ▶ open(MAKEFILE, '< Makefile')
Branch: 1 branch
BranchTrueFalseTotal
open MAKEFILE, "< Makefile" or croak("Can't open Makefile for input: $!\n") 0 4 4
908 or croak "Can't open Makefile for input: $!\n";
909 4 @lines = <MAKEFILE>;
910 4 close MAKEFILE;
911  
912 4 ▶ open(MAKEFILE, '> Makefile')
Branch: 1 branch
BranchTrueFalseTotal
open MAKEFILE, "> Makefile" or croak("Can't open Makefile for output: $!\n") 0 4 4
913 or croak "Can't open Makefile for output: $!\n";
914 4 for (@lines) {
915 4220 ▶ if (/^(\w+)\s*=\s*\S+.*$/ and
Branch: 1 branch
BranchTrueFalseTotal
if (/^(\w+)\s*=\s*\S+.*$/ and $fix = $fixes{$1}) { } 16 4204 4220
Condition100%3/3
/^(\w+)\s*=\s*\S+.*$/ and $fix = $fixes{$1}
!ll&&!rl&&r
346474016
MC/DC100%2/2
/^(\w+)\s*=\s*\S+.*$/ and $fix = $fixes{$1}
/^(\w+)\s*=\s*\S+.*$/ $fix = $fixes{$1}
Truth table100%3/3
A and B
A= /^(\w+)\s*=\s*\S+.*$/B= $fix = $fixes{$1}
ABresult
0X0
100
111
916 $fix = $fixes{$1}
917 ) {
918 16 my $fixed = $o->{ILSM}{$fix};
919 16 ▶ $fixed = fix_space($fixed) if $fix eq 'install_lib';
Branch: 1 branch
BranchTrueFalseTotal
if $fix eq "install_lib" 8 8 16
920 16 print MAKEFILE "$1 = $fixed\n";
921 }
922 else {
923 4204 print MAKEFILE;
924 }
925 }
926 4 close MAKEFILE;
927 }
928  
929 sub quote_space {
930  
931 # Do nothing if $ENV{NO_INSANE_DIRNAMES} is set
932 0 ▶ return $_[0] if $ENV{NO_INSANE_DIRNAMES};
Subroutine quote_space: not called CC=15 SCAR=54.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"NO_INSANE_DIRNAMES"} 0 0 0
933  
934 # If $_[0] contains one or more doublequote characters, assume
935 # that whitespace has already been quoted as required. Hence,
936 # do nothing other than immediately return $_[0] as is.
937 # We currently don't properly handle tabs either, so we'll
938 # do the same if $_[0] =~ /\t/.
939 0 ▶ return $_[0] if ($_[0] =~ /"/ || $_[0] =~ /\t/);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /"/ or $_[0] =~ /\t/ 0 0 0
Condition0%0/3
$_[0] =~ /"/ or $_[0] =~ /\t/
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] =~ /"/ or $_[0] =~ /\t/
$_[0] =~ /"/ $_[0] =~ /\t/
Truth table0%0/3
A or B
A= $_[0] =~ /"/B= $_[0] =~ /\t/
ABresult
1X1
011
000
940  
941 # We want to split on /\s\-I/ not /\-I/
942 0 my @in = split /\s\-I/, $_[0];
943 0 my $s = @in - 1;
944 0 my %s;
945 my %q;
946  
947 # First up, let's reinstate the ' ' characters that split
948 # removed
949 0 ▶ for(my $i = 0; $i < $s; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $s) 0 0 0
950 0 $in[$i] .= ' ';
951 }
952  
953 # This for{} block dies if it finds that any of the ' -I'
954 # occurrences in $_[0] are part of a directory name.
955 0 ▶ for(my $i = 1; $i < $s; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $s) 0 0 0
956 0 my $t = $in[$i + 1];
957 0 ▶ while($t =~ /\s$/) {chop $t}
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ /\s$/) 0 0 0
958 0 ▶ die "Found a '", $in[$i], "-I", $t, "' directory.",
Branch: 1 branch
BranchTrueFalseTotal
if -d $in[$i] . '-I' . $t 0 0 0
959 " INC Config argument is ambiguous.",
960 " Please use doublequotes to signify your intentions"
961 if -d ($in[$i] . "-I" . $t);
962 }
963  
964 0 $s++; # Now the same as scalar(@in)
965  
966 # Remove (but also Keep track of the amount of) whitespace
967 # at the end of each element of @in.
968 0 ▶ for(my $i = 0; $i < $s; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $s) 0 0 0
969 0 my $count = 0;
970 0 ▶ while($in[$i] =~ /\s$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in[$i] =~ /\s$/) 0 0 0
971 0 chop $in[$i];
972 0 $count++;
973 }
974 0 $s{$i} = $count;
975 }
976  
977 # Note which elements of @in still contain whitespace. These
978 # (and only these) elements will be quoted
979 0 ▶ for(my $i = 0; $i < $s; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $s) 0 0 0
980 0 ▶ $q{$i} = 1 if $in[$i] =~ /\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $in[$i] =~ /\s/ 0 0 0
981 }
982  
983 # Reinstate the occurrences of '-I' that were removed by split(),
984 # insert any quotes that are needed, reinstate the whitespace
985 # that was removed earlier, then join() the array back together
986 # again.
987 0 ▶ for(my $i = 0; $i < $s; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $s) 0 0 0
988 0 ▶ $in[$i] = '-I' . $in[$i] if $i;
Branch: 1 branch
BranchTrueFalseTotal
if $i 0 0 0
989 0 ▶ $in[$i] = '"' . $in[$i] . '"' if $q{$i};
Branch: 1 branch
BranchTrueFalseTotal
if $q{$i} 0 0 0
990 0 $in[$i] .= ' ' x $s{$i};
991 }
992  
993 # Note: If there was no whitespace that needed quoting, the
994 # original argument should not have changed in any way.
995  
996 0 my $out = join '', @in;
997 0 $out =~ s/"\-I\s+\//"\-I\//g;
998 0 $_[0] = $out;
999 }
1000  
1001 sub fix_space {
1002 12 ▶ $_[0] =~ s/ /\\ /g if $_[0] =~ / /;
Subroutine fix_space: called CC=2 SCAR=7.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ / / 0 12 12
1003 12 $_[0];
1004 }
1005  
1006 #==============================================================================
1007 # This routine used by C/t/09parser to test that the expected parser is in use
1008 #==============================================================================
1009  
1010 sub _parser_test {
1011 0 ▶ my $dir = '_Inline_test';
Subroutine _parser_test: not called CC=5 SCAR=34.0
1012 0 ▶ if(! -d $dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
1013 0 my $ok = mkdir $dir;
1014 0 ▶ warn $! if !$ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
1015 }
1016  
1017 0 ▶ warn $! if !open(TEST_FH, '>>', "$dir/parser_id");
Branch: 1 branch
BranchTrueFalseTotal
unless open TEST_FH, ">>", "$dir/parser_id" 0 0 0
1018 0 print TEST_FH $_[0];
1019 0 ▶ warn $! if !close(TEST_FH);
Branch: 1 branch
BranchTrueFalseTotal
if not close TEST_FH 0 0 0
1020 }
1021  
1022 #=======================================================================
1023 # This routine used to cleanup files created by _TESTING (config option)
1024 #=======================================================================
1025  
1026 sub _testing_cleanup {
1027 0 ▶ my $dir = '_Inline_test';
Subroutine _testing_cleanup: not called CC=5 SCAR=34.0
1028  
1029 0 ▶ if(-f "$dir/parser_id") {
Branch: 1 branch
BranchTrueFalseTotal
if (-f "$dir/parser_id") 0 0 0
1030 0 ▶ warn "Failed to unlink C/$dir/parser_id\n" if !unlink("$dir/parser_id");
Branch: 1 branch
BranchTrueFalseTotal
unless unlink "$dir/parser_id" 0 0 0
1031 }
1032  
1033 0 ▶ if(-f "$dir/void_test") {
Branch: 1 branch
BranchTrueFalseTotal
if (-f "$dir/void_test") 0 0 0
1034 0 ▶ warn "Failed to unlink C/$dir/void_test\n" if !unlink("$dir/void_test");
Branch: 1 branch
BranchTrueFalseTotal
if not unlink("$dir/void_test") 0 0 0
1035 }
1036 }
1037  
1038 1 1;
1039  
1040 __END__
↑ Summary blib/lib/Inline/C.pm »