line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "ppport.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include "const-c.inc" |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#define sv_defined(sv) (sv && (SvIOK(sv) || SvNOK(sv) || SvPOK(sv) || SvROK(sv))) |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#ifndef SvRXOK |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#define SvRXOK(sv) is_regexp(aTHX_ sv) |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
STATIC int |
16
|
|
|
|
|
|
|
is_regexp (pTHX_ SV* sv) { |
17
|
|
|
|
|
|
|
SV* tmpsv; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if (SvMAGICAL(sv)) |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
mg_get(sv); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
if (SvROK(sv) |
25
|
|
|
|
|
|
|
&& (tmpsv = (SV*) SvRV(sv)) |
26
|
|
|
|
|
|
|
&& SvTYPE(tmpsv) == SVt_PVMG |
27
|
|
|
|
|
|
|
&& (mg_find(tmpsv, PERL_MAGIC_qr))) |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
return TRUE; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return FALSE; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#endif |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
bool |
38
|
100143
|
|
|
|
|
|
_match (SV *const a, SV *const b) |
39
|
|
|
|
|
|
|
{ |
40
|
100143
|
50
|
|
|
|
|
if (!sv_defined(b)) |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
41
|
|
|
|
|
|
|
{ |
42
|
9
|
50
|
|
|
|
|
return !sv_defined(a); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
100134
|
100
|
|
|
|
|
if (!SvROK(b)) |
46
|
|
|
|
|
|
|
{ |
47
|
11
|
|
|
|
|
|
return sv_eq(a, b); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
100123
|
100
|
|
|
|
|
if (SvRXOK(b)) |
51
|
|
|
|
|
|
|
{ |
52
|
10
|
|
|
|
|
|
dSP; |
53
|
|
|
|
|
|
|
int count; |
54
|
|
|
|
|
|
|
bool r; |
55
|
10
|
|
|
|
|
|
ENTER; |
56
|
10
|
|
|
|
|
|
SAVETMPS; |
57
|
10
|
50
|
|
|
|
|
PUSHMARK(SP); |
58
|
10
|
50
|
|
|
|
|
XPUSHs(a); |
59
|
10
|
50
|
|
|
|
|
XPUSHs(b); |
60
|
10
|
|
|
|
|
|
PUTBACK; |
61
|
10
|
|
|
|
|
|
count = call_pv("match::simple::XS::_regexp", G_SCALAR); |
62
|
10
|
|
|
|
|
|
SPAGAIN; |
63
|
10
|
50
|
|
|
|
|
r = POPi; |
64
|
10
|
|
|
|
|
|
PUTBACK; |
65
|
10
|
50
|
|
|
|
|
FREETMPS; |
66
|
10
|
|
|
|
|
|
LEAVE; |
67
|
10
|
|
|
|
|
|
return (r != 0); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
100113
|
100
|
|
|
|
|
if (sv_isobject(b)) |
71
|
|
|
|
|
|
|
{ |
72
|
4
|
50
|
|
|
|
|
if (sv_derived_from(b, "Type::Tiny")) |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
|
|
|
dSP; |
75
|
|
|
|
|
|
|
int count; |
76
|
|
|
|
|
|
|
SV *ret; |
77
|
|
|
|
|
|
|
bool ret_truth; |
78
|
0
|
|
|
|
|
|
ENTER; |
79
|
0
|
|
|
|
|
|
SAVETMPS; |
80
|
0
|
0
|
|
|
|
|
PUSHMARK(SP); |
81
|
0
|
0
|
|
|
|
|
XPUSHs(b); |
82
|
0
|
0
|
|
|
|
|
XPUSHs(a); |
83
|
0
|
|
|
|
|
|
PUTBACK; |
84
|
0
|
|
|
|
|
|
count = call_method("check", G_SCALAR); |
85
|
0
|
|
|
|
|
|
SPAGAIN; |
86
|
0
|
|
|
|
|
|
ret = POPs; |
87
|
0
|
0
|
|
|
|
|
ret_truth = SvTRUE(ret); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
PUTBACK; |
89
|
0
|
0
|
|
|
|
|
FREETMPS; |
90
|
0
|
|
|
|
|
|
LEAVE; |
91
|
0
|
|
|
|
|
|
return ret_truth; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
4
|
|
|
|
|
|
dSP; |
95
|
|
|
|
|
|
|
int count; |
96
|
|
|
|
|
|
|
SV *ret; |
97
|
|
|
|
|
|
|
bool can; |
98
|
4
|
|
|
|
|
|
SV *method_name = newSVpv("MATCH", 0); |
99
|
|
|
|
|
|
|
|
100
|
4
|
|
|
|
|
|
ENTER; |
101
|
4
|
|
|
|
|
|
SAVETMPS; |
102
|
4
|
50
|
|
|
|
|
PUSHMARK(SP); |
103
|
4
|
50
|
|
|
|
|
XPUSHs(b); |
104
|
4
|
50
|
|
|
|
|
XPUSHs(method_name); |
105
|
4
|
|
|
|
|
|
PUTBACK; |
106
|
4
|
|
|
|
|
|
count = call_method("can", G_SCALAR); |
107
|
4
|
|
|
|
|
|
SPAGAIN; |
108
|
4
|
|
|
|
|
|
ret = POPs; |
109
|
4
|
50
|
|
|
|
|
can = SvTRUE(ret); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
110
|
4
|
|
|
|
|
|
PUTBACK; |
111
|
4
|
50
|
|
|
|
|
FREETMPS; |
112
|
4
|
|
|
|
|
|
LEAVE; |
113
|
|
|
|
|
|
|
|
114
|
4
|
100
|
|
|
|
|
if (can) |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
bool ret_truth; |
117
|
|
|
|
|
|
|
|
118
|
2
|
|
|
|
|
|
ENTER; |
119
|
2
|
|
|
|
|
|
SAVETMPS; |
120
|
2
|
50
|
|
|
|
|
PUSHMARK(SP); |
121
|
2
|
50
|
|
|
|
|
XPUSHs(b); |
122
|
2
|
50
|
|
|
|
|
XPUSHs(a); |
123
|
2
|
|
|
|
|
|
PUTBACK; |
124
|
2
|
|
|
|
|
|
count = call_method("MATCH", G_SCALAR); |
125
|
2
|
|
|
|
|
|
SPAGAIN; |
126
|
2
|
|
|
|
|
|
ret = POPs; |
127
|
2
|
50
|
|
|
|
|
ret_truth = SvTRUE(ret); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
128
|
2
|
|
|
|
|
|
PUTBACK; |
129
|
2
|
50
|
|
|
|
|
FREETMPS; |
130
|
2
|
|
|
|
|
|
LEAVE; |
131
|
2
|
|
|
|
|
|
return ret_truth; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
if ( 1 ) { |
135
|
2
|
|
|
|
|
|
dSP; |
136
|
|
|
|
|
|
|
int countx; |
137
|
|
|
|
|
|
|
SV* rx; |
138
|
|
|
|
|
|
|
bool overload_r; |
139
|
2
|
|
|
|
|
|
ENTER; |
140
|
2
|
|
|
|
|
|
SAVETMPS; |
141
|
2
|
50
|
|
|
|
|
PUSHMARK(SP); |
142
|
2
|
50
|
|
|
|
|
XPUSHs(b); |
143
|
2
|
|
|
|
|
|
PUTBACK; |
144
|
2
|
|
|
|
|
|
countx = call_pv("match::simple::XS::_overloaded_smartmatch", G_SCALAR); |
145
|
2
|
|
|
|
|
|
SPAGAIN; |
146
|
2
|
|
|
|
|
|
rx = POPs; |
147
|
2
|
|
|
|
|
|
PUTBACK; |
148
|
|
|
|
|
|
|
|
149
|
2
|
50
|
|
|
|
|
if (SvTYPE(rx) == SVt_IV) { |
150
|
2
|
|
|
|
|
|
SV* coderef = rx; |
151
|
2
|
|
|
|
|
|
SV* one = newSViv(1); |
152
|
2
|
|
|
|
|
|
dSP; |
153
|
|
|
|
|
|
|
int count; |
154
|
2
|
50
|
|
|
|
|
PUSHMARK(SP); |
155
|
2
|
50
|
|
|
|
|
XPUSHs(b); |
156
|
2
|
50
|
|
|
|
|
XPUSHs(a); |
157
|
2
|
50
|
|
|
|
|
XPUSHs(one); |
158
|
2
|
|
|
|
|
|
PUTBACK; |
159
|
2
|
|
|
|
|
|
count = call_sv(coderef, G_SCALAR); |
160
|
2
|
|
|
|
|
|
SPAGAIN; |
161
|
2
|
50
|
|
|
|
|
overload_r = POPi; |
162
|
2
|
|
|
|
|
|
PUTBACK; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
2
|
50
|
|
|
|
|
FREETMPS; |
166
|
2
|
|
|
|
|
|
LEAVE; |
167
|
2
|
|
|
|
|
|
return (overload_r != 0); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
return FALSE; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
100109
|
|
|
|
|
|
SV *sv_b = SvRV(b); |
174
|
|
|
|
|
|
|
|
175
|
100109
|
100
|
|
|
|
|
if (SvTYPE(sv_b) == SVt_PVCV) |
176
|
|
|
|
|
|
|
{ |
177
|
100106
|
|
|
|
|
|
dSP; |
178
|
|
|
|
|
|
|
int count; |
179
|
|
|
|
|
|
|
SV *ret; |
180
|
|
|
|
|
|
|
bool ret_truth; |
181
|
|
|
|
|
|
|
|
182
|
100106
|
|
|
|
|
|
SAVESPTR(GvSV(PL_defgv)); |
183
|
|
|
|
|
|
|
|
184
|
100106
|
|
|
|
|
|
ENTER; |
185
|
100106
|
|
|
|
|
|
SAVETMPS; |
186
|
100106
|
50
|
|
|
|
|
PUSHMARK(SP); |
187
|
100106
|
50
|
|
|
|
|
XPUSHs(a); |
188
|
100106
|
|
|
|
|
|
PUTBACK; |
189
|
100106
|
|
|
|
|
|
GvSV(PL_defgv) = a; |
190
|
100106
|
|
|
|
|
|
count = call_sv(b, G_SCALAR); |
191
|
100106
|
|
|
|
|
|
SPAGAIN; |
192
|
100106
|
|
|
|
|
|
ret = POPs; |
193
|
100106
|
50
|
|
|
|
|
ret_truth = SvTRUE(ret); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
194
|
100106
|
|
|
|
|
|
PUTBACK; |
195
|
100106
|
50
|
|
|
|
|
FREETMPS; |
196
|
100106
|
|
|
|
|
|
LEAVE; |
197
|
100106
|
|
|
|
|
|
return ret_truth; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
3
|
100
|
|
|
|
|
if (SvTYPE(sv_b) == SVt_PVAV) |
201
|
|
|
|
|
|
|
{ |
202
|
|
|
|
|
|
|
AV *b_arr; |
203
|
|
|
|
|
|
|
int top_index; |
204
|
|
|
|
|
|
|
int i; |
205
|
|
|
|
|
|
|
|
206
|
1
|
|
|
|
|
|
b_arr = (AV*) SvRV(b); |
207
|
1
|
|
|
|
|
|
top_index = av_len(b_arr); |
208
|
|
|
|
|
|
|
|
209
|
1
|
50
|
|
|
|
|
for (i = 0; i <= top_index; i++) |
210
|
|
|
|
|
|
|
{ |
211
|
1
|
|
|
|
|
|
SV *item = *av_fetch(b_arr, i, 1); |
212
|
1
|
50
|
|
|
|
|
if (_match(a, item)) |
213
|
1
|
|
|
|
|
|
return TRUE; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
return FALSE; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
2
|
|
|
|
|
|
croak("match::simple::XS cannot match"); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
MODULE = match::simple::XS PACKAGE = match::simple::XS |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
INCLUDE: const-xs.inc |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
bool |
227
|
|
|
|
|
|
|
match (a, b) |
228
|
|
|
|
|
|
|
SV *a |
229
|
|
|
|
|
|
|
SV *b |
230
|
|
|
|
|
|
|
CODE: |
231
|
100142
|
|
|
|
|
|
RETVAL = _match(a, b); |
232
|
|
|
|
|
|
|
OUTPUT: |
233
|
|
|
|
|
|
|
RETVAL |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
bool |
236
|
|
|
|
|
|
|
is_regexp (r) |
237
|
|
|
|
|
|
|
SV *r |
238
|
|
|
|
|
|
|
CODE: |
239
|
0
|
|
|
|
|
|
RETVAL = SvRXOK(r); |
240
|
|
|
|
|
|
|
OUTPUT: |
241
|
|
|
|
|
|
|
RETVAL |