blib/lib/Inline/C.pm

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