Op.xs

filter: Statementstmt 98.5% 700 / 710 Branchbran 79.8% 562 / 714 (12 uncoverable) Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 89.1% 1262 / 1424 (12 uncoverable) CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/ex_op_reg.h ↑ Summary include/ex_op_call.h »
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5 #define NEED_caller_cx
6 #define NEED_mg_findext
7 #include "ppport.h"
8  
9 #include "xop_compat.h"
10 #include "ex_op_compat.h"
11 #include "ex_op.h"
12 #include "ex_op_reg.h"
13  
14 START_MY_CXT
15  
16 #include "ex_op_call.h"
17 #include "ex_op_kw.h"
18  
19 static void
20 50 eo_cxt_init(pTHX_ my_cxt_t *cxt)
21 {
22 50 cxt->exports = newHV();
23 50 cxt->ret = NULL;
24 50 cxt->ret_top = 0;
25 50 cxt->ret_max = 0;
26 50 cxt->level_gv = gv_fetchpvs("Ex::Op::ExportLevel", GV_ADDMULTI, SVt_PV);
27 50 cxt->verbose_gv = gv_fetchpvs("Ex::Op::Verbose", GV_ADDMULTI, SVt_PV);
28 50 ▶ if (!SvOK(GvSVn(cxt->level_gv))) /* # uncoverable condition right count:1 */
Branch: 2 branches
BranchTrueFalseTotal
if (!SvOK(GvSVn(cxt->level_gv))) /* # uncoverable condition right count:1 */ 50 0 50
if (!SvOK(GvSVn(cxt->level_gv))) /* # uncoverable condition right count:1 */ 50 0 50
29 50 ▶ sv_setiv(GvSVn(cxt->level_gv), 0);
Branch: 1 branch
BranchTrueFalseTotal
sv_setiv(GvSVn(cxt->level_gv), 0); 50 0 50
30 50 ▶ if (!SvOK(GvSVn(cxt->verbose_gv))) /* # uncoverable condition right count:1 */
Branch: 2 branches
BranchTrueFalseTotal
if (!SvOK(GvSVn(cxt->verbose_gv))) /* # uncoverable condition right count:1 */ 50 0 50
if (!SvOK(GvSVn(cxt->verbose_gv))) /* # uncoverable condition right count:1 */ 50 0 50
31 50 ▶ sv_setiv(GvSVn(cxt->verbose_gv), 0);
Branch: 1 branch
BranchTrueFalseTotal
sv_setiv(GvSVn(cxt->verbose_gv), 0); 50 0 50
32 50 cxt->import_cv = get_cvs("Ex::Op::import", 0);
33 50 cxt->export_cv = get_cvs("Ex::Op::export", 0);
34 50 cxt->export_fail_cv = get_cvs("Ex::Op::export_fail", 0);
35 50 }
36  
37 /* What Exporter's caller($level) sees from inside an exporter sub. An XSUB
38 * has no frame of its own, so level 0 is the statement that called it and
39 * level N is the call site of the Perl frame N-1 above it. */
40 static const COP *
41 6462 eo_caller_cop(pTHX_ IV level)
42 {
43 const PERL_CONTEXT *cx;
44 6462 ▶ if (level <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (level <= 0) 6452 10 6462
45 6452 return PL_curcop;
46 10 cx = caller_cx((I32)(level - 1), NULL);
47 10 ▶ return cx ? cx->blk_oldcop : NULL;
Branch: 1 branch
BranchTrueFalseTotal
return cx ? cx->blk_oldcop : NULL; 8 2 10
48 }
49  
50 static SV *
51 6704 eo_stash_name(pTHX_ HV *stash)
52 {
53 6704 ▶ if (!stash || !HvNAME_get(stash))
Branch: 8 branches
BranchTrueFalseTotal
if (!stash || !HvNAME_get(stash)) 6702 2 6704
if (!stash || !HvNAME_get(stash)) 6702 0 6702
if (!stash || !HvNAME_get(stash)) 6702 0 6702
if (!stash || !HvNAME_get(stash)) 0 6702 6702
if (!stash || !HvNAME_get(stash)) 0 0 0
if (!stash || !HvNAME_get(stash)) 6702 0 6702
if (!stash || !HvNAME_get(stash)) 0 6702 6702
if (!stash || !HvNAME_get(stash)) 0 6702 6702
54 2 return newSVpvs_flags("main", SVs_TEMP);
55 6702 ▶ return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash),
Branch: 20 branches
BranchTrueFalseTotal
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 6702 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 0 0
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 6702 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 6702 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 1 6701 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 6702 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 0 0
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 6702 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 6702 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 0 0
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 6702 0 6702
return newSVpvn_flags(HvNAME_get(stash), HvNAMELEN_get(stash), 0 6702 6702
56 SVs_TEMP | (HvNAMEUTF8(stash) ? SVf_UTF8 : 0));
57 }
58  
59 static SV *
60 1505 eo_qualify(pTHX_ SV *pkg, const char *name, STRLEN len, bool utf8)
61 {
62 1505 SV *full = newSVsv(pkg);
63 1505 sv_2mortal(full);
64 1505 sv_catpvs(full, "::");
65 1505 ▶ if (utf8 && !SvUTF8(full))
Branch: 2 branches
BranchTrueFalseTotal
if (utf8 && !SvUTF8(full)) 16 1489 1505
if (utf8 && !SvUTF8(full)) 15 1 16
66 15 sv_utf8_upgrade(full);
67 1508 ▶ if (SvUTF8(full) && !utf8) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvUTF8(full) && !utf8) { 19 1486 1505
if (SvUTF8(full) && !utf8) { 3 16 19
68 3 SV *tail = newSVpvn_flags(name, len, SVs_TEMP);
69 3 sv_catsv(full, tail);
70 }
71 else {
72 1502 sv_catpvn(full, name, len);
73 }
74 1505 return full;
75 }
76  
77 /* The glob a plain name already has in a stash, found without building
78 * "Pkg::name". NULL for a qualified or UTF-8 name, or one with no glob yet. */
79 static GV *
80 87349 eo_stash_gv(pTHX_ HV *stash, const char *name, STRLEN len, bool utf8)
81 {
82 SV **svp;
83 87349 ▶ if (!stash || utf8 || !len || memchr(name, ':', len) || memchr(name, '\'', len)) /* # uncoverable condition left count:2 */
Branch: 5 branches
BranchTrueFalseTotal
if (!stash || utf8 || !len || memchr(name, ':', len) || memchr(name, '\'', len)) /* # uncoverable condition left count:2 */ 87347 2 87349
if (!stash || utf8 || !len || memchr(name, ':', len) || memchr(name, '\'', len)) /* # uncoverable condition left count:2 */ 87347 0 87347
if (!stash || utf8 || !len || memchr(name, ':', len) || memchr(name, '\'', len)) /* # uncoverable condition left count:2 */ 87346 1 87347
if (!stash || utf8 || !len || memchr(name, ':', len) || memchr(name, '\'', len)) /* # uncoverable condition left count:2 */ 87344 2 87346
if (!stash || utf8 || !len || memchr(name, ':', len) || memchr(name, '\'', len)) /* # uncoverable condition left count:2 */ 1 87343 87344
84 6 return NULL;
85 87343 svp = hv_fetch(stash, name, (I32)len, 0);
86 87343 ▶ return (svp && isGV_with_GP(*svp)) ? (GV *)*svp : NULL;
Branch: 4 branches
BranchTrueFalseTotal
return (svp && isGV_with_GP(*svp)) ? (GV *)*svp : NULL; 76677 10666 87343
return (svp && isGV_with_GP(*svp)) ? (GV *)*svp : NULL; 76677 0 76677
return (svp && isGV_with_GP(*svp)) ? (GV *)*svp : NULL; 0 76677 76677
return (svp && isGV_with_GP(*svp)) ? (GV *)*svp : NULL; 0 0 0
87 }
88  
89 /* The same, made when it is not there yet, for a name gv_fetchpvn would
90 * give nothing special: two or more word characters, the first lower case
91 * or an underscore. EXPORT, ISA, VERSION, ARGV, SIG, ENV, STDIN, $a, $b and
92 * the rest all start otherwise, and go the long way. */
93 static GV *
94 10853 eo_stash_gv_add(pTHX_ HV *stash, const char *name, STRLEN len, bool utf8)
95 {
96 10853 GV *gv = eo_stash_gv(aTHX_ stash, name, len, utf8);
97 STRLEN i;
98 SV **svp;
99 /*
100 # uncoverable condition left count:2
101 # uncoverable condition left count:3
102 # uncoverable condition right count:6 */
103 10853 ▶ if (gv || !stash || utf8 || len < 2 || !(isLOWER(*name) || *name == '_'))
Branch: 6 branches
BranchTrueFalseTotal
if (gv || !stash || utf8 || len < 2 || !(isLOWER(*name) || *name == '_')) 10563 290 10853
if (gv || !stash || utf8 || len < 2 || !(isLOWER(*name) || *name == '_')) 10563 0 10563
if (gv || !stash || utf8 || len < 2 || !(isLOWER(*name) || *name == '_')) 10563 0 10563
if (gv || !stash || utf8 || len < 2 || !(isLOWER(*name) || *name == '_')) 10535 28 10563
if (gv || !stash || utf8 || len < 2 || !(isLOWER(*name) || *name == '_')) 532 10003 10535
if (gv || !stash || utf8 || len < 2 || !(isLOWER(*name) || *name == '_')) 532 0 532
104 850 return gv;
105 20252 ▶ for (i = 1; i < len; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 1; i < len; i++) 10250 10002 20252
106 10250 ▶ if (!isWORDCHAR(name[i]))
Branch: 1 branch
BranchTrueFalseTotal
if (!isWORDCHAR(name[i])) 1 10249 10250
107 1 return NULL;
108 10002 svp = hv_fetch(stash, name, (I32)len, 1);
109 /*
110 # uncoverable branch true
111 # uncoverable condition left count:1 */
112 10002 ▶ if (!svp)
Branch: 1 branch
BranchTrueFalseTotal
if (!svp) 0 10002 10002
113 0 return NULL; /* # uncoverable statement */
114 10002 ▶ if (!isGV_with_GP(*svp)) /* # uncoverable branch false */
Branch: 3 branches
BranchTrueFalseTotal
if (!isGV_with_GP(*svp)) /* # uncoverable branch false */ 0 10002 10002
if (!isGV_with_GP(*svp)) /* # uncoverable branch false */ 0 0 0
if (!isGV_with_GP(*svp)) /* # uncoverable branch false */ 0 0 0
115 10002 gv_init((GV *)*svp, stash, name, len, TRUE);
116 10002 ▶ return isGV_with_GP(*svp) ? (GV *)*svp : NULL;
Branch: 3 branches
BranchTrueFalseTotal
return isGV_with_GP(*svp) ? (GV *)*svp : NULL; 10002 0 10002
return isGV_with_GP(*svp) ? (GV *)*svp : NULL; 0 10002 10002
return isGV_with_GP(*svp) ? (GV *)*svp : NULL; 0 0 0
117 }
118  
119 static GV *
120 28270 eo_pkg_gv(pTHX_ SV *pkg, const char *name, STRLEN len, svtype type)
121 {
122 28270 GV *gv = eo_stash_gv(aTHX_ gv_stashsv(pkg, 0), name, len, FALSE);
123 28270 ▶ if (gv)
Branch: 1 branch
BranchTrueFalseTotal
if (gv) 28245 25 28270
124 28245 return gv;
125 25 gv = gv_fetchsv(eo_qualify(aTHX_ pkg, name, len, FALSE), 0, type);
126 25 ▶ return (gv && isGV_with_GP(gv)) ? gv : NULL;
Branch: 4 branches
BranchTrueFalseTotal
return (gv && isGV_with_GP(gv)) ? gv : NULL; 0 25 25
return (gv && isGV_with_GP(gv)) ? gv : NULL; 0 0 0
return (gv && isGV_with_GP(gv)) ? gv : NULL; 0 0 0
return (gv && isGV_with_GP(gv)) ? gv : NULL; 0 0 0
127 }
128  
129 static AV *
130 23024 eo_pkg_av(pTHX_ SV *pkg, const char *name, STRLEN len)
131 {
132 23024 GV *gv = eo_pkg_gv(aTHX_ pkg, name, len, SVt_PVAV);
133 23024 ▶ return gv ? GvAV(gv) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
return gv ? GvAV(gv) : NULL; 23001 23 23024
134 }
135  
136 static HV *
137 5246 eo_pkg_hv(pTHX_ SV *pkg, const char *name, STRLEN len)
138 {
139 5246 GV *gv = eo_pkg_gv(aTHX_ pkg, name, len, SVt_PVHV);
140 5246 ▶ return gv ? GvHV(gv) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
return gv ? GvHV(gv) : NULL; 5244 2 5246
141 }
142  
143 static SV *
144 16709 eo_strip_amp(pTHX_ SV *sv)
145 {
146 STRLEN len;
147 16709 const char *s = SvPV_const(sv, len);
148 /*
149 # uncoverable branch true
150 # uncoverable condition left count:1
151 # uncoverable condition right count:1
152 # uncoverable condition left count:2 */
153 16709 ▶ if (len && *s == '&') {
Branch: 2 branches
BranchTrueFalseTotal
if (len && *s == '&') { 16709 0 16709
if (len && *s == '&') { 0 16709 16709
154 0 s++; /* # uncoverable statement */
155 0 len--; /* # uncoverable statement */
156 } /* # uncoverable statement */
157 16709 return newSVpvn_flags(s, len, SVs_TEMP | (SvUTF8(sv) ? SVf_UTF8 : 0));
158 }
159  
160 /* Exporter's _rebuild_cache runs s/^&// over @EXPORT and @EXPORT_OK
161 * themselves, so after the first import with a list :DEFAULT names d2, not
162 * &d2. The arrays are changed in place here too. */
163 static void
164 3888 eo_add_names(pTHX_ HV *set, AV *av)
165 {
166 SSize_t i, top;
167 /*
168 # uncoverable branch true
169 # uncoverable condition left count:1 */
170 3888 ▶ if (!av)
Branch: 1 branch
BranchTrueFalseTotal
if (!av) 0 3888 3888
171 0 return; /* # uncoverable statement */
172 3888 top = av_len(av);
173 21154 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 17266 3888 21154
174 17266 SV **svp = av_fetch(av, i, 0);
175 STRLEN len;
176 const char *s;
177 17266 ▶ if (!svp)
Branch: 1 branch
BranchTrueFalseTotal
if (!svp) 7 17259 17266
178 7 continue;
179 17259 s = SvPV_const(*svp, len);
180 17259 ▶ if (len && *s == '&')
Branch: 2 branches
BranchTrueFalseTotal
if (len && *s == '&') 17257 2 17259
if (len && *s == '&') 11 17246 17257
181 11 sv_chop(*svp, s + 1);
182 17259 (void)hv_store_ent(set, *svp, &PL_sv_yes, 0);
183 }
184 }
185  
186 static void
187 5291 eo_av_append(pTHX_ AV *to, AV *from)
188 {
189 SSize_t i, top;
190 /*
191 # uncoverable branch true
192 # uncoverable condition left count:1 */
193 5291 ▶ if (!from)
Branch: 1 branch
BranchTrueFalseTotal
if (!from) 0 5291 5291
194 0 return; /* # uncoverable statement */
195 5291 top = av_len(from);
196 19017 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 13726 5291 19017
197 13726 SV **svp = av_fetch(from, i, 0);
198 13726 ▶ av_push(to, svp ? newSVsv(*svp) : newSV(0));
Branch: 1 branch
BranchTrueFalseTotal
av_push(to, svp ? newSVsv(*svp) : newSV(0)); 13722 4 13726
199 }
200 }
201  
202 static AV *
203 102 eo_av_copy(pTHX_ AV *from)
204 {
205 102 AV *to = (AV *)sv_2mortal((SV *)newAV());
206 102 eo_av_append(aTHX_ to, from);
207 102 return to;
208 }
209  
210 static SV *
211 9 eo_join(pTHX_ AV *av, const char *sep)
212 {
213 9 SV *out = sv_2mortal(newSVpvs(""));
214 9 SSize_t i, top = av_len(av);
215 27 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 18 9 27
216 18 SV **svp = av_fetch(av, i, 0);
217 18 ▶ if (i)
Branch: 1 branch
BranchTrueFalseTotal
if (i) 9 9 18
218 9 sv_catpv(out, sep);
219 /*
220 # uncoverable branch false
221 # uncoverable condition right count:1 */
222 18 ▶ if (svp)
Branch: 1 branch
BranchTrueFalseTotal
if (svp) 18 0 18
223 18 sv_catsv(out, *svp);
224 }
225 9 return out;
226 }
227  
228 /* The set of exportable names for a package, with & stripped, as
229 * Exporter's %Cache holds it. It is rebuilt when @EXPORT or @EXPORT_OK has
230 * been replaced or changed size, and by the caller on a miss, as Exporter
231 * rebuilds on a miss. */
232 static HV *
233 1944 eo_cache_build(pTHX_ SV *pkg, AV *exp, AV *ok)
234 {
235 dMY_CXT;
236 1944 HV *set = newHV();
237 1944 AV *entry = newAV();
238 1944 eo_add_names(aTHX_ set, exp);
239 1944 eo_add_names(aTHX_ set, ok);
240 1944 av_store(entry, EO_CACHE_SET, newRV_noinc((SV *)set));
241 1944 ▶ av_store(entry, EO_CACHE_EXP, exp ? newRV_inc((SV *)exp) : newSV(0)); /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
av_store(entry, EO_CACHE_EXP, exp ? newRV_inc((SV *)exp) : newSV(0)); /* # uncoverable condition right count:1 */ 1944 0 1944
242 1944 ▶ av_store(entry, EO_CACHE_OK, ok ? newRV_inc((SV *)ok) : newSV(0)); /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
av_store(entry, EO_CACHE_OK, ok ? newRV_inc((SV *)ok) : newSV(0)); /* # uncoverable condition right count:1 */ 1944 0 1944
243 1944 ▶ av_store(entry, EO_CACHE_NEXP, newSViv(exp ? av_len(exp) : -2)); /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
av_store(entry, EO_CACHE_NEXP, newSViv(exp ? av_len(exp) : -2)); /* # uncoverable condition right count:1 */ 1944 0 1944
244 1944 ▶ av_store(entry, EO_CACHE_NOK, newSViv(ok ? av_len(ok) : -2)); /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
av_store(entry, EO_CACHE_NOK, newSViv(ok ? av_len(ok) : -2)); /* # uncoverable condition right count:1 */ 1944 0 1944
245 1944 (void)hv_store_ent(MY_CXT.exports, pkg, newRV_noinc((SV *)entry), 0);
246 1944 return set;
247 }
248  
249 static bool
250 12921 eo_cache_same(pTHX_ AV *entry, I32 slot, I32 nslot, AV *av)
251 {
252 12921 SV **ref = av_fetch(entry, slot, 0);
253 12921 SV **n = av_fetch(entry, nslot, 0);
254 AV *had;
255 /*
256 # uncoverable branch true
257 # uncoverable condition left count:1
258 # uncoverable condition left count:2 */
259 12921 ▶ if (!ref || !n)
Branch: 2 branches
BranchTrueFalseTotal
if (!ref || !n) 12921 0 12921
if (!ref || !n) 0 12921 12921
260 0 return FALSE; /* # uncoverable statement */
261 12921 ▶ had = SvROK(*ref) ? (AV *)SvRV(*ref) : NULL; /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
had = SvROK(*ref) ? (AV *)SvRV(*ref) : NULL; /* # uncoverable condition right count:1 */ 12921 0 12921
262 12921 ▶ if (had != av)
Branch: 1 branch
BranchTrueFalseTotal
if (had != av) 1 12920 12921
263 1 return FALSE;
264 12920 ▶ return SvIV(*n) == (av ? av_len(av) : -2); /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
return SvIV(*n) == (av ? av_len(av) : -2); /* # uncoverable condition right count:1 */ 12920 0 12920
265 }
266  
267 static HV *
268 6504 eo_cache_get(pTHX_ SV *pkg, AV *exp, AV *ok, bool *built)
269 {
270 dMY_CXT;
271 6504 HE *he = hv_fetch_ent(MY_CXT.exports, pkg, 0, 0);
272 6504 ▶ if (he && SvROK(HeVAL(he))) { /* # uncoverable condition right count:2 */
Branch: 2 branches
BranchTrueFalseTotal
if (he && SvROK(HeVAL(he))) { /* # uncoverable condition right count:2 */ 6461 43 6504
if (he && SvROK(HeVAL(he))) { /* # uncoverable condition right count:2 */ 6461 0 6461
273 6461 AV *entry = (AV *)SvRV(HeVAL(he));
274 6461 ▶ if (eo_cache_same(aTHX_ entry, EO_CACHE_EXP, EO_CACHE_NEXP, exp)
Branch: 1 branch
BranchTrueFalseTotal
if (eo_cache_same(aTHX_ entry, EO_CACHE_EXP, EO_CACHE_NEXP, exp) 6460 1 6461
275 6460 ▶ && eo_cache_same(aTHX_ entry, EO_CACHE_OK, EO_CACHE_NOK, ok)) {
Branch: 1 branch
BranchTrueFalseTotal
&& eo_cache_same(aTHX_ entry, EO_CACHE_OK, EO_CACHE_NOK, ok)) { 6456 4 6460
276 6456 SV **set = av_fetch(entry, EO_CACHE_SET, 0);
277 6456 *built = FALSE;
278 6456 return (HV *)SvRV(*set);
279 }
280 }
281 48 *built = TRUE;
282 48 return eo_cache_build(aTHX_ pkg, exp, ok);
283 }
284  
285 static bool
286 4318 eo_is_word_start(const char *s, STRLEN len, bool utf8)
287 {
288 U8 c;
289 4318 ▶ if (!len)
Branch: 1 branch
BranchTrueFalseTotal
if (!len) 7 4311 4318
290 7 return TRUE;
291 4311 c = (U8)*s;
292 4311 ▶ if (utf8 && c >= 0x80)
Branch: 2 branches
BranchTrueFalseTotal
if (utf8 && c >= 0x80) 8 4303 4311
if (utf8 && c >= 0x80) 5 3 8
293 5 return TRUE;
294 4306 return isWORDCHAR(c) ? TRUE : FALSE;
295 }
296  
297 static void eo_install_slow(pTHX_ SV *pkg, SV *callpkg, SV *name);
298  
299 /* The usual install: a plain name in two stashes, both found once for the
300 * whole import. Anything else goes the long way, by full name. */
301 static void
302 10879 eo_install_one(pTHX_ SV *pkg, SV *callpkg, HV *srcstash, HV *dststash, SV *name)
303 {
304 STRLEN len;
305 10879 const char *s = SvPV_const(name, len);
306 10879 bool utf8 = SvUTF8(name) ? TRUE : FALSE;
307 10879 char type = '&';
308 GV *src, *dgv;
309 SV *thing, *ref;
310  
311 10879 ▶ if (utf8 || !len) {
Branch: 2 branches
BranchTrueFalseTotal
if (utf8 || !len) { 10871 8 10879
if (utf8 || !len) { 7 10864 10871
312 15 eo_install_slow(aTHX_ pkg, callpkg, name);
313 1677 return;
314 }
315 10864 ▶ if (!isWORDCHAR(*s)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!isWORDCHAR(*s)) { 4910 5954 10864
316 4910 type = *s;
317 4910 s++;
318 4910 len--;
319 }
320 10864 src = eo_stash_gv(aTHX_ srcstash, s, len, FALSE);
321 10864 ▶ if (!src) {
Branch: 1 branch
BranchTrueFalseTotal
if (!src) { 9 10855 10864
322 9 eo_install_slow(aTHX_ pkg, callpkg, name);
323 9 return;
324 }
325 10855 switch (type) {
326 5948 ▶ case '&': thing = (SV *)GvCVu(src); break;
Branch: 1 branch
BranchTrueFalseTotal
case '&': thing = (SV *)GvCVu(src); break; 5948 0 5948
327 1704 ▶ case '$': thing = GvSVn(src); break;
Branch: 1 branch
BranchTrueFalseTotal
case '$': thing = GvSVn(src); break; 1704 0 1704
328 1522 ▶ case '@': thing = (SV *)GvAVn(src); break;
Branch: 1 branch
BranchTrueFalseTotal
case '@': thing = (SV *)GvAVn(src); break; 1522 0 1522
329 586 ▶ case '%': thing = (SV *)GvHVn(src); break;
Branch: 1 branch
BranchTrueFalseTotal
case '%': thing = (SV *)GvHVn(src); break; 586 0 586
330 1094 case '*': thing = (SV *)src; break;
331 1 default: thing = NULL; break;
332 }
333 10855 ▶ if (!thing || !(dgv = eo_stash_gv_add(aTHX_ dststash, s, len, FALSE))) {
Branch: 2 branches
BranchTrueFalseTotal
if (!thing || !(dgv = eo_stash_gv_add(aTHX_ dststash, s, len, FALSE))) { 10853 2 10855
if (!thing || !(dgv = eo_stash_gv_add(aTHX_ dststash, s, len, FALSE))) { 561 10292 10853
334 563 eo_install_slow(aTHX_ pkg, callpkg, name);
335 562 return;
336 }
337  
338 10292 ▶ if (type == '*') {
Branch: 1 branch
BranchTrueFalseTotal
if (type == '*') { 1093 9199 10292
339 1093 sv_setsv_mg((SV *)dgv, thing);
340 1093 GvIMPORTED_on(dgv);
341 1093 return;
342 }
343 9199 ref = newRV_inc(thing);
344 9199 sv_setsv_mg((SV *)dgv, ref);
345 9199 SvREFCNT_dec(ref);
346 9199 switch (type) { /* # uncoverable branch true count:5 */
347 5397 case '&': GvIMPORTED_CV_on(dgv); break;
348 1700 case '$': GvIMPORTED_SV_on(dgv); break;
349 1519 case '@': GvIMPORTED_AV_on(dgv); break;
350 583 case '%': GvIMPORTED_HV_on(dgv); break;
351 }
352 }
353  
354 static void
355 587 eo_install_slow(pTHX_ SV *pkg, SV *callpkg, SV *name)
356 {
357 STRLEN len;
358 587 const char *s = SvPV_const(name, len);
359 587 bool utf8 = SvUTF8(name) ? TRUE : FALSE;
360 587 char type = '&';
361 SV *src, *dst, *ref;
362 GV *gv, *dgv;
363  
364 587 ▶ if (!eo_is_word_start(s, len, utf8)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!eo_is_word_start(s, len, utf8)) { 15 572 587
365 15 type = *s;
366 15 s++;
367 15 len--;
368 }
369  
370 587 src = eo_qualify(aTHX_ pkg, s, len, utf8);
371 587 dst = eo_qualify(aTHX_ callpkg, s, len, utf8);
372  
373 587 switch (type) {
374 572 case '&': {
375 HV *st;
376 572 CV *cv = sv_2cv(src, &st, &gv, GV_ADDMULTI);
377 572 ref = sv_2mortal(newRV_inc((SV *)cv));
378 572 break;
379 }
380 6 case '$':
381 6 gv = gv_fetchsv(src, GV_ADDMULTI, SVt_PV);
382 6 ▶ ref = sv_2mortal(newRV_inc(GvSVn(gv)));
Branch: 1 branch
BranchTrueFalseTotal
ref = sv_2mortal(newRV_inc(GvSVn(gv))); 5 1 6
383 6 break;
384 3 case '@':
385 3 gv = gv_fetchsv(src, GV_ADDMULTI, SVt_PVAV);
386 3 ▶ ref = sv_2mortal(newRV_inc((SV *)GvAVn(gv)));
Branch: 1 branch
BranchTrueFalseTotal
ref = sv_2mortal(newRV_inc((SV *)GvAVn(gv))); 3 0 3
387 3 break;
388 3 case '%':
389 3 gv = gv_fetchsv(src, GV_ADDMULTI, SVt_PVHV);
390 3 ▶ ref = sv_2mortal(newRV_inc((SV *)GvHVn(gv)));
Branch: 1 branch
BranchTrueFalseTotal
ref = sv_2mortal(newRV_inc((SV *)GvHVn(gv))); 3 0 3
391 3 break;
392 1 case '*':
393 1 ref = (SV *)gv_fetchsv(src, GV_ADDMULTI, SVt_PVGV);
394 1 break;
395 2 default:
396 2 Perl_croak(aTHX_ "Can't export symbol: %c%" SVf, type,
397 2 ▶ SVfARG(newSVpvn_flags(s, len, SVs_TEMP | (utf8 ? SVf_UTF8 : 0))));
Branch: 1 branch
BranchTrueFalseTotal
SVfARG(newSVpvn_flags(s, len, SVs_TEMP | (utf8 ? SVf_UTF8 : 0)))); 1 1 2
398 }
399  
400 585 dgv = gv_fetchsv(dst, GV_ADDMULTI, SVt_PVGV);
401 585 sv_setsv_mg((SV *)dgv, ref);
402  
403 584 switch (type) { /* # uncoverable branch true count:6 class:ignore_covered_err */
404 571 case '&': GvIMPORTED_CV_on(dgv); break;
405 6 case '$': GvIMPORTED_SV_on(dgv); break;
406 3 case '@': GvIMPORTED_AV_on(dgv); break;
407 3 case '%': GvIMPORTED_HV_on(dgv); break;
408 1 case '*': GvIMPORTED_on(dgv); break;
409 }
410 584 }
411  
412 /* Exporter assigns the globs from its own file, which has no lexical
413 * warnings, so a redefinition warns only under $^W. The copy of the caller's
414 * statement keeps its file and line for the message and drops its warnings. */
415 static void
416 3122 eo_install_list(pTHX_ SV *pkg, SV *callpkg, HV *srcstash, SV **list, SSize_t n)
417 {
418 COP fake;
419 SSize_t i;
420  
421 3122 ENTER;
422 3122 StructCopy(PL_curcop, &fake, COP);
423 3122 fake.cop_warnings = pWARN_STD;
424 3122 SAVEVPTR(PL_curcop);
425 3122 PL_curcop = &fake;
426  
427 {
428 3122 HV *dststash = gv_stashsv(callpkg, GV_ADD);
429 13998 ▶ for (i = 0; i < n; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) 10879 3119 13998
430 /*
431 # uncoverable branch false class:ignore_covered_err
432 # uncoverable condition right count:1 class:ignore_covered_err */
433 10879 ▶ if (list[i])
Branch: 1 branch
BranchTrueFalseTotal
if (list[i]) 10879 0 10879
434 10879 eo_install_one(aTHX_ pkg, callpkg, srcstash, dststash, list[i]);
435 }
436  
437 3119 LEAVE;
438 3119 }
439  
440 static void
441 3099 eo_install(pTHX_ SV *pkg, SV *callpkg, AV *names)
442 {
443 3099 eo_install_list(aTHX_ pkg, callpkg, gv_stashsv(pkg, 0), AvARRAY(names), av_len(names) + 1);
444 3096 }
445  
446 static void
447 1094 eo_call_version(pTHX_ SV *pkg, SV *wanted)
448 {
449 1094 dSP;
450 1094 ENTER;
451 1094 SAVETMPS;
452 1094 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 1094 1094
453 1094 ▶ XPUSHs(pkg);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(pkg); 0 1094 1094
454 1094 ▶ XPUSHs(wanted);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(wanted); 0 1094 1094
455 1094 PUTBACK;
456 1094 call_method("VERSION", G_DISCARD);
457 1090 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 1090 0 1090
458 1090 LEAVE;
459 1090 }
460  
461 /* The names in a list of specs, in the order first added. Exporter keeps
462 * them in a hash, so its order is the hash's; the set is the same. */
463 typedef struct {
464 AV *order;
465 HV *at;
466 } eo_picks;
467  
468 static void
469 29804 eo_pick(pTHX_ eo_picks *p, SV *name, bool remove)
470 {
471 29804 ▶ if (remove) {
Branch: 1 branch
BranchTrueFalseTotal
if (remove) { 6158 23646 29804
472 6158 (void)hv_delete_ent(p->at, name, G_DISCARD, 0);
473 }
474 23646 ▶ else if (!hv_exists_ent(p->at, name, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
else if (!hv_exists_ent(p->at, name, 0)) { 21047 2599 23646
475 21047 av_push(p->order, newSVsv(name));
476 21047 (void)hv_store_ent(p->at, name, newSViv(av_len(p->order)), 0);
477 }
478 29804 }
479  
480 static AV *
481 5229 eo_picked(pTHX_ eo_picks *p)
482 {
483 5229 AV *out = (AV *)sv_2mortal((SV *)newAV());
484 5229 SSize_t i, top = av_len(p->order);
485 26276 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 21047 5229 26276
486 21047 SV *name = *av_fetch(p->order, i, 0);
487 21047 HE *he = hv_fetch_ent(p->at, name, 0, 0);
488 21047 ▶ if (he && SvIV(HeVAL(he)) == i)
Branch: 2 branches
BranchTrueFalseTotal
if (he && SvIV(HeVAL(he)) == i) 18825 2222 21047
if (he && SvIV(HeVAL(he)) == i) 18358 467 18825
489 18358 av_push(out, newSVsv(name));
490 }
491 5229 return out;
492 }
493  
494 static bool
495 6421 eo_has_specs(pTHX_ AV *names)
496 {
497 6421 SSize_t i, top = av_len(names);
498 12971 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 11784 1187 12971
499 STRLEN len;
500 11784 const char *s = SvPV_const(*av_fetch(names, i, 0), len);
501 11784 ▶ if (len && (*s == '/' || *s == '!' || *s == ':'))
Branch: 4 branches
BranchTrueFalseTotal
if (len && (*s == '/' || *s == '!' || *s == ':')) 11099 685 11784
if (len && (*s == '/' || *s == '!' || *s == ':')) 10432 667 11099
if (len && (*s == '/' || *s == '!' || *s == ':')) 8482 1950 10432
if (len && (*s == '/' || *s == '!' || *s == ':')) 2617 5865 8482
502 5234 return TRUE;
503 }
504 1187 return FALSE;
505 }
506  
507 static AV *
508 1853 eo_all_exports(pTHX_ AV *exp, AV *ok)
509 {
510 1853 AV *all = (AV *)sv_2mortal((SV *)newAV());
511 1853 HV *seen = (HV *)sv_2mortal((SV *)newHV());
512 AV *lists[2];
513 int l;
514 1853 lists[0] = exp;
515 1853 lists[1] = ok;
516 5559 ▶ for (l = 0; l < 2; l++) {
Branch: 1 branch
BranchTrueFalseTotal
for (l = 0; l < 2; l++) { 3706 1853 5559
517 SSize_t i, top;
518 /*
519 # uncoverable branch true
520 # uncoverable condition left count:1 */
521 3706 ▶ if (!lists[l])
Branch: 1 branch
BranchTrueFalseTotal
if (!lists[l]) 0 3706 3706
522 0 continue; /* # uncoverable statement */
523 3706 top = av_len(lists[l]);
524 20418 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 16712 3706 20418
525 16712 SV **svp = av_fetch(lists[l], i, 0);
526 SV *name;
527 16712 ▶ if (!svp)
Branch: 1 branch
BranchTrueFalseTotal
if (!svp) 3 16709 16712
528 3 continue;
529 16709 name = eo_strip_amp(aTHX_ *svp);
530 16709 ▶ if (hv_exists_ent(seen, name, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (hv_exists_ent(seen, name, 0)) 1 16708 16709
531 1 continue;
532 16708 (void)hv_store_ent(seen, name, &PL_sv_yes, 0);
533 16708 av_push(all, newSVsv(name));
534 }
535 }
536 1853 return all;
537 }
538  
539 static void
540 2066 eo_grep(pTHX_ AV *into, AV *from, const char *pat, STRLEN plen, bool utf8)
541 {
542 2066 ▶ SV *patsv = newSVpvn_flags(pat, plen, SVs_TEMP | (utf8 ? SVf_UTF8 : 0));
Branch: 1 branch
BranchTrueFalseTotal
SV *patsv = newSVpvn_flags(pat, plen, SVs_TEMP | (utf8 ? SVf_UTF8 : 0)); 1 2065 2066
543 REGEXP *rx;
544 COP fake;
545 2066 SSize_t i, top = av_len(from);
546  
547 2066 ENTER;
548 2066 StructCopy(PL_curcop, &fake, COP);
549 2066 fake.cop_hints = 0;
550 2066 SAVEVPTR(PL_curcop);
551 2066 PL_curcop = &fake;
552 2066 SAVEI32(*(I32 *)&PL_hints);
553 2066 PL_hints = 0;
554 2066 rx = pregcomp(patsv, 0);
555 2063 LEAVE;
556  
557 20647 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 18584 2063 20647
558 18584 SV *name = *av_fetch(from, i, 0);
559 STRLEN len;
560 18584 char *s = SvPV(name, len);
561 18584 ▶ if (pregexec(rx, s, s + len, s, 0, name, 1))
Branch: 1 branch
BranchTrueFalseTotal
if (pregexec(rx, s, s + len, s, 0, name, 1)) 8225 10359 18584
562 8225 av_push(into, newSVsv(name));
563 }
564 2063 ReREFCNT_dec(rx);
565 2063 }
566  
567 static AV *
568 5234 eo_walk_specs(pTHX_ SV *pkg, AV *specs, AV *exp, AV *ok, bool verbose, I32 *oops)
569 {
570 5234 HV *tags = eo_pkg_hv(aTHX_ pkg, STR_WITH_LEN("EXPORT_TAGS"));
571 5234 AV *all = NULL;
572 eo_picks p;
573 SSize_t i, top;
574  
575 5234 p.order = (AV *)sv_2mortal((SV *)newAV());
576 5234 p.at = (HV *)sv_2mortal((SV *)newHV());
577  
578 /*
579 # uncoverable branch false class:ignore_covered_err
580 # uncoverable condition right count:1 class:ignore_covered_err */
581 5234 ▶ if (av_len(specs) >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(specs) >= 0) { 5234 0 5234
582 STRLEN len;
583 5234 const char *s = SvPV_const(*av_fetch(specs, 0, 0), len);
584 5234 ▶ if (len && *s == '!')
Branch: 2 branches
BranchTrueFalseTotal
if (len && *s == '!') 4970 264 5234
if (len && *s == '!') 1051 3919 4970
585 1051 av_unshift(specs, 1), av_store(specs, 0, newSVpvs(":DEFAULT"));
586 }
587  
588 5234 top = av_len(specs);
589 21632 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 16403 5229 21632
590 16403 SV *spec = *av_fetch(specs, i, 0);
591 16403 AV *names = (AV *)sv_2mortal((SV *)newAV());
592 STRLEN len;
593 16403 const char *s = SvPV_const(spec, len);
594 16403 bool utf8 = SvUTF8(spec) ? TRUE : FALSE;
595 16403 bool remove = FALSE;
596 SSize_t j, ntop;
597  
598 16403 ▶ if (len && *s == '!') {
Branch: 2 branches
BranchTrueFalseTotal
if (len && *s == '!') { 15619 784 16403
if (len && *s == '!') { 3085 12534 15619
599 3085 remove = TRUE;
600 3085 s++;
601 3085 len--;
602 }
603  
604 21578 ▶ if (len && *s == ':') {
Branch: 2 branches
BranchTrueFalseTotal
if (len && *s == ':') { 15619 784 16403
if (len && *s == ':') { 6204 9415 15619
605 6204 ▶ SV *tag = newSVpvn_flags(s + 1, len - 1, SVs_TEMP | (utf8 ? SVf_UTF8 : 0));
Branch: 1 branch
BranchTrueFalseTotal
SV *tag = newSVpvn_flags(s + 1, len - 1, SVs_TEMP | (utf8 ? SVf_UTF8 : 0)); 2 6202 6204
606 HE *he;
607 6204 ▶ if (len - 1 == 7 && memEQ(s + 1, "DEFAULT", 7)) {
Branch: 2 branches
BranchTrueFalseTotal
if (len - 1 == 7 && memEQ(s + 1, "DEFAULT", 7)) { 2080 4124 6204
if (len - 1 == 7 && memEQ(s + 1, "DEFAULT", 7)) { 2079 1 2080
608 2079 eo_av_append(aTHX_ names, exp);
609 }
610 7221 ▶ else if (tags && (he = hv_fetch_ent(tags, tag, 0, 0)) && SvTRUE(HeVAL(he))) { /* # uncoverable condition right count:1 */
Branch: 3 branches
BranchTrueFalseTotal
else if (tags && (he = hv_fetch_ent(tags, tag, 0, 0)) && SvTRUE(HeVAL(he))) { /* # uncoverable condition right count:1 */ 4125 0 4125
else if (tags && (he = hv_fetch_ent(tags, tag, 0, 0)) && SvTRUE(HeVAL(he))) { /* # uncoverable condition right count:1 */ 3099 1026 4125
else if (tags && (he = hv_fetch_ent(tags, tag, 0, 0)) && SvTRUE(HeVAL(he))) { /* # uncoverable condition right count:1 */ 3098 1 3099
611 3098 SV *val = HeVAL(he);
612 3098 ▶ if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVAV) 3097 1 3098
if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVAV) 1 3096 3097
613 2 Perl_croak(aTHX_ "Not an ARRAY reference");
614 3096 eo_av_append(aTHX_ names, (AV *)SvRV(val));
615 }
616 else {
617 1027 Perl_warn(aTHX_ "\"%" SVf "\" is not defined in %%%" SVf "::EXPORT_TAGS",
618 SVfARG(tag), SVfARG(pkg));
619 1027 ++*oops;
620 1027 continue;
621 }
622 }
623 10199 ▶ else if (len >= 2 && *s == '/'
Branch: 2 branches
BranchTrueFalseTotal
else if (len >= 2 && *s == '/' 9414 785 10199
else if (len >= 2 && *s == '/' 2069 7345 9414
624 4132 ▶ && (s[len - 1] == '/' || (len >= 3 && s[len - 1] == '\n' && s[len - 2] == '/'))) {
Branch: 4 branches
BranchTrueFalseTotal
&& (s[len - 1] == '/' || (len >= 3 && s[len - 1] == '\n' && s[len - 2] == '/'))) { 4 2065 2069
&& (s[len - 1] == '/' || (len >= 3 && s[len - 1] == '\n' && s[len - 2] == '/'))) { 3 1 4
&& (s[len - 1] == '/' || (len >= 3 && s[len - 1] == '\n' && s[len - 2] == '/'))) { 2 1 3
&& (s[len - 1] == '/' || (len >= 3 && s[len - 1] == '\n' && s[len - 2] == '/'))) { 1 1 2
625 2066 ▶ STRLEN plen = s[len - 1] == '/' ? len - 2 : len - 3;
Branch: 1 branch
BranchTrueFalseTotal
STRLEN plen = s[len - 1] == '/' ? len - 2 : len - 3; 2065 1 2066
626 2066 ▶ if (!all)
Branch: 1 branch
BranchTrueFalseTotal
if (!all) 1853 213 2066
627 1853 all = eo_all_exports(aTHX_ exp, ok);
628 2066 eo_grep(aTHX_ names, all, s + 1, plen, utf8);
629 }
630 else {
631 8133 ▶ av_push(names, newSVpvn_flags(s, len, utf8 ? SVf_UTF8 : 0));
Branch: 1 branch
BranchTrueFalseTotal
av_push(names, newSVpvn_flags(s, len, utf8 ? SVf_UTF8 : 0)); 1 8132 8133
632 }
633  
634 15371 ▶ if (verbose)
Branch: 1 branch
BranchTrueFalseTotal
if (verbose) 3 15368 15371
635 3 ▶ Perl_warn(aTHX_ "Import %s: %" SVf " ", remove ? "del" : "add",
Branch: 1 branch
BranchTrueFalseTotal
Perl_warn(aTHX_ "Import %s: %" SVf " ", remove ? "del" : "add", 1 2 3
636 3 SVfARG(eo_join(aTHX_ names, " ")));
637  
638 15371 ntop = av_len(names);
639 45175 ▶ for (j = 0; j <= ntop; j++)
Branch: 1 branch
BranchTrueFalseTotal
for (j = 0; j <= ntop; j++) 29804 15371 45175
640 29804 eo_pick(aTHX_ &p, *av_fetch(names, j, 0), remove);
641 }
642  
643 5229 return eo_picked(aTHX_ &p);
644 }
645  
646 static AV *
647 677 eo_call_export_fail(pTHX_ SV *pkg, AV *failed)
648 {
649 dMY_CXT;
650 677 HV *stash = gv_stashsv(pkg, 0);
651 677 ▶ GV *meth = stash ? gv_fetchmethod_autoload(stash, "export_fail", FALSE) : NULL; /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
GV *meth = stash ? gv_fetchmethod_autoload(stash, "export_fail", FALSE) : NULL; /* # uncoverable condition right count:1 */ 677 0 677
652 677 ▶ CV *fcv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL;
Branch: 4 branches
BranchTrueFalseTotal
CV *fcv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL; 673 4 677
CV *fcv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL; 673 0 673
CV *fcv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL; 0 673 673
CV *fcv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL; 0 0 0
653 677 AV *out = (AV *)sv_2mortal((SV *)newAV());
654 SSize_t i, top;
655 I32 count;
656 677 dSP;
657  
658 677 ▶ if (!fcv || fcv == MY_CXT.export_fail_cv) {
Branch: 2 branches
BranchTrueFalseTotal
if (!fcv || fcv == MY_CXT.export_fail_cv) { 673 4 677
if (!fcv || fcv == MY_CXT.export_fail_cv) { 1 672 673
659 5 eo_av_append(aTHX_ out, failed);
660 5 return out;
661 }
662  
663 672 ENTER;
664 672 SAVETMPS;
665 672 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 672 672
666 672 top = av_len(failed);
667 672 ▶ EXTEND(SP, top + 2);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(SP, top + 2); 672 0 672
EXTEND(SP, top + 2); 0 672 672
668 672 PUSHs(pkg);
669 1371 ▶ for (i = 0; i <= top; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) 699 672 1371
670 699 PUSHs(*av_fetch(failed, i, 0));
671 672 PUTBACK;
672 672 count = call_sv((SV *)fcv, G_ARRAY);
673 672 SPAGAIN;
674 1364 ▶ for (i = 0; i < count; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < count; i++) 692 672 1364
675 692 av_push(out, newSVsv(SP[i - count + 1]));
676 672 SP -= count;
677 672 PUTBACK;
678 672 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 668 4 672
679 672 LEAVE;
680 672 return out;
681 }
682  
683 static void
684 3772 eo_check_fail(pTHX_ SV *pkg, AV *names, bool verbose)
685 {
686 3772 AV *fail = eo_pkg_av(aTHX_ pkg, STR_WITH_LEN("EXPORT_FAIL"));
687 HV *fset;
688 AV *expanded, *failed;
689 SSize_t i, top;
690  
691 3772 ▶ if (!fail || av_len(fail) < 0)
Branch: 2 branches
BranchTrueFalseTotal
if (!fail || av_len(fail) < 0) 3749 23 3772
if (!fail || av_len(fail) < 0) 59 3690 3749
692 82 return;
693  
694 3690 fset = (HV *)sv_2mortal((SV *)newHV());
695 3690 expanded = (AV *)sv_2mortal((SV *)newAV());
696 3690 top = av_len(fail);
697 7428 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 3738 3690 7428
698 3738 SV **svp = av_fetch(fail, i, 0);
699 STRLEN len;
700 const char *s;
701 3738 ▶ if (!svp)
Branch: 1 branch
BranchTrueFalseTotal
if (!svp) 5 3733 3738
702 5 continue;
703 3733 s = SvPV_const(*svp, len);
704 3733 av_push(expanded, newSVsv(*svp));
705 3733 (void)hv_store_ent(fset, *svp, &PL_sv_yes, 0);
706 3733 ▶ if (len && eo_is_word_start(s, len, SvUTF8(*svp) ? TRUE : FALSE)) {
Branch: 2 branches
BranchTrueFalseTotal
if (len && eo_is_word_start(s, len, SvUTF8(*svp) ? TRUE : FALSE)) { 3731 2 3733
if (len && eo_is_word_start(s, len, SvUTF8(*svp) ? TRUE : FALSE)) { 3729 2 3731
707 3729 SV *amp = sv_2mortal(newSVpvs("&"));
708 3729 sv_catsv(amp, *svp);
709 3729 av_push(expanded, newSVsv(amp));
710 3729 (void)hv_store_ent(fset, amp, &PL_sv_yes, 0);
711 }
712 }
713 3690 ▶ if (verbose)
Branch: 1 branch
BranchTrueFalseTotal
if (verbose) 1 3689 3690
714 1 Perl_warn(aTHX_ "%" SVf "::EXPORT_FAIL cached: %" SVf,
715 1 SVfARG(pkg), SVfARG(eo_join(aTHX_ expanded, " ")));
716  
717 3690 failed = (AV *)sv_2mortal((SV *)newAV());
718 3690 top = av_len(names);
719 16812 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 13122 3690 16812
720 13122 SV *sym = *av_fetch(names, i, 0);
721 13122 ▶ if (hv_exists_ent(fset, sym, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (hv_exists_ent(fset, sym, 0)) 704 12418 13122
722 704 av_push(failed, newSVsv(sym));
723 }
724 3690 ▶ if (av_len(failed) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(failed) < 0) 3013 677 3690
725 3013 return;
726  
727 677 failed = eo_call_export_fail(aTHX_ pkg, failed);
728 677 top = av_len(failed);
729 1374 ▶ for (i = 0; i <= top; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) 697 677 1374
730 697 Perl_warn(aTHX_ "\"%" SVf "\" is not implemented by the %" SVf " module on this architecture",
731 697 SVfARG(*av_fetch(failed, i, 0)), SVfARG(pkg));
732 677 ▶ if (top >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (top >= 0) 673 4 677
733 673 Perl_croak(aTHX_ "Can't continue after import errors");
734 }
735  
736 static void
737 24498 eo_vivify(pTHX_ SV *pkg, const char *name, STRLEN len, svtype type)
738 {
739 24498 GV *gv = eo_stash_gv(aTHX_ gv_stashsv(pkg, 0), name, len, FALSE);
740 24498 ▶ if (!gv)
Branch: 1 branch
BranchTrueFalseTotal
if (!gv) 52 24446 24498
741 52 gv = gv_fetchsv(eo_qualify(aTHX_ pkg, name, len, FALSE), GV_ADDMULTI, type);
742 24498 ▶ if (type == SVt_PVAV)
Branch: 1 branch
BranchTrueFalseTotal
if (type == SVt_PVAV) 19264 5234 24498
743 19264 ▶ (void)GvAVn(gv);
Branch: 1 branch
BranchTrueFalseTotal
(void)GvAVn(gv); 19264 0 19264
744 else
745 5234 ▶ (void)GvHVn(gv);
Branch: 1 branch
BranchTrueFalseTotal
(void)GvHVn(gv); 5234 0 5234
746 24498 }
747  
748 static bool
749 7227 eo_has_nonword(const char *s, STRLEN len, bool utf8)
750 {
751 STRLEN i;
752 13010 ▶ for (i = 0; i < len; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < len; i++) { 10944 2066 13010
753 10944 U8 c = (U8)s[i];
754 10944 ▶ if (utf8 && c >= 0x80)
Branch: 2 branches
BranchTrueFalseTotal
if (utf8 && c >= 0x80) 30 10914 10944
if (utf8 && c >= 0x80) 18 12 30
755 18 continue;
756 10926 ▶ if (!isWORDCHAR(c))
Branch: 1 branch
BranchTrueFalseTotal
if (!isWORDCHAR(c)) 5161 5765 10926
757 5161 return TRUE;
758 }
759 2066 return FALSE;
760 }
761  
762 /* Exporter.pm's import takes Exporter::Heavy only for some lists, and the
763 * heavy path is the one that touches @EXPORT_FAIL. This is its test. */
764 static bool
765 6430 eo_would_be_heavy(pTHX_ SV *pkg, AV *list, bool args, HV *set, bool verbose)
766 {
767 6430 HV *stash = gv_stashsv(pkg, 0);
768 6430 ▶ SV **failgv = stash ? hv_fetchs(stash, "EXPORT_FAIL", 0) : NULL; /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
SV **failgv = stash ? hv_fetchs(stash, "EXPORT_FAIL", 0) : NULL; /* # uncoverable condition right count:1 */ 6430 0 6430
769 6430 ▶ AV *fail = failgv ? eo_pkg_av(aTHX_ pkg, STR_WITH_LEN("EXPORT_FAIL")) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
AV *fail = failgv ? eo_pkg_av(aTHX_ pkg, STR_WITH_LEN("EXPORT_FAIL")) : NULL; 6389 41 6430
770 6430 SV *first = NULL;
771 SSize_t i, top;
772  
773 6430 ▶ if (verbose)
Branch: 1 branch
BranchTrueFalseTotal
if (verbose) 4 6426 6430
774 4 return TRUE;
775 6426 ▶ if (fail && av_len(fail) >= 1)
Branch: 2 branches
BranchTrueFalseTotal
if (fail && av_len(fail) >= 1) 6386 40 6426
if (fail && av_len(fail) >= 1) 57 6329 6386
776 57 return TRUE;
777 6369 ▶ if (fail && av_len(fail) >= 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (fail && av_len(fail) >= 0) { 6329 40 6369
if (fail && av_len(fail) >= 0) { 6277 52 6329
778 6277 SV **svp = av_fetch(fail, 0, 0);
779 6277 ▶ first = svp ? *svp : NULL;
Branch: 1 branch
BranchTrueFalseTotal
first = svp ? *svp : NULL; 6276 1 6277
780 }
781  
782 6369 ▶ top = list ? av_len(list) : -1; /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
top = list ? av_len(list) : -1; /* # uncoverable condition right count:1 */ 6369 0 6369
783 7178 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 7137 41 7178
784 7137 SV **svp = av_fetch(list, i, 0);
785 STRLEN len;
786 const char *s;
787 /*
788 # uncoverable branch true
789 # uncoverable condition left count:1 */
790 7137 ▶ if (!svp)
Branch: 1 branch
BranchTrueFalseTotal
if (!svp) 0 7137 7137
791 0 continue; /* # uncoverable statement */
792 7137 s = SvPV_const(*svp, len);
793 7137 ▶ if (eo_has_nonword(s, len, SvUTF8(*svp) ? TRUE : FALSE))
Branch: 1 branch
BranchTrueFalseTotal
if (eo_has_nonword(s, len, SvUTF8(*svp) ? TRUE : FALSE)) 5120 2017 7137
794 6328 return TRUE;
795 2017 ▶ if (args && set && !hv_exists_ent(set, *svp, 0)) /* # uncoverable condition right count:2 */
Branch: 3 branches
BranchTrueFalseTotal
if (args && set && !hv_exists_ent(set, *svp, 0)) /* # uncoverable condition right count:2 */ 1997 20 2017
if (args && set && !hv_exists_ent(set, *svp, 0)) /* # uncoverable condition right count:2 */ 1997 0 1997
if (args && set && !hv_exists_ent(set, *svp, 0)) /* # uncoverable condition right count:2 */ 820 1177 1997
796 820 return TRUE;
797 1197 ▶ if (first && sv_eq(*svp, first))
Branch: 2 branches
BranchTrueFalseTotal
if (first && sv_eq(*svp, first)) 1160 37 1197
if (first && sv_eq(*svp, first)) 388 772 1160
798 388 return TRUE;
799 }
800 41 return FALSE;
801 }
802  
803 static void
804 6465 eo_export(pTHX_ SV *pkg, SV *callpkg, SV **items, I32 n, const COP *errcop, bool via_import)
805 {
806 dMY_CXT;
807 AV *exp, *names;
808 6465 ▶ bool verbose = SvTRUE(GvSVn(MY_CXT.verbose_gv)) ? TRUE : FALSE; /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
bool verbose = SvTRUE(GvSVn(MY_CXT.verbose_gv)) ? TRUE : FALSE; /* # uncoverable condition right count:1 */ 6465 0 6465
809  
810 6465 ENTER;
811 6465 ▶ if (errcop && errcop != PL_curcop) {
Branch: 2 branches
BranchTrueFalseTotal
if (errcop && errcop != PL_curcop) { 6463 2 6465
if (errcop && errcop != PL_curcop) { 7 6456 6463
812 7 SAVEVPTR(PL_curcop);
813 7 PL_curcop = (COP *)errcop;
814 }
815  
816 /* The common import: plain names, every one already known, and nothing
817 * that would send Exporter.pm down its heavy path. It is installed
818 * straight from the stack. */
819 6465 ▶ if (n > 0 && via_import && !verbose) {
Branch: 3 branches
BranchTrueFalseTotal
if (n > 0 && via_import && !verbose) { 6444 21 6465
if (n > 0 && via_import && !verbose) { 6435 9 6444
if (n > 0 && via_import && !verbose) { 6432 3 6435
820 6432 HV *stash = gv_stashsv(pkg, 0);
821 6432 GV *expgv = eo_stash_gv(aTHX_ stash, STR_WITH_LEN("EXPORT"), FALSE);
822 6432 GV *okgv = eo_stash_gv(aTHX_ stash, STR_WITH_LEN("EXPORT_OK"), FALSE);
823 6432 ▶ SV **failp = stash ? hv_fetchs(stash, "EXPORT_FAIL", 0) : NULL; /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
SV **failp = stash ? hv_fetchs(stash, "EXPORT_FAIL", 0) : NULL; /* # uncoverable condition right count:1 */ 6432 0 6432
824 6432 ▶ AV *fail = (failp && isGV_with_GP(*failp)) ? GvAV((GV *)*failp) : NULL;
Branch: 4 branches
BranchTrueFalseTotal
AV *fail = (failp && isGV_with_GP(*failp)) ? GvAV((GV *)*failp) : NULL; 6395 37 6432
AV *fail = (failp && isGV_with_GP(*failp)) ? GvAV((GV *)*failp) : NULL; 6395 0 6395
AV *fail = (failp && isGV_with_GP(*failp)) ? GvAV((GV *)*failp) : NULL; 0 6395 6395
AV *fail = (failp && isGV_with_GP(*failp)) ? GvAV((GV *)*failp) : NULL; 0 0 0
825 6432 ▶ if (expgv && GvAV(expgv) && okgv && GvAV(okgv)
Branch: 4 branches
BranchTrueFalseTotal
if (expgv && GvAV(expgv) && okgv && GvAV(okgv) 6411 21 6432
if (expgv && GvAV(expgv) && okgv && GvAV(okgv) 6411 0 6411
if (expgv && GvAV(expgv) && okgv && GvAV(okgv) 6409 2 6411
if (expgv && GvAV(expgv) && okgv && GvAV(okgv) 6409 0 6409
826 6409 ▶ && (!failp || (isGV_with_GP(*failp) && (!fail || av_len(fail) < 0)))) {
Branch: 6 branches
BranchTrueFalseTotal
&& (!failp || (isGV_with_GP(*failp) && (!fail || av_len(fail) < 0)))) { 6389 20 6409
&& (!failp || (isGV_with_GP(*failp) && (!fail || av_len(fail) < 0)))) { 6389 0 6389
&& (!failp || (isGV_with_GP(*failp) && (!fail || av_len(fail) < 0)))) { 0 6389 6389
&& (!failp || (isGV_with_GP(*failp) && (!fail || av_len(fail) < 0)))) { 0 0 0
&& (!failp || (isGV_with_GP(*failp) && (!fail || av_len(fail) < 0)))) { 6389 0 6389
&& (!failp || (isGV_with_GP(*failp) && (!fail || av_len(fail) < 0)))) { 63 6326 6389
827 bool current;
828 83 HV *set = eo_cache_get(aTHX_ pkg, GvAV(expgv), GvAV(okgv), &current);
829 I32 i;
830 116 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 93 23 116
831 STRLEN len;
832 const char *s;
833 93 ▶ if (!SvPOK(items[i]) || SvGMAGICAL(items[i]))
Branch: 2 branches
BranchTrueFalseTotal
if (!SvPOK(items[i]) || SvGMAGICAL(items[i])) 92 1 93
if (!SvPOK(items[i]) || SvGMAGICAL(items[i])) 91 1 92
834 break;
835 91 s = SvPVX_const(items[i]);
836 91 len = SvCUR(items[i]);
837 91 ▶ if (!len || eo_has_nonword(s, len, SvUTF8(items[i]) ? TRUE : FALSE)
Branch: 2 branches
BranchTrueFalseTotal
if (!len || eo_has_nonword(s, len, SvUTF8(items[i]) ? TRUE : FALSE) 90 1 91
if (!len || eo_has_nonword(s, len, SvUTF8(items[i]) ? TRUE : FALSE) 49 41 90
838 49 ▶ || !hv_exists_ent(set, items[i], 0))
Branch: 1 branch
BranchTrueFalseTotal
|| !hv_exists_ent(set, items[i], 0)) 33 16 49
839 break;
840 }
841 83 ▶ if (i == n) {
Branch: 1 branch
BranchTrueFalseTotal
if (i == n) { 23 60 83
842 23 eo_install_list(aTHX_ pkg, callpkg, stash, items, n);
843 23 LEAVE;
844 23 return;
845 }
846 }
847 }
848  
849 6442 eo_vivify(aTHX_ pkg, STR_WITH_LEN("EXPORT"), SVt_PVAV);
850 6442 ▶ if (n)
Branch: 1 branch
BranchTrueFalseTotal
if (n) 6421 21 6442
851 6421 eo_vivify(aTHX_ pkg, STR_WITH_LEN("EXPORT_OK"), SVt_PVAV);
852 6442 exp = eo_pkg_av(aTHX_ pkg, STR_WITH_LEN("EXPORT"));
853  
854 6442 ▶ if (n == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (n == 0) { 21 6421 6442
855 21 names = eo_av_copy(aTHX_ exp);
856 21 ▶ if (!via_import || eo_would_be_heavy(aTHX_ pkg, names, FALSE, NULL, verbose))
Branch: 2 branches
BranchTrueFalseTotal
if (!via_import || eo_would_be_heavy(aTHX_ pkg, names, FALSE, NULL, verbose)) 18 3 21
if (!via_import || eo_would_be_heavy(aTHX_ pkg, names, FALSE, NULL, verbose)) 4 14 18
857 7 eo_vivify(aTHX_ pkg, STR_WITH_LEN("EXPORT_FAIL"), SVt_PVAV);
858 }
859 else {
860 6421 AV *ok = eo_pkg_av(aTHX_ pkg, STR_WITH_LEN("EXPORT_OK"));
861 bool current;
862 6421 HV *set = eo_cache_get(aTHX_ pkg, exp, ok, &current);
863 6421 SV *errors = NULL;
864 6421 I32 oops = 0;
865 SSize_t i, top;
866 I32 i32;
867  
868 6421 names = (AV *)sv_2mortal((SV *)newAV());
869 25101 ▶ for (i32 = 0; i32 < n; i32++)
Branch: 1 branch
BranchTrueFalseTotal
for (i32 = 0; i32 < n; i32++) 18680 6421 25101
870 18680 av_push(names, newSVsv(items[i32]));
871  
872 6421 ▶ if (!via_import || eo_would_be_heavy(aTHX_ pkg, names, TRUE, set, verbose))
Branch: 2 branches
BranchTrueFalseTotal
if (!via_import || eo_would_be_heavy(aTHX_ pkg, names, TRUE, set, verbose)) 6412 9 6421
if (!via_import || eo_would_be_heavy(aTHX_ pkg, names, TRUE, set, verbose)) 6385 27 6412
873 6394 eo_vivify(aTHX_ pkg, STR_WITH_LEN("EXPORT_FAIL"), SVt_PVAV);
874  
875 6421 ▶ if (eo_has_specs(aTHX_ names)) {
Branch: 1 branch
BranchTrueFalseTotal
if (eo_has_specs(aTHX_ names)) { 5234 1187 6421
876 5234 eo_vivify(aTHX_ pkg, STR_WITH_LEN("EXPORT_TAGS"), SVt_PVHV);
877 5234 names = eo_walk_specs(aTHX_ pkg, names, exp, ok, verbose, &oops);
878 }
879  
880 6416 top = av_len(names);
881 27954 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 21653 6301 27954
882 21653 SV *sym = *av_fetch(names, i, 0);
883 STRLEN len;
884 21653 const char *s = SvPV_const(sym, len);
885  
886 21653 ▶ if (hv_exists_ent(set, sym, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (hv_exists_ent(set, sym, 0)) 17496 4157 21653
887 19470 continue;
888  
889 4157 ▶ if (len && isDIGIT(*s)) {
Branch: 2 branches
BranchTrueFalseTotal
if (len && isDIGIT(*s)) { 3107 1050 4157
if (len && isDIGIT(*s)) { 1094 2013 3107
890 1094 eo_call_version(aTHX_ pkg, sym);
891 1090 ▶ if (top == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (top == 0) { 77 1013 1090
892 77 names = eo_av_copy(aTHX_ exp);
893 111 break;
894 }
895 1013 ▶ if (top == 1 && !SvTRUE(*av_fetch(names, 1, 0))) {
Branch: 2 branches
BranchTrueFalseTotal
if (top == 1 && !SvTRUE(*av_fetch(names, 1, 0))) { 237 776 1013
if (top == 1 && !SvTRUE(*av_fetch(names, 1, 0))) { 34 203 237
896 34 names = (AV *)sv_2mortal((SV *)newAV());
897 34 break;
898 }
899 979 continue;
900 }
901  
902 3063 ▶ if (len && *s == '&') {
Branch: 2 branches
BranchTrueFalseTotal
if (len && *s == '&') { 2013 1050 3063
if (len && *s == '&') { 995 1018 2013
903 995 sv_chop(sym, s + 1);
904 995 ▶ if (hv_exists_ent(set, sym, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (hv_exists_ent(set, sym, 0)) 993 2 995
905 993 continue;
906 }
907  
908 2070 ▶ if (!current) {
Branch: 1 branch
BranchTrueFalseTotal
if (!current) { 1896 174 2070
909 1896 set = eo_cache_build(aTHX_ pkg, exp, ok);
910 1896 current = TRUE;
911 1896 ▶ if (hv_exists_ent(set, sym, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (hv_exists_ent(set, sym, 0)) 2 1894 1896
912 2 continue;
913 }
914  
915 2068 ▶ if (!errors)
Branch: 1 branch
BranchTrueFalseTotal
if (!errors) 1894 174 2068
916 1894 errors = sv_2mortal(newSVpvs(""));
917 2068 sv_catpvf(errors, "\"%" SVf "\" is not exported by the %" SVf " module\n",
918 SVfARG(sym), SVfARG(pkg));
919 2068 oops++;
920 }
921  
922 6412 ▶ if (oops) {
Branch: 1 branch
BranchTrueFalseTotal
if (oops) { 2661 3751 6412
923 2661 ▶ if (!errors)
Branch: 1 branch
BranchTrueFalseTotal
if (!errors) 767 1894 2661
924 767 errors = sv_2mortal(newSVpvs(""));
925 2661 sv_catpvs(errors, "Can't continue after import errors");
926 2661 Perl_croak(aTHX_ "%" SVf, SVfARG(errors));
927 }
928 }
929  
930 3772 eo_check_fail(aTHX_ pkg, names, verbose);
931  
932 3099 ▶ if (verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if (verbose) { 4 3095 3099
933 4 AV *sorted = eo_av_copy(aTHX_ names);
934 4 ▶ if (av_len(sorted) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(sorted) > 0) 2 2 4
935 2 sortsv(AvARRAY(sorted), av_len(sorted) + 1, Perl_sv_cmp);
936 4 Perl_warn(aTHX_ "Importing into %" SVf " from %" SVf ": %" SVf,
937 4 SVfARG(callpkg), SVfARG(pkg), SVfARG(eo_join(aTHX_ sorted, ", ")));
938 }
939  
940 3099 eo_install(aTHX_ pkg, callpkg, names);
941 3096 LEAVE;
942 }
943  
944 static void
945 83 eo_setup(pTHX_ SV **items, I32 n)
946 {
947 dMY_CXT;
948 83 bool want_import = TRUE;
949 83 SV *errors = NULL;
950 I32 i;
951  
952 97 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 14 83 97
953 STRLEN len;
954 14 const char *s = SvPV_const(items[i], len);
955 14 ▶ if (len == 6 && memEQ(s, "import", 6))
Branch: 2 branches
BranchTrueFalseTotal
if (len == 6 && memEQ(s, "import", 6)) 8 6 14
if (len == 6 && memEQ(s, "import", 6)) 3 5 8
956 9 continue;
957 11 ▶ if (len == 9 && memEQ(s, "-noimport", 9)) {
Branch: 2 branches
BranchTrueFalseTotal
if (len == 9 && memEQ(s, "-noimport", 9)) { 3 8 11
if (len == 9 && memEQ(s, "-noimport", 9)) { 2 1 3
958 2 want_import = FALSE;
959 2 continue;
960 }
961 9 ▶ if (len == 6 && memEQ(s, "strict", 6)) {
Branch: 2 branches
BranchTrueFalseTotal
if (len == 6 && memEQ(s, "strict", 6)) { 5 4 9
if (len == 6 && memEQ(s, "strict", 6)) { 4 1 5
962 SV **v;
963 4 PL_hints |= HINT_LOCALIZE_HH;
964 4 ▶ v = hv_stores(GvHVn(PL_hintgv), EO_STRICT_KEY, newSViv(1));
Branch: 1 branch
BranchTrueFalseTotal
v = hv_stores(GvHVn(PL_hintgv), EO_STRICT_KEY, newSViv(1)); 4 0 4
965 /*
966 # uncoverable branch false
967 # uncoverable condition right count:1 */
968 4 ▶ if (v)
Branch: 1 branch
BranchTrueFalseTotal
if (v) 4 0 4
969 4 ▶ SvSETMAGIC(*v);
Branch: 1 branch
BranchTrueFalseTotal
SvSETMAGIC(*v); 4 0 4
970 4 continue;
971 }
972 5 ▶ if (!errors)
Branch: 1 branch
BranchTrueFalseTotal
if (!errors) 3 2 5
973 3 errors = sv_2mortal(newSVpvs(""));
974 5 sv_catpvf(errors, "\"%" SVf "\" is not exported by the Ex::Op module\n",
975 SVfARG(items[i]));
976 }
977 83 ▶ if (errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (errors) { 3 80 83
978 3 sv_catpvs(errors, "Can't continue after import errors");
979 3 Perl_croak(aTHX_ "%" SVf, SVfARG(errors));
980 }
981  
982 {
983 SV **v;
984 80 PL_hints |= HINT_LOCALIZE_HH;
985 80 ▶ v = hv_stores(GvHVn(PL_hintgv), EO_KW_KEY, newSViv(1));
Branch: 1 branch
BranchTrueFalseTotal
v = hv_stores(GvHVn(PL_hintgv), EO_KW_KEY, newSViv(1)); 80 0 80
986 /*
987 # uncoverable branch false
988 # uncoverable condition right count:1 */
989 80 ▶ if (v)
Branch: 1 branch
BranchTrueFalseTotal
if (v) 80 0 80
990 80 ▶ SvSETMAGIC(*v);
Branch: 1 branch
BranchTrueFalseTotal
SvSETMAGIC(*v); 80 0 80
991 }
992  
993 80 ▶ if (want_import) {
Branch: 1 branch
BranchTrueFalseTotal
if (want_import) { 78 2 80
994 78 SV *callpkg = eo_stash_name(aTHX_ CopSTASH(PL_curcop));
995 78 SV *dst = eo_qualify(aTHX_ callpkg, STR_WITH_LEN("import"), FALSE);
996 78 GV *gv = gv_fetchsv(dst, 0, SVt_PVCV);
997 78 ▶ CV *have = (gv && isGV_with_GP(gv)) ? GvCVu(gv) : NULL;
Branch: 5 branches
BranchTrueFalseTotal
CV *have = (gv && isGV_with_GP(gv)) ? GvCVu(gv) : NULL; 8 70 78
CV *have = (gv && isGV_with_GP(gv)) ? GvCVu(gv) : NULL; 8 0 8
CV *have = (gv && isGV_with_GP(gv)) ? GvCVu(gv) : NULL; 0 8 8
CV *have = (gv && isGV_with_GP(gv)) ? GvCVu(gv) : NULL; 0 0 0
CV *have = (gv && isGV_with_GP(gv)) ? GvCVu(gv) : NULL; 8 0 8
998 78 ▶ if (!have || !(CvROOT(have) || CvXSUB(have))) { /* # uncoverable condition right count:3 class:ignore_covered_err */
Branch: 3 branches
BranchTrueFalseTotal
if (!have || !(CvROOT(have) || CvXSUB(have))) { /* # uncoverable condition right count:3 class:ignore_covered_err */ 6 72 78
if (!have || !(CvROOT(have) || CvXSUB(have))) { /* # uncoverable condition right count:3 class:ignore_covered_err */ 1 5 6
if (!have || !(CvROOT(have) || CvXSUB(have))) { /* # uncoverable condition right count:3 class:ignore_covered_err */ 1 0 1
999 73 gv = gv_fetchsv(dst, GV_ADDMULTI, SVt_PVGV);
1000 73 sv_setsv_mg((SV *)gv, sv_2mortal(newRV_inc((SV *)MY_CXT.import_cv)));
1001 73 GvIMPORTED_CV_on(gv);
1002 }
1003 }
1004 80 }
1005  
1006 static void
1007 12 eo_push_tags(pTHX_ const char *var, STRLEN varlen, SV **items, I32 n)
1008 {
1009 12 SV *pkg = eo_stash_name(aTHX_ CopSTASH(PL_curcop));
1010 12 HV *tags = eo_pkg_hv(aTHX_ pkg, STR_WITH_LEN("EXPORT_TAGS"));
1011 12 ▶ AV *target = GvAVn(gv_fetchsv(eo_qualify(aTHX_ pkg, var, varlen, FALSE), GV_ADDMULTI, SVt_PVAV));
Branch: 1 branch
BranchTrueFalseTotal
AV *target = GvAVn(gv_fetchsv(eo_qualify(aTHX_ pkg, var, varlen, FALSE), GV_ADDMULTI, SVt_PVAV)); 12 0 12
1012 12 AV *list = (AV *)sv_2mortal((SV *)newAV());
1013 12 AV *nontag = (AV *)sv_2mortal((SV *)newAV());
1014 SSize_t i, top;
1015 I32 i32;
1016  
1017 12 ▶ if (n) {
Branch: 1 branch
BranchTrueFalseTotal
if (n) { 8 4 12
1018 19 ▶ for (i32 = 0; i32 < n; i32++)
Branch: 1 branch
BranchTrueFalseTotal
for (i32 = 0; i32 < n; i32++) 11 8 19
1019 11 av_push(list, newSVsv(items[i32]));
1020 }
1021 4 ▶ else if (tags) {
Branch: 1 branch
BranchTrueFalseTotal
else if (tags) { 3 1 4
1022 HE *he;
1023 3 hv_iterinit(tags);
1024 9 ▶ while ((he = hv_iternext(tags)))
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(tags))) 6 3 9
1025 6 av_push(list, newSVsv(hv_iterkeysv(he)));
1026 3 ▶ if (av_len(list) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (av_len(list) > 0) 2 1 3
1027 2 sortsv(AvARRAY(list), av_len(list) + 1, Perl_sv_cmp);
1028 }
1029  
1030 12 top = av_len(list);
1031 27 ▶ for (i = 0; i <= top; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) { 17 10 27
1032 17 SV *name = *av_fetch(list, i, 0);
1033 17 ▶ HE *he = tags ? hv_fetch_ent(tags, name, 0, 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
HE *he = tags ? hv_fetch_ent(tags, name, 0, 0) : NULL; 16 1 17
1034 26 ▶ if (he && SvTRUE(HeVAL(he))) {
Branch: 2 branches
BranchTrueFalseTotal
if (he && SvTRUE(HeVAL(he))) { 12 5 17
if (he && SvTRUE(HeVAL(he))) { 11 1 12
1035 11 SV *val = HeVAL(he);
1036 11 ▶ if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVAV) 10 1 11
if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVAV) 1 9 10
1037 2 Perl_croak(aTHX_ "Not an ARRAY reference");
1038 9 eo_av_append(aTHX_ target, (AV *)SvRV(val));
1039 }
1040 else {
1041 6 av_push(nontag, newSVsv(name));
1042 6 av_push(target, newSVsv(name));
1043 }
1044 }
1045  
1046 10 ▶ if (av_len(nontag) >= 0 && (PL_dowarn & G_WARN_ON))
Branch: 2 branches
BranchTrueFalseTotal
if (av_len(nontag) >= 0 && (PL_dowarn & G_WARN_ON)) 4 6 10
if (av_len(nontag) >= 0 && (PL_dowarn & G_WARN_ON)) 1 3 4
1047 1 Perl_warn(aTHX_ "%" SVf " are not tags of %" SVf,
1048 1 SVfARG(eo_join(aTHX_ nontag, ", ")), SVfARG(pkg));
1049 10 }
1050  
1051 MODULE = Ex::Op PACKAGE = Ex::Op
1052  
1053 PROTOTYPES: DISABLE
1054  
1055 void
1056 import(...)
1057 CODE:
1058 {
1059 SV *pkg;
1060 6537 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 1 6536 6537
1061 1 XSRETURN_EMPTY;
1062 6536 pkg = ST(0);
1063 13071 ▶ if (!SvROK(pkg) && strEQ(SvPV_nolen_const(pkg), "Ex::Op")) {
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(pkg) && strEQ(SvPV_nolen_const(pkg), "Ex::Op")) { 6535 1 6536
if (!SvROK(pkg) && strEQ(SvPV_nolen_const(pkg), "Ex::Op")) { 83 6452 6535
1064 83 eo_setup(aTHX_ &ST(1), items - 1);
1065 }
1066 else {
1067 dMY_CXT;
1068 6453 ▶ IV level = SvIV(GvSVn(MY_CXT.level_gv));
Branch: 1 branch
BranchTrueFalseTotal
IV level = SvIV(GvSVn(MY_CXT.level_gv)); 6453 0 6453
1069 6453 const COP *at = eo_caller_cop(aTHX_ level);
1070 6453 ▶ SV *callpkg = eo_stash_name(aTHX_ at ? CopSTASH(at) : NULL);
Branch: 1 branch
BranchTrueFalseTotal
SV *callpkg = eo_stash_name(aTHX_ at ? CopSTASH(at) : NULL); 6452 1 6453
1071 6453 eo_export(aTHX_ sv_mortalcopy(pkg), callpkg, &ST(1), items - 1, at, TRUE);
1072 }
1073 3188 XSRETURN_EMPTY;
1074 }
1075  
1076 void
1077 unimport(...)
1078 CODE:
1079 {
1080 6 ▶ if (items < 1 || SvROK(ST(0)) || !strEQ(SvPV_nolen_const(ST(0)), "Ex::Op"))
Branch: 3 branches
BranchTrueFalseTotal
if (items < 1 || SvROK(ST(0)) || !strEQ(SvPV_nolen_const(ST(0)), "Ex::Op")) 3 1 4
if (items < 1 || SvROK(ST(0)) || !strEQ(SvPV_nolen_const(ST(0)), "Ex::Op")) 2 1 3
if (items < 1 || SvROK(ST(0)) || !strEQ(SvPV_nolen_const(ST(0)), "Ex::Op")) 1 1 2
1081 3 XSRETURN_EMPTY;
1082 1 PL_hints |= HINT_LOCALIZE_HH;
1083 1 ▶ (void)hv_deletes(GvHVn(PL_hintgv), EO_KW_KEY, G_DISCARD);
Branch: 1 branch
BranchTrueFalseTotal
(void)hv_deletes(GvHVn(PL_hintgv), EO_KW_KEY, G_DISCARD); 1 0 1
1084 1 ▶ (void)hv_deletes(GvHVn(PL_hintgv), EO_STRICT_KEY, G_DISCARD);
Branch: 1 branch
BranchTrueFalseTotal
(void)hv_deletes(GvHVn(PL_hintgv), EO_STRICT_KEY, G_DISCARD); 1 0 1
1085 1 XSRETURN_EMPTY;
1086 }
1087  
1088 void
1089 export(pkg, callpkg, ...)
1090 SV *pkg
1091 SV *callpkg
1092 CODE:
1093 {
1094 4 eo_export(aTHX_ sv_mortalcopy(pkg), sv_mortalcopy(callpkg), &ST(2), items - 2, PL_curcop, FALSE);
1095 4 XSRETURN_EMPTY;
1096 }
1097  
1098 void
1099 export_to_level(pkg, level, ...)
1100 SV *pkg
1101 IV level
1102 CODE:
1103 {
1104 dMY_CXT;
1105 9 const COP *at = eo_caller_cop(aTHX_ level);
1106 9 ▶ SV *callpkg = eo_stash_name(aTHX_ at ? CopSTASH(at) : NULL);
Branch: 1 branch
BranchTrueFalseTotal
SV *callpkg = eo_stash_name(aTHX_ at ? CopSTASH(at) : NULL); 8 1 9
1107 9 ▶ I32 skip = items > 2 ? 3 : 2;
Branch: 1 branch
BranchTrueFalseTotal
I32 skip = items > 2 ? 3 : 2; 7 2 9
1108 9 HV *stash = gv_stashsv(pkg, 0);
1109 9 ▶ GV *meth = stash ? gv_fetchmethod_autoload(stash, "export", FALSE) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
GV *meth = stash ? gv_fetchmethod_autoload(stash, "export", FALSE) : NULL; 8 1 9
1110 9 ▶ CV *ecv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL;
Branch: 4 branches
BranchTrueFalseTotal
CV *ecv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL; 2 7 9
CV *ecv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL; 2 0 2
CV *ecv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL; 0 2 2
CV *ecv = (meth && isGV_with_GP(meth)) ? GvCV(meth) : NULL; 0 0 0
1111  
1112 10 ▶ if (ecv && ecv != MY_CXT.export_cv) {
Branch: 2 branches
BranchTrueFalseTotal
if (ecv && ecv != MY_CXT.export_cv) { 2 7 9
if (ecv && ecv != MY_CXT.export_cv) { 1 1 2
1113 1 AV *args = (AV *)sv_2mortal((SV *)newAV());
1114 SSize_t i, top;
1115 1 av_push(args, newSVsv(pkg));
1116 1 av_push(args, newSVsv(callpkg));
1117 2 ▶ for (i = skip; i < items; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = skip; i < items; i++) 1 1 2
1118 1 av_push(args, newSVsv(ST(i)));
1119 1 top = av_len(args);
1120 1 SP = MARK;
1121 1 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 1 1
1122 1 ▶ EXTEND(SP, top + 1);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(SP, top + 1); 1 0 1
EXTEND(SP, top + 1); 0 1 1
1123 4 ▶ for (i = 0; i <= top; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= top; i++) 3 1 4
1124 3 PUSHs(*av_fetch(args, i, 0));
1125 1 PUTBACK;
1126 1 call_sv((SV *)ecv, G_VOID | G_DISCARD);
1127 }
1128 else {
1129 8 eo_export(aTHX_ sv_mortalcopy(pkg), callpkg, &ST(skip), items - skip, at, FALSE);
1130 }
1131 8 XSRETURN_EMPTY;
1132 }
1133  
1134 void
1135 export_fail(self, ...)
1136 SV *self
1137 PPCODE:
1138 {
1139 I32 i;
1140 PERL_UNUSED_VAR(self);
1141 3 ▶ for (i = 1; i < items; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 1; i < items; i++) 2 1 3
1142 2 ST(i - 1) = ST(i);
1143 1 XSRETURN(items - 1);
1144 }
1145  
1146 void
1147 export_tags(...)
1148 CODE:
1149 {
1150 9 eo_push_tags(aTHX_ STR_WITH_LEN("EXPORT"), &ST(0), items);
1151 7 XSRETURN_EMPTY;
1152 }
1153  
1154 void
1155 export_ok_tags(...)
1156 CODE:
1157 {
1158 3 eo_push_tags(aTHX_ STR_WITH_LEN("EXPORT_OK"), &ST(0), items);
1159 3 XSRETURN_EMPTY;
1160 }
1161  
1162 SV *
1163 require_version(self, wanted)
1164 SV *self
1165 SV *wanted
1166 CODE:
1167 {
1168 2 ▶ SV *pkg = SvROK(self) && SvOBJECT(SvRV(self))
Branch: 1 branch
BranchTrueFalseTotal
SV *pkg = SvROK(self) && SvOBJECT(SvRV(self)) 2 0 2
1169 2 ▶ ? newSVpv(HvNAME_get(SvSTASH(SvRV(self))), 0) /* # uncoverable condition left count:1 */
Branch: 6 branches
BranchTrueFalseTotal
? newSVpv(HvNAME_get(SvSTASH(SvRV(self))), 0) /* # uncoverable condition left count:1 */ 2 0 2
? newSVpv(HvNAME_get(SvSTASH(SvRV(self))), 0) /* # uncoverable condition left count:1 */ 2 0 2
? newSVpv(HvNAME_get(SvSTASH(SvRV(self))), 0) /* # uncoverable condition left count:1 */ 0 2 2
? newSVpv(HvNAME_get(SvSTASH(SvRV(self))), 0) /* # uncoverable condition left count:1 */ 0 0 0
? newSVpv(HvNAME_get(SvSTASH(SvRV(self))), 0) /* # uncoverable condition left count:1 */ 2 0 2
? newSVpv(HvNAME_get(SvSTASH(SvRV(self))), 0) /* # uncoverable condition left count:1 */ 0 2 2
1170 10 ▶ : newSVsv(self);
Branch: 1 branch
BranchTrueFalseTotal
: newSVsv(self); 2 8 10
1171 I32 count;
1172 10 sv_2mortal(pkg);
1173 10 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 10 10
1174 10 ▶ XPUSHs(pkg);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(pkg); 0 10 10
1175 10 ▶ XPUSHs(wanted);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(wanted); 0 10 10
1176 10 PUTBACK;
1177 10 count = call_method("VERSION", G_SCALAR);
1178 7 SPAGAIN;
1179 7 ▶ RETVAL = count ? newSVsv(POPs) : newSV(0); /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = count ? newSVsv(POPs) : newSV(0); /* # uncoverable condition right count:1 */ 7 0 7
1180 7 PUTBACK;
1181 }
1182 OUTPUT:
1183 RETVAL
1184  
1185 void
1186 reset_cache(...)
1187 CODE:
1188 {
1189 dMY_CXT;
1190 I32 i;
1191 2 ▶ if (items == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items == 0) 1 1 2
1192 1 hv_clear(MY_CXT.exports);
1193 3 ▶ for (i = 0; i < items; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < items; i++) 1 2 3
1194 1 (void)hv_delete_ent(MY_CXT.exports, ST(i), G_DISCARD, 0);
1195 2 XSRETURN_EMPTY;
1196 }
1197  
1198 void
1199 make(name, code)
1200 SV *name
1201 SV *code
1202 PPCODE:
1203 {
1204 331 CV *cv = eo_code_arg(aTHX_ code, "Ex::Op::make");
1205 STRLEN len;
1206 329 const char *s = SvPV_const(name, len);
1207 SV *full;
1208 GV *gv;
1209 eo_op_t *e;
1210  
1211 329 ▶ if (!len)
Branch: 1 branch
BranchTrueFalseTotal
if (!len) 1 328 329
1212 1 Perl_croak(aTHX_ "Ex::Op::make needs a name");
1213 328 ▶ if (instr(s, "::"))
Branch: 1 branch
BranchTrueFalseTotal
if (instr(s, "::")) 176 152 328
1214 176 full = sv_mortalcopy(name);
1215 else
1216 152 full = eo_qualify(aTHX_ eo_stash_name(aTHX_ CopSTASH(PL_curcop)), s, len,
1217 152 SvUTF8(name) ? TRUE : FALSE);
1218  
1219 328 gv = gv_fetchsv(full, GV_ADDMULTI, SVt_PVCV);
1220 328 sv_setsv_mg((SV *)gv, code);
1221  
1222 328 e = eo_register(aTHX_ cv);
1223 328 ▶ if (!e->accepted && eo_strict_on(aTHX))
Branch: 2 branches
BranchTrueFalseTotal
if (!e->accepted && eo_strict_on(aTHX)) 35 293 328
if (!e->accepted && eo_strict_on(aTHX)) 1 34 35
1224 1 Perl_croak(aTHX_ "%" SVf " cannot be an op: %s", SVfARG(full), e->why);
1225  
1226 327 ▶ ST(0) = e->accepted ? &PL_sv_yes : &PL_sv_no;
Branch: 1 branch
BranchTrueFalseTotal
ST(0) = e->accepted ? &PL_sv_yes : &PL_sv_no; 293 34 327
1227 327 XSRETURN(1);
1228 }
1229  
1230 void
1231 is_op(code)
1232 SV *code
1233 PPCODE:
1234 {
1235 55 CV *cv = eo_code_arg(aTHX_ code, "Ex::Op::is_op");
1236 54 ▶ ST(0) = eo_op_live(aTHX_ cv) ? &PL_sv_yes : &PL_sv_no;
Branch: 1 branch
BranchTrueFalseTotal
ST(0) = eo_op_live(aTHX_ cv) ? &PL_sv_yes : &PL_sv_no; 34 20 54
1237 54 XSRETURN(1);
1238 }
1239  
1240 void
1241 why_not(code)
1242 SV *code
1243 PPCODE:
1244 {
1245 56 CV *cv = eo_code_arg(aTHX_ code, "Ex::Op::why_not");
1246 56 eo_op_t *e = eo_op_find(aTHX_ cv);
1247 56 ▶ if (eo_op_live(aTHX_ cv))
Branch: 1 branch
BranchTrueFalseTotal
if (eo_op_live(aTHX_ cv)) 24 32 56
1248 24 ST(0) = &PL_sv_undef;
1249 32 ▶ else if (!e)
Branch: 1 branch
BranchTrueFalseTotal
else if (!e) 1 31 32
1250 1 ST(0) = sv_2mortal(newSVpvs("it was never made an op"));
1251 31 ▶ else if (e->why)
Branch: 1 branch
BranchTrueFalseTotal
else if (e->why) 31 0 31
1252 31 ST(0) = sv_2mortal(newSVpv(e->why, 0));
1253 else
1254 0 ST(0) = sv_2mortal(newSVpvs("it has been redefined or undefined since it was made an op"));
1255 56 XSRETURN(1);
1256 }
1257  
1258 #ifdef EO_TEST_HOOKS
1259  
1260 void
1261 _test_add_checker()
1262 CODE:
1263 eo_wrap_check(OP_ENTERSUB, eo_test_ck, &eo_test_next_ck);
1264  
1265 IV
1266 _test_checker_seen()
1267 CODE:
1268 RETVAL = eo_test_seen;
1269 OUTPUT:
1270 RETVAL
1271  
1272 IV
1273 _test_check_wrap()
1274 CODE:
1275 RETVAL = EO_CHECK_WRAP;
1276 OUTPUT:
1277 RETVAL
1278  
1279 #endif
1280  
1281 void
1282 CLONE(...)
1283 CODE:
1284 {
1285 MY_CXT_CLONE;
1286 0 eo_cxt_init(aTHX_ &MY_CXT);
1287 PERL_UNUSED_VAR(items);
1288 }
1289  
1290 BOOT:
1291 {
1292 MY_CXT_INIT;
1293 50 eo_cxt_init(aTHX_ &MY_CXT);
1294 50 eo_boot_ops(aTHX);
1295 50 eo_boot_keyword(aTHX);
1296 }
« include/ex_op_reg.h ↑ Summary include/ex_op_call.h »