perl_syck.h

filter: Statementstmt 92.5% 804 / 869 Branchbran 68.1% 575 / 844 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 80.5% 1379 / 1713 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« syck_.c ↑ Summary perl_common.h »
1 /* Implementation-specific variables */
2 #undef PACKAGE_NAME
3 #undef NULL_LITERAL
4 #undef NULL_LITERAL_LENGTH
5 #undef SCALAR_NUMBER
6 #undef SCALAR_STRING
7 #undef SCALAR_QUOTED
8 #undef SCALAR_UTF8
9 #undef SEQ_NONE
10 #undef MAP_NONE
11 #undef IS_UTF8
12 #undef TYPE_IS_NULL
13 #undef OBJOF
14 #undef PERL_SYCK_PARSER_HANDLER
15 #undef PERL_SYCK_EMITTER_HANDLER
16 #undef PERL_SYCK_INDENT_LEVEL
17 #undef PERL_SYCK_MARK_EMITTER
18 #undef PERL_SYCK_EMITTER_MARK_NODE_FLAGS
19  
20 #ifdef YAML_IS_JSON
21 # define PACKAGE_NAME "JSON::Syck"
22 # define NULL_LITERAL "null"
23 # define NULL_LITERAL_LENGTH 4
24 # define SCALAR_NUMBER scalar_none
25 # define PERL_SYCK_EMITTER_MARK_NODE_FLAGS EMITTER_MARK_NODE_FLAG_PERMIT_DUPLICATE_NODES
26 int json_max_depth = 512;
27 char json_quote_char = '"';
28 static enum scalar_style json_quote_style = scalar_2quote;
29 # define SCALAR_STRING json_quote_style
30 # define SCALAR_QUOTED json_quote_style
31 # define SCALAR_UTF8 scalar_fold
32 # define SEQ_NONE seq_inline
33 # define MAP_NONE map_inline
34 # define IS_UTF8(x) TRUE
35 # define TYPE_IS_NULL(x) ((x == NULL) || strEQ( x, "str" ))
36 # define OBJOF(a) (a)
37 # define PERL_SYCK_PARSER_HANDLER json_syck_parser_handler
38 # define PERL_SYCK_EMITTER_HANDLER json_syck_emitter_handler
39 # define PERL_SYCK_MARK_EMITTER json_syck_mark_emitter
40 # define PERL_SYCK_INDENT_LEVEL 0
41 #else
42 # define PACKAGE_NAME "YAML::Syck"
43 # define REGEXP_LITERAL "REGEXP"
44 # define REGEXP_LITERAL_LENGTH 6
45 # define REF_LITERAL "="
46 # define REF_LITERAL_LENGTH 1
47 # define NULL_LITERAL "~"
48 # define NULL_LITERAL_LENGTH 1
49 # define SCALAR_NUMBER scalar_none
50 # define PERL_SYCK_EMITTER_MARK_NODE_FLAGS 0
51 static enum scalar_style yaml_quote_style = scalar_none;
52 # define SCALAR_STRING yaml_quote_style
53 # define SCALAR_QUOTED scalar_1quote
54 # define SCALAR_UTF8 scalar_fold
55 # define SEQ_NONE seq_none
56 # define MAP_NONE map_none
57 #ifdef SvUTF8
58 # define IS_UTF8(x) (SvUTF8(x))
59 #else
60 # define IS_UTF8(x) (FALSE)
61 #endif
62 # define TYPE_IS_NULL(x) ((x == NULL) || strEQ( x, "str" ))
63 # define OBJOF(a) (*tag ? tag : a)
64 # define PERL_SYCK_PARSER_HANDLER yaml_syck_parser_handler
65 # define PERL_SYCK_EMITTER_HANDLER yaml_syck_emitter_handler
66 # define PERL_SYCK_MARK_EMITTER yaml_syck_mark_emitter
67 # define PERL_SYCK_INDENT_LEVEL 2
68 #endif
69  
70 #define TRACK_OBJECT(sv) (av_push(((struct parser_xtra *)p->bonus)->objects, sv))
71 #define USE_OBJECT(sv) (SvREFCNT_inc(sv))
72 #define IS_SIGN(c) ((c) == '-' || (c) == '+')
73  
74 #ifndef YAML_IS_JSON
75  
76 #ifndef SvRV_set /* prior to 5.8.7; thx charsbar! */
77 #define SvRV_set(sv, val) \
78 STMT_START { \
79 (SvRV(sv) = (val)); } STMT_END
80 #endif
81  
82 static const char *
83 9361672 is_bad_alias_object( SV *sv ) {
84 SV *hv, **psv;
85  
86 9361672 ▶ if (! sv_isobject(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (! sv_isobject(sv)) 9361655 17 9361672
87 9361655 return NULL;
88  
89 17 hv = SvRV(sv);
90 17 ▶ if (! strnEQ(sv_reftype(hv, 1), "YAML::Syck::BadAlias", 20-1))
Branch: 1 branch
BranchTrueFalseTotal
if (! strnEQ(sv_reftype(hv, 1), "YAML::Syck::BadAlias", 20-1)) 7 10 17
91 7 return NULL;
92  
93 10 psv = hv_fetch((HV *) hv, "name", 4, 0);
94 10 ▶ if (! psv)
Branch: 1 branch
BranchTrueFalseTotal
if (! psv) 0 10 10
95 0 return NULL;
96  
97 10 return SvPVX(*psv);
98 }
99  
100 static void
101 10 register_bad_alias( SyckParser *p, const char *anchor, SV *sv ) {
102 HV *map;
103 SV **pref_av, *new_rvav;
104 AV *rvs;
105  
106 10 map = ((struct parser_xtra *)p->bonus)->bad_anchors;
107 10 pref_av = hv_fetch(map, anchor, strlen(anchor), 0);
108 10 ▶ if (! pref_av) {
Branch: 1 branch
BranchTrueFalseTotal
if (! pref_av) { 5 5 10
109 5 new_rvav = newRV_noinc((SV *) newAV());
110 5 hv_store(map, anchor, strlen(anchor), new_rvav, 0);
111 5 pref_av = &new_rvav;
112 }
113 10 rvs = (AV *) SvRV(*pref_av);
114  
115 10 SvREFCNT_inc(sv);
116 10 av_push(rvs, sv);
117 10 }
118  
119 static void
120 7 resolve_bad_alias( SyckParser *p, const char *anchor, SV *sv ) {
121 HV *map;
122 SV **pref_av, *entity;
123 AV *rvs;
124 I32 len, i;
125  
126 7 entity = SvRV(sv);
127  
128 7 map = ((struct parser_xtra *)p->bonus)->bad_anchors;
129 7 pref_av = hv_fetch(map, anchor, strlen(anchor), 0);
130 7 ▶ if (! pref_av)
Branch: 1 branch
BranchTrueFalseTotal
if (! pref_av) 2 5 7
131 2 return;
132  
133 5 rvs = (AV *) SvRV(*pref_av);
134 5 len = av_len(rvs)+1;
135 15 ▶ for (i = 0; i < len; i ++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < len; i ++) { 10 5 15
136 10 SV **prv = av_fetch(rvs, i, 0);
137 10 ▶ if (prv) {
Branch: 1 branch
BranchTrueFalseTotal
if (prv) { 10 0 10
138 10 SvREFCNT_dec(SvRV(*prv));
139 10 SvRV_set(*prv, entity);
140 10 SvREFCNT_inc(entity);
141 }
142 }
143 5 av_clear(rvs);
144 }
145  
146 #endif
147  
148 SYMID
149 #ifdef YAML_IS_JSON
150 1691 json_syck_parser_handler
151 #else
152 18725241 yaml_syck_parser_handler
153 #endif
154 (SyckParser *p, SyckNode *n) {
155 18726932 SV *sv = NULL;
156 AV *seq;
157 HV *map;
158 long i;
159 18726932 char *id = n->type_id;
160 #ifndef YAML_IS_JSON
161 18725241 struct parser_xtra *bonus = (struct parser_xtra *)p->bonus;
162 18725241 bool load_code = bonus->load_code;
163 18725241 bool load_blessed = bonus->load_blessed;
164 #endif
165  
166 18726997 ▶ while (id && (*id == '!')) { id++; }
Branch: 4 branches
BranchTrueFalseTotal
while (id && (*id == '!')) { id++; } 18721450 3856 18725306
while (id && (*id == '!')) { id++; } 65 18721385 18721450
while (id && (*id == '!')) { id++; } 960 731 1691
while (id && (*id == '!')) { id++; } 0 960 960
167  
168 18726932 switch (n->kind) {
169 18724208 case syck_str_kind:
170 18724208 ▶ if (TYPE_IS_NULL(id)) {
Branch: 4 branches
BranchTrueFalseTotal
if (TYPE_IS_NULL(id)) { 18721337 1911 18723248
if (TYPE_IS_NULL(id)) { 18720507 830 18721337
if (TYPE_IS_NULL(id)) { 960 0 960
if (TYPE_IS_NULL(id)) { 865 95 960
171 37446566 ▶ if (strnEQ( n->data.str->ptr, NULL_LITERAL, 1+NULL_LITERAL_LENGTH)
Branch: 2 branches
BranchTrueFalseTotal
if (strnEQ( n->data.str->ptr, NULL_LITERAL, 1+NULL_LITERAL_LENGTH) 9 18722409 18722418
if (strnEQ( n->data.str->ptr, NULL_LITERAL, 1+NULL_LITERAL_LENGTH) 0 865 865
172 9 ▶ && (n->data.str->style == scalar_plain)) {
Branch: 2 branches
BranchTrueFalseTotal
&& (n->data.str->style == scalar_plain)) { 8 1 9
&& (n->data.str->style == scalar_plain)) { 0 0 0
173 8 sv = newSV(0);
174 }
175 else {
176 18723275 sv = newSVpvn(n->data.str->ptr, n->data.str->len);
177 18723275 ▶ CHECK_UTF8;
Branch: 6 branches
BranchTrueFalseTotal
CHECK_UTF8; 274 18722136 18722410
CHECK_UTF8; 274 0 274
CHECK_UTF8; 270 4 274
CHECK_UTF8; 50 815 865
CHECK_UTF8; 44 6 50
CHECK_UTF8; 44 0 44
178 }
179 925 ▶ } else if (strEQ( id, "null" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "null" )) { 7 823 830
} else if (strEQ( id, "null" )) { 20 75 95
180 27 sv = newSV(0);
181 898 ▶ } else if (strEQ( id, "bool#yes" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "bool#yes" )) { 13 810 823
} else if (strEQ( id, "bool#yes" )) { 0 75 75
182 13 sv = newSVsv(&PL_sv_yes);
183 885 ▶ } else if (strEQ( id, "bool#no" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "bool#no" )) { 23 787 810
} else if (strEQ( id, "bool#no" )) { 0 75 75
184 23 sv = newSVsv(&PL_sv_no);
185 862 ▶ } else if (strEQ( id, "default" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "default" )) { 2 785 787
} else if (strEQ( id, "default" )) { 0 75 75
186 2 sv = newSVpvn(n->data.str->ptr, n->data.str->len);
187 2 ▶ CHECK_UTF8;
Branch: 6 branches
BranchTrueFalseTotal
CHECK_UTF8; 0 2 2
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
188 860 ▶ } else if (strEQ( id, "float#base60" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "float#base60" )) { 11 774 785
} else if (strEQ( id, "float#base60" )) { 0 75 75
189 char *ptr, *end;
190 11 UV sixty = 1;
191 11 NV total = 0.0;
192 int is_neg;
193 11 syck_str_blow_away_commas( n );
194 11 ptr = n->data.str->ptr;
195 11 is_neg = (*ptr == '-');
196 11 ▶ if (*ptr == '-' || *ptr == '+') ptr++;
Branch: 4 branches
BranchTrueFalseTotal
if (*ptr == '-' || *ptr == '+') ptr++; 7 4 11
if (*ptr == '-' || *ptr == '+') ptr++; 1 6 7
if (*ptr == '-' || *ptr == '+') ptr++; 0 0 0
if (*ptr == '-' || *ptr == '+') ptr++; 0 0 0
197 11 end = n->data.str->ptr + n->data.str->len;
198 39 ▶ while ( end > ptr )
Branch: 2 branches
BranchTrueFalseTotal
while ( end > ptr ) 28 11 39
while ( end > ptr ) 0 0 0
199 {
200 28 NV bnum = 0;
201 28 char *colon = end - 1;
202 80 ▶ while ( colon > ptr && *colon != ':' )
Branch: 4 branches
BranchTrueFalseTotal
while ( colon > ptr && *colon != ':' ) 69 11 80
while ( colon > ptr && *colon != ':' ) 52 17 69
while ( colon > ptr && *colon != ':' ) 0 0 0
while ( colon > ptr && *colon != ':' ) 0 0 0
203 {
204 52 colon--;
205 }
206 28 ▶ if ( *colon == ':' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ( *colon == ':' ) { 17 11 28
if ( *colon == ':' ) { 0 0 0
207 17 *colon = '\0';
208 17 bnum = Atof( colon + 1 );
209 17 end = colon;
210 } else {
211 11 bnum = Atof( ptr );
212 11 end = ptr;
213 }
214 28 total += bnum * sixty;
215 28 sixty *= 60;
216 }
217 11 ▶ sv = newSVnv((is_neg && total != 0.0) ? -total : total);
Branch: 4 branches
BranchTrueFalseTotal
sv = newSVnv((is_neg && total != 0.0) ? -total : total); 4 7 11
sv = newSVnv((is_neg && total != 0.0) ? -total : total); 3 1 4
sv = newSVnv((is_neg && total != 0.0) ? -total : total); 0 0 0
sv = newSVnv((is_neg && total != 0.0) ? -total : total); 0 0 0
218 #ifdef NV_NAN
219 849 ▶ } else if (strEQ( id, "float#nan" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "float#nan" )) { 6 768 774
} else if (strEQ( id, "float#nan" )) { 0 75 75
220 6 sv = newSVnv(NV_NAN);
221 #endif
222 #ifdef NV_INF
223 843 ▶ } else if (strEQ( id, "float#inf" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "float#inf" )) { 7 761 768
} else if (strEQ( id, "float#inf" )) { 0 75 75
224 7 sv = newSVnv(NV_INF);
225 836 ▶ } else if (strEQ( id, "float#neginf" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "float#neginf" )) { 6 755 761
} else if (strEQ( id, "float#neginf" )) { 0 75 75
226 6 sv = newSVnv(-NV_INF);
227 #endif
228 830 ▶ } else if (strnEQ( id, "float", 5 )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strnEQ( id, "float", 5 )) { 7 748 755
} else if (strnEQ( id, "float", 5 )) { 0 75 75
229 NV f;
230 7 syck_str_blow_away_commas( n );
231 7 f = Atof( n->data.str->ptr );
232 7 sv = newSVnv( f );
233 823 ▶ } else if (strEQ( id, "int#base60" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "int#base60" )) { 18 730 748
} else if (strEQ( id, "int#base60" )) { 0 75 75
234 char *ptr, *end;
235 18 UV sixty = 1;
236 18 UV total = 0;
237 int is_neg;
238 18 syck_str_blow_away_commas( n );
239 18 ptr = n->data.str->ptr;
240 18 is_neg = (*ptr == '-');
241 18 ▶ if (is_neg) ptr++;
Branch: 2 branches
BranchTrueFalseTotal
if (is_neg) ptr++; 5 13 18
if (is_neg) ptr++; 0 0 0
242 18 end = n->data.str->ptr + n->data.str->len;
243 65 ▶ while ( end > ptr )
Branch: 2 branches
BranchTrueFalseTotal
while ( end > ptr ) 47 18 65
while ( end > ptr ) 0 0 0
244 {
245 47 long bnum = 0;
246 47 char *colon = end - 1;
247 89 ▶ while ( colon > ptr && *colon != ':' )
Branch: 4 branches
BranchTrueFalseTotal
while ( colon > ptr && *colon != ':' ) 71 18 89
while ( colon > ptr && *colon != ':' ) 42 29 71
while ( colon > ptr && *colon != ':' ) 0 0 0
while ( colon > ptr && *colon != ':' ) 0 0 0
248 {
249 42 colon--;
250 }
251 47 ▶ if ( *colon == ':' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ( *colon == ':' ) { 29 18 47
if ( *colon == ':' ) { 0 0 0
252 29 *colon = '\0';
253 29 bnum = strtol( colon + 1, NULL, 10 );
254 29 end = colon;
255 } else {
256 18 bnum = strtol( ptr, NULL, 10 );
257 18 end = ptr;
258 }
259 47 total += bnum * sixty;
260 47 sixty *= 60;
261 }
262 18 ▶ if (is_neg)
Branch: 2 branches
BranchTrueFalseTotal
if (is_neg) 5 13 18
if (is_neg) 0 0 0
263 5 sv = newSViv(-(IV)total);
264 else
265 13 sv = newSVuv(total);
266 805 ▶ } else if (strEQ( id, "int#hex" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "int#hex" )) { 16 714 730
} else if (strEQ( id, "int#hex" )) { 0 75 75
267 16 I32 flags = 0;
268 16 char *ptr = n->data.str->ptr;
269 16 STRLEN len = n->data.str->len;
270 16 int is_neg = (*ptr == '-');
271 16 syck_str_blow_away_commas( n );
272 16 ▶ if (IS_SIGN(*ptr)) { ptr++; len--; }
Branch: 4 branches
BranchTrueFalseTotal
if (IS_SIGN(*ptr)) { ptr++; len--; } 12 4 16
if (IS_SIGN(*ptr)) { ptr++; len--; } 4 8 12
if (IS_SIGN(*ptr)) { ptr++; len--; } 0 0 0
if (IS_SIGN(*ptr)) { ptr++; len--; } 0 0 0
273 16 UV uv = grok_hex( ptr, &len, &flags, NULL);
274 16 if (is_neg)
275 4 sv = newSViv(-(IV)uv);
276 else
277 12 sv = newSVuv(uv);
278 789 ▶ } else if (strEQ( id, "int#oct" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "int#oct" )) { 13 701 714
} else if (strEQ( id, "int#oct" )) { 0 75 75
279 13 I32 flags = 0;
280 13 char *ptr = n->data.str->ptr;
281 13 STRLEN len = n->data.str->len;
282 13 int is_neg = (*ptr == '-');
283 13 syck_str_blow_away_commas( n );
284 13 ▶ if (IS_SIGN(*ptr)) { ptr++; len--; }
Branch: 4 branches
BranchTrueFalseTotal
if (IS_SIGN(*ptr)) { ptr++; len--; } 10 3 13
if (IS_SIGN(*ptr)) { ptr++; len--; } 4 6 10
if (IS_SIGN(*ptr)) { ptr++; len--; } 0 0 0
if (IS_SIGN(*ptr)) { ptr++; len--; } 0 0 0
285 13 UV uv = grok_oct( ptr, &len, &flags, NULL);
286 13 if (is_neg)
287 3 sv = newSViv(-(IV)uv);
288 else
289 10 sv = newSVuv(uv);
290 776 ▶ } else if (strEQ( id, "int" ) ) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "int" ) ) { 39 662 701
} else if (strEQ( id, "int" ) ) { 75 0 75
291 UV uv;
292 int flags;
293  
294 114 syck_str_blow_away_commas( n );
295 114 flags = grok_number( n->data.str->ptr, n->data.str->len, &uv);
296  
297 114 if (flags == IS_NUMBER_IN_UV) {
298 108 ▶ if (uv <= IV_MAX) {
Branch: 2 branches
BranchTrueFalseTotal
if (uv <= IV_MAX) { 34 0 34
if (uv <= IV_MAX) { 74 0 74
299 108 sv = newSViv(uv);
300 }
301 else {
302 0 sv = newSVuv(uv);
303 }
304 }
305 6 ▶ else if ((flags == (IS_NUMBER_IN_UV | IS_NUMBER_NEG)) && (uv <= (UV) IV_MIN)) {
Branch: 4 branches
BranchTrueFalseTotal
else if ((flags == (IS_NUMBER_IN_UV | IS_NUMBER_NEG)) && (uv <= (UV) IV_MIN)) { 5 0 5
else if ((flags == (IS_NUMBER_IN_UV | IS_NUMBER_NEG)) && (uv <= (UV) IV_MIN)) { 5 0 5
else if ((flags == (IS_NUMBER_IN_UV | IS_NUMBER_NEG)) && (uv <= (UV) IV_MIN)) { 1 0 1
else if ((flags == (IS_NUMBER_IN_UV | IS_NUMBER_NEG)) && (uv <= (UV) IV_MIN)) { 1 0 1
306 6 sv = newSViv(-(IV)uv);
307 }
308 else {
309 0 sv = newSVnv(Atof( n->data.str->ptr ));
310 }
311 662 ▶ } else if (strEQ( id, "binary" )) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ( id, "binary" )) { 202 460 662
} else if (strEQ( id, "binary" )) { 0 0 0
312 202 long len = 0;
313 202 char *blob = syck_base64dec(n->data.str->ptr, n->data.str->len, &len);
314 202 sv = newSVpv(blob, len);
315 202 syck_base64_free(blob);
316 #ifndef YAML_IS_JSON
317 #ifdef PERL_LOADMOD_NOIMPORT
318 673 ▶ } else if (strEQ(id, "perl/code") || strnEQ(id, "perl/code:", 10)) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (strEQ(id, "perl/code") || strnEQ(id, "perl/code:", 10)) { 459 1 460
} else if (strEQ(id, "perl/code") || strnEQ(id, "perl/code:", 10)) { 223 236 459
319 SV *cv;
320 SV *sub;
321 224 char *pkg = id + 10;
322  
323 224 ▶ if (load_code) {
Branch: 1 branch
BranchTrueFalseTotal
if (load_code) { 220 4 224
324 SV *text;
325  
326 /* This code is copypasted from Storable.xs */
327  
328 /*
329 * prepend "sub " to the source
330 */
331  
332 220 text = newSVpvn(n->data.str->ptr, n->data.str->len);
333  
334 220 sub = newSVpvn("sub ", 4);
335 220 sv_catpv(sub, SvPV_nolen(text)); /* XXX no sv_catsv! */
336 220 SvREFCNT_dec(text);
337 } else {
338 4 sub = newSVpvn("sub {}", 6);
339 }
340  
341 224 ENTER;
342 224 SAVETMPS;
343  
344 224 sv_2mortal(sub);
345  
346 224 cv = eval_pv(SvPV_nolen(sub), FALSE);
347  
348 224 ▶ if (SvTRUE(ERRSV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) { 224 0 224
if (SvTRUE(ERRSV)) { 11 213 224
349 11 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 11 0 11
350 11 LEAVE;
351 22 ▶ croak("code %s did not evaluate to a subroutine reference\n", SvPV_nolen(ERRSV));
Branch: 1 branch
BranchTrueFalseTotal
croak("code %s did not evaluate to a subroutine reference\n", SvPV_nolen(ERRSV)); 11 0 11
352 }
353  
354 213 ▶ if (cv && SvROK(cv) && SvTYPE(SvRV(cv)) == SVt_PVCV) {
Branch: 3 branches
BranchTrueFalseTotal
if (cv && SvROK(cv) && SvTYPE(SvRV(cv)) == SVt_PVCV) { 213 0 213
if (cv && SvROK(cv) && SvTYPE(SvRV(cv)) == SVt_PVCV) { 213 0 213
if (cv && SvROK(cv) && SvTYPE(SvRV(cv)) == SVt_PVCV) { 213 0 213
355 213 sv = cv;
356 }
357 else {
358 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
359 0 LEAVE;
360 0 croak("code %s did not evaluate to a subroutine reference\n", SvPV_nolen(sub));
361 }
362  
363 213 SvREFCNT_inc(sv); /* prevent FREETMPS from freeing the mortal cv */
364  
365 213 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 213 0 213
366 213 LEAVE;
367  
368 213 ▶ if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) { 8 205 213
if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) { 7 1 8
if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) { 4 3 7
369 4 sv_bless(sv, gv_stashpv(pkg, TRUE));
370 }
371  
372 /* END Storable */
373  
374 236 ▶ } else if (strnEQ( n->data.str->ptr, REF_LITERAL, 1+REF_LITERAL_LENGTH)) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strnEQ( n->data.str->ptr, REF_LITERAL, 1+REF_LITERAL_LENGTH)) { 4 232 236
375 /* type tag in a scalar ref */
376 4 char *id_copy = savepv(id);
377 4 char *lang = id_copy;
378 4 char *type = strpbrk(id_copy, "/:");
379 4 ▶ if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; }
Branch: 2 branches
BranchTrueFalseTotal
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 2 2 4
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 0 2 2
380  
381 4 ▶ if (lang == NULL || (strEQ(lang, "perl"))) {
Branch: 2 branches
BranchTrueFalseTotal
if (lang == NULL || (strEQ(lang, "perl"))) { 4 0 4
if (lang == NULL || (strEQ(lang, "perl"))) { 2 2 4
382 2 ▶ if (type != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (type != NULL) { 1 1 2
383 1 sv = newSVpv(type, 0);
384 } else {
385 /* Tag has no type component (e.g. "!perl =") —
386 * fall back to raw scalar content */
387 1 sv = newSVpvn(n->data.str->ptr, n->data.str->len);
388 1 ▶ CHECK_UTF8;
Branch: 3 branches
BranchTrueFalseTotal
CHECK_UTF8; 0 1 1
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
389 }
390 }
391 else {
392 2 ▶ sv = newSVpv((type == NULL) ? lang : form("%s::%s", lang, type), 0);
Branch: 1 branch
BranchTrueFalseTotal
sv = newSVpv((type == NULL) ? lang : form("%s::%s", lang, type), 0); 1 1 2
393 }
394 4 Safefree(id_copy);
395 441 ▶ } else if ( strEQ( id, "perl/scalar" ) || strnEQ( id, "perl/scalar:", 12 ) ) {
Branch: 2 branches
BranchTrueFalseTotal
} else if ( strEQ( id, "perl/scalar" ) || strnEQ( id, "perl/scalar:", 12 ) ) { 30 202 232
} else if ( strEQ( id, "perl/scalar" ) || strnEQ( id, "perl/scalar:", 12 ) ) { 7 23 30
396 209 char *pkg = id + 12;
397  
398 209 ▶ if (strnEQ( n->data.str->ptr, NULL_LITERAL, 1+NULL_LITERAL_LENGTH)
Branch: 1 branch
BranchTrueFalseTotal
if (strnEQ( n->data.str->ptr, NULL_LITERAL, 1+NULL_LITERAL_LENGTH) 2 207 209
399 2 ▶ && (n->data.str->style == scalar_plain)) {
Branch: 1 branch
BranchTrueFalseTotal
&& (n->data.str->style == scalar_plain)) { 2 0 2
400 2 sv = newSV(0);
401 }
402 else {
403 207 sv = newSVpvn(n->data.str->ptr, n->data.str->len);
404 207 ▶ CHECK_UTF8;
Branch: 3 branches
BranchTrueFalseTotal
CHECK_UTF8; 0 207 207
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
405 }
406  
407 209 sv = newRV_noinc(sv);
408  
409 209 ▶ if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) { 207 2 209
if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) { 5 202 207
if ( load_blessed && (*(pkg - 1) != '\0') && (*pkg != '\0') ) { 5 0 5
410 5 sv_bless(sv, gv_stashpv(id + 12, TRUE));
411 }
412  
413 30 ▶ } else if ( (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) {
Branch: 2 branches
BranchTrueFalseTotal
} else if ( (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) { 20 3 23
} else if ( (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) { 4 16 20
414 7 dSP;
415 7 SV *val = newSVpvn(n->data.str->ptr, n->data.str->len);
416 7 char *id_copy = savepv(id);
417 7 char *lang = id_copy;
418 7 char *type = strpbrk(id_copy, "/:");
419 7 ▶ if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; }
Branch: 2 branches
BranchTrueFalseTotal
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 7 0 7
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 0 7 7
420  
421 7 ENTER;
422 7 SAVETMPS;
423 7 ▶ PUSHMARK(sp);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(sp); 0 7 7
424 7 ▶ XPUSHs(val);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(val); 0 7 7
425 7 PUTBACK;
426 7 call_pv("YAML::Syck::__qr_helper", G_SCALAR);
427 7 SPAGAIN;
428  
429 7 sv = newSVsv(POPs);
430  
431 7 PUTBACK;
432 7 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 7 0 7
433 7 LEAVE;
434  
435 /* bless it if necessary */
436 7 ▶ if ( type != NULL && strnEQ(type, "regexp:", 7)) {
Branch: 2 branches
BranchTrueFalseTotal
if ( type != NULL && strnEQ(type, "regexp:", 7)) { 7 0 7
if ( type != NULL && strnEQ(type, "regexp:", 7)) { 4 3 7
437 /* !perl/regexp:Foo::Bar blesses into Foo::Bar */
438 4 type += 7;
439 }
440  
441 7 ▶ if ( load_blessed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( load_blessed ) { 6 1 7
442 6 ▶ if (lang == NULL || (strEQ(lang, "perl"))) {
Branch: 2 branches
BranchTrueFalseTotal
if (lang == NULL || (strEQ(lang, "perl"))) { 6 0 6
if (lang == NULL || (strEQ(lang, "perl"))) { 6 0 6
443 /* !perl/regexp on it's own causes no blessing */
444 6 ▶ if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) {
Branch: 3 branches
BranchTrueFalseTotal
if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) { 6 0 6
if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) { 3 3 6
if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) { 3 0 3
445 3 sv_bless(sv, gv_stashpv(type, TRUE));
446 }
447 }
448 else {
449 0 ▶ sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE));
Branch: 1 branch
BranchTrueFalseTotal
sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE)); 0 0 0
450 }
451 }
452 7 Safefree(id_copy);
453 #endif /* PERL_LOADMOD_NOIMPORT */
454 #endif /* !YAML_IS_JSON */
455 } else {
456 /* croak("unknown node type: %s", id); */
457 16 sv = newSVpvn(n->data.str->ptr, n->data.str->len);
458 16 ▶ CHECK_UTF8;
Branch: 6 branches
BranchTrueFalseTotal
CHECK_UTF8; 0 16 16
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
CHECK_UTF8; 0 0 0
459 }
460 18724197 break;
461  
462 121 case syck_seq_kind:
463 /* load the seq into a new AV and place a ref to it in the SV */
464 121 seq = newAV();
465 396 ▶ for (i = 0; i < n->data.list->idx; i++) {
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; i < n->data.list->idx; i++) { 211 93 304
for (i = 0; i < n->data.list->idx; i++) { 64 28 92
466 275 SV *a = perl_syck_lookup_sym(p, syck_seq_read(n, i));
467 #ifndef YAML_IS_JSON
468 const char *forward_anchor;
469  
470 211 a = sv_2mortal(newSVsv(a));
471 211 forward_anchor = is_bad_alias_object(a);
472 211 ▶ if (forward_anchor)
Branch: 1 branch
BranchTrueFalseTotal
if (forward_anchor) 0 211 211
473 0 register_bad_alias(p, forward_anchor, a);
474 #endif
475 275 av_push(seq, a);
476 275 USE_OBJECT(a);
477 }
478 /* create the ref to the new array in the sv */
479 121 sv = newRV_noinc((SV*)seq);
480 #ifndef YAML_IS_JSON
481  
482 93 ▶ if (id) {
Branch: 1 branch
BranchTrueFalseTotal
if (id) { 5 88 93
483 /* bless it if necessary */
484 5 char *id_copy = savepv(id);
485 5 char *lang = id_copy;
486 5 char *type = strpbrk(id_copy, "/:");
487 5 ▶ if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; }
Branch: 2 branches
BranchTrueFalseTotal
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 5 0 5
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 0 5 5
488  
489 5 ▶ if ( type != NULL ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( type != NULL ) { 5 0 5
490 5 ▶ if (strnEQ(type, "array:", 6)) {
Branch: 1 branch
BranchTrueFalseTotal
if (strnEQ(type, "array:", 6)) { 4 1 5
491 /* !perl/array:Foo::Bar blesses into Foo::Bar */
492 4 type += 6;
493 }
494  
495 /* FIXME deprecated - here compatibility with @Foo::Bar style blessing */
496 5 ▶ while ( *type == '@' ) { type++; }
Branch: 1 branch
BranchTrueFalseTotal
while ( *type == '@' ) { type++; } 0 5 5
497 }
498  
499 5 ▶ if (load_blessed) {
Branch: 1 branch
BranchTrueFalseTotal
if (load_blessed) { 4 1 5
500 4 ▶ if (lang == NULL || (strEQ(lang, "perl"))) {
Branch: 2 branches
BranchTrueFalseTotal
if (lang == NULL || (strEQ(lang, "perl"))) { 4 0 4
if (lang == NULL || (strEQ(lang, "perl"))) { 4 0 4
501 /* !perl/array on it's own causes no blessing */
502 4 ▶ if ( (type != NULL) && strNE(type, "array") && *type != '\0' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ( (type != NULL) && strNE(type, "array") && *type != '\0' ) { 4 0 4
if ( (type != NULL) && strNE(type, "array") && *type != '\0' ) { 3 1 4
if ( (type != NULL) && strNE(type, "array") && *type != '\0' ) { 3 0 3
503 3 sv_bless(sv, gv_stashpv(type, TRUE));
504 }
505 }
506 else {
507 0 ▶ sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE));
Branch: 1 branch
BranchTrueFalseTotal
sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE)); 0 0 0
508 }
509 }
510 5 Safefree(id_copy);
511 }
512 #endif
513 121 break;
514  
515 2603 case syck_map_kind:
516 #ifndef YAML_IS_JSON
517 1909 ▶ if ( (id != NULL) && (strEQ(id, "perl/ref") || strnEQ( id, "perl/ref:", 9 ) ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if ( (id != NULL) && (strEQ(id, "perl/ref") || strnEQ( id, "perl/ref:", 9 ) ) ) { 43 1857 1900
if ( (id != NULL) && (strEQ(id, "perl/ref") || strnEQ( id, "perl/ref:", 9 ) ) ) { 35 8 43
if ( (id != NULL) && (strEQ(id, "perl/ref") || strnEQ( id, "perl/ref:", 9 ) ) ) { 1 34 35
518 /* handle scalar references, that are a weird type of mappings */
519 9 SV* key = perl_syck_lookup_sym(p, syck_map_read(n, map_key, 0));
520 9 SV* val = perl_syck_lookup_sym(p, syck_map_read(n, map_value, 0));
521 9 char *ref_type = SvPVX(key);
522 #if 0 /* need not to duplicate scalar reference */
523 const char *forward_anchor;
524  
525 val = sv_2mortal(newSVsv(val));
526 forward_anchor = is_bad_alias_object(val);
527 if (forward_anchor)
528 register_bad_alias(p, forward_anchor, val);
529 #endif
530 9 sv = newRV_noinc(val);
531 9 USE_OBJECT(val);
532  
533 9 ▶ if ( load_blessed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( load_blessed ) { 8 1 9
534 8 ▶ if ( strnNE(ref_type, REF_LITERAL, REF_LITERAL_LENGTH+1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ( strnNE(ref_type, REF_LITERAL, REF_LITERAL_LENGTH+1)) { 0 8 8
535 /* handle the weird audrey scalar ref stuff */
536 0 sv_bless(sv, gv_stashpv(ref_type, TRUE));
537 }
538 else {
539 /* bless it if necessary */
540 8 char *id_copy = savepv(id);
541 8 char *lang = id_copy;
542 8 char *type = strpbrk(id_copy, "/:");
543 8 ▶ if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; }
Branch: 2 branches
BranchTrueFalseTotal
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 8 0 8
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 0 8 8
544  
545 8 ▶ if ( type != NULL && strnEQ(type, "ref:", 4)) {
Branch: 2 branches
BranchTrueFalseTotal
if ( type != NULL && strnEQ(type, "ref:", 4)) { 8 0 8
if ( type != NULL && strnEQ(type, "ref:", 4)) { 1 7 8
546 /* !perl/ref:Foo::Bar blesses into Foo::Bar */
547 1 type += 4;
548 }
549 8 ▶ if (lang == NULL || (strEQ(lang, "perl"))) {
Branch: 2 branches
BranchTrueFalseTotal
if (lang == NULL || (strEQ(lang, "perl"))) { 8 0 8
if (lang == NULL || (strEQ(lang, "perl"))) { 8 0 8
550 /* !perl/ref on it's own causes no blessing */
551 8 ▶ if ( (type != NULL) && strNE(type, "ref") && (*type != '\0')) {
Branch: 3 branches
BranchTrueFalseTotal
if ( (type != NULL) && strNE(type, "ref") && (*type != '\0')) { 8 0 8
if ( (type != NULL) && strNE(type, "ref") && (*type != '\0')) { 1 7 8
if ( (type != NULL) && strNE(type, "ref") && (*type != '\0')) { 1 0 1
552 1 sv_bless(sv, gv_stashpv(type, TRUE));
553 }
554 }
555 else {
556 0 ▶ sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE));
Branch: 1 branch
BranchTrueFalseTotal
sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE)); 0 0 0
557 }
558 8 Safefree(id_copy);
559 }
560 }
561 }
562 1891 ▶ else if ( (id != NULL) && (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) {
Branch: 3 branches
BranchTrueFalseTotal
else if ( (id != NULL) && (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) { 34 1857 1891
else if ( (id != NULL) && (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) { 34 0 34
else if ( (id != NULL) && (strEQ(id, "perl/regexp") || strnEQ( id, "perl/regexp:", 12 ) ) ) { 0 34 34
563 /* handle regexp references, that are a weird type of mappings */
564 0 dSP;
565 0 SV* key = perl_syck_lookup_sym(p, syck_map_read(n, map_key, 0));
566 0 SV* val = perl_syck_lookup_sym(p, syck_map_read(n, map_value, 0));
567 0 char *ref_type = SvPVX(key);
568  
569 0 ENTER;
570 0 SAVETMPS;
571 0 ▶ PUSHMARK(sp);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(sp); 0 0 0
572 0 ▶ XPUSHs(val);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(val); 0 0 0
573 0 PUTBACK;
574 0 call_pv("YAML::Syck::__qr_helper", G_SCALAR);
575 0 SPAGAIN;
576  
577 0 sv = newSVsv(POPs);
578  
579 0 PUTBACK;
580 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
581 0 LEAVE;
582  
583 0 ▶ if ( load_blessed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( load_blessed ) { 0 0 0
584 0 ▶ if (strnNE(ref_type, REGEXP_LITERAL, REGEXP_LITERAL_LENGTH+1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (strnNE(ref_type, REGEXP_LITERAL, REGEXP_LITERAL_LENGTH+1)) { 0 0 0
585 /* handle the weird audrey scalar ref stuff */
586 0 sv_bless(sv, gv_stashpv(ref_type, TRUE));
587 }
588 else {
589 /* bless it if necessary */
590 0 char *id_copy = savepv(id);
591 0 char *lang = id_copy;
592 0 char *type = strpbrk(id_copy, "/:");
593 0 ▶ if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; }
Branch: 2 branches
BranchTrueFalseTotal
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 0 0 0
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 0 0 0
594  
595 0 ▶ if ( type != NULL && strnEQ(type, "regexp:", 7)) {
Branch: 2 branches
BranchTrueFalseTotal
if ( type != NULL && strnEQ(type, "regexp:", 7)) { 0 0 0
if ( type != NULL && strnEQ(type, "regexp:", 7)) { 0 0 0
596 /* !perl/regexp:Foo::Bar blesses into Foo::Bar */
597 0 type += 7;
598 }
599  
600 0 ▶ if (lang == NULL || (strEQ(lang, "perl"))) {
Branch: 2 branches
BranchTrueFalseTotal
if (lang == NULL || (strEQ(lang, "perl"))) { 0 0 0
if (lang == NULL || (strEQ(lang, "perl"))) { 0 0 0
601 /* !perl/regexp on it's own causes no blessing */
602 0 ▶ if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) {
Branch: 3 branches
BranchTrueFalseTotal
if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) { 0 0 0
if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) { 0 0 0
if ( (type != NULL) && strNE(type, "regexp") && (*type != '\0')) { 0 0 0
603 0 sv_bless(sv, gv_stashpv(type, TRUE));
604 }
605 }
606 else {
607 0 ▶ sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE));
Branch: 1 branch
BranchTrueFalseTotal
sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE)); 0 0 0
608 }
609 0 Safefree(id_copy);
610 }
611 }
612 }
613 1898 ▶ else if (id && strnEQ(id, "perl:YAML::Syck::BadAlias", 25-1)) {
Branch: 2 branches
BranchTrueFalseTotal
else if (id && strnEQ(id, "perl:YAML::Syck::BadAlias", 25-1)) { 34 1857 1891
else if (id && strnEQ(id, "perl:YAML::Syck::BadAlias", 25-1)) { 7 27 34
614 7 SV* key = (SV *) syck_map_read(n, map_key, 0);
615 7 SV* val = (SV *) syck_map_read(n, map_value, 0);
616 7 map = newHV();
617 7 ▶ if (hv_store_ent(map, key, val, 0) != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (hv_store_ent(map, key, val, 0) != NULL) 7 0 7
618 7 USE_OBJECT(val);
619 7 sv = newRV_noinc((SV*)map);
620 7 sv_bless(sv, gv_stashpv("YAML::Syck::BadAlias", TRUE));
621 }
622 else
623 #endif
624 {
625 /* load the map into a new HV and place a ref to it in the SV */
626 #ifndef YAML_IS_JSON
627 1884 AV *merge_values = NULL;
628 #endif
629 2587 map = newHV();
630 9364785 ▶ for (i = 0; i < n->data.pairs->idx; i++) {
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; i < n->data.pairs->idx; i++) { 9361461 1884 9363345
for (i = 0; i < n->data.pairs->idx; i++) { 737 703 1440
631 9362198 SV* key = perl_syck_lookup_sym(p, syck_map_read(n, map_key, i));
632 9362198 SV* val = perl_syck_lookup_sym(p, syck_map_read(n, map_value, i));
633 #ifndef YAML_IS_JSON
634 const char *forward_anchor;
635  
636 9361461 val = sv_2mortal(newSVsv(val));
637 9361461 forward_anchor = is_bad_alias_object(val);
638 9361461 ▶ if (forward_anchor)
Branch: 1 branch
BranchTrueFalseTotal
if (forward_anchor) 10 9361451 9361461
639 10 register_bad_alias(p, forward_anchor, val);
640  
641 /* YAML merge key (<<): defer merge processing until
642 * all explicit keys are stored, so explicit keys
643 * always take precedence over merged keys. */
644 9361461 ▶ if (p->implicit_typing) {
Branch: 1 branch
BranchTrueFalseTotal
if (p->implicit_typing) { 183 9361278 9361461
645 STRLEN klen;
646 183 const char *kpv = SvPV(key, klen);
647 183 ▶ if (klen == 2 && kpv[0] == '<' && kpv[1] == '<') {
Branch: 3 branches
BranchTrueFalseTotal
if (klen == 2 && kpv[0] == '<' && kpv[1] == '<') { 10 173 183
if (klen == 2 && kpv[0] == '<' && kpv[1] == '<') { 7 3 10
if (klen == 2 && kpv[0] == '<' && kpv[1] == '<') { 7 0 7
648 7 ▶ if (!merge_values)
Branch: 1 branch
BranchTrueFalseTotal
if (!merge_values) 7 0 7
649 7 merge_values = newAV();
650 7 SvREFCNT_inc(val);
651 7 av_push(merge_values, val);
652 7 continue;
653 }
654 }
655 #endif
656 9362191 ▶ if (hv_store_ent(map, key, val, 0) != NULL)
Branch: 2 branches
BranchTrueFalseTotal
if (hv_store_ent(map, key, val, 0) != NULL) 9361454 0 9361454
if (hv_store_ent(map, key, val, 0) != NULL) 737 0 737
657 9362191 USE_OBJECT(val);
658 }
659 #ifndef YAML_IS_JSON
660 /* Apply merge keys: copy entries from referenced mappings
661 * into the parent hash, skipping keys that already exist. */
662 1884 ▶ if (merge_values) {
Branch: 1 branch
BranchTrueFalseTotal
if (merge_values) { 7 1877 1884
663 long mi;
664 14 ▶ for (mi = 0; mi <= av_len(merge_values); mi++) {
Branch: 1 branch
BranchTrueFalseTotal
for (mi = 0; mi <= av_len(merge_values); mi++) { 7 7 14
665 7 SV **pmerge = av_fetch(merge_values, mi, 0);
666 7 ▶ if (!pmerge) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!pmerge) continue; 0 7 7
667 11 ▶ if (SvROK(*pmerge) && SvTYPE(SvRV(*pmerge)) == SVt_PVHV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(*pmerge) && SvTYPE(SvRV(*pmerge)) == SVt_PVHV) { 7 0 7
if (SvROK(*pmerge) && SvTYPE(SvRV(*pmerge)) == SVt_PVHV) { 4 3 7
668 /* <<: *alias (single mapping) */
669 4 HV *merge_hv = (HV *)SvRV(*pmerge);
670 HE *he;
671 4 hv_iterinit(merge_hv);
672 15 ▶ while ((he = hv_iternext(merge_hv))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(merge_hv))) { 7 4 11
673 7 SV *hkey = hv_iterkeysv(he);
674 7 ▶ if (!hv_exists_ent(map, hkey, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!hv_exists_ent(map, hkey, 0)) { 6 1 7
675 6 SV *hval = hv_iterval(merge_hv, he);
676 6 SvREFCNT_inc(hval);
677 6 ▶ if (hv_store_ent(map, hkey, hval, 0) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (hv_store_ent(map, hkey, hval, 0) == NULL) 0 6 6
678 0 SvREFCNT_dec(hval);
679 }
680 }
681 }
682 3 ▶ else if (SvROK(*pmerge) && SvTYPE(SvRV(*pmerge)) == SVt_PVAV) {
Branch: 2 branches
BranchTrueFalseTotal
else if (SvROK(*pmerge) && SvTYPE(SvRV(*pmerge)) == SVt_PVAV) { 3 0 3
else if (SvROK(*pmerge) && SvTYPE(SvRV(*pmerge)) == SVt_PVAV) { 3 0 3
683 /* <<: [*a, *b] (sequence of mappings) */
684 3 AV *merge_av = (AV *)SvRV(*pmerge);
685 long ai;
686 9 ▶ for (ai = 0; ai <= av_len(merge_av); ai++) {
Branch: 1 branch
BranchTrueFalseTotal
for (ai = 0; ai <= av_len(merge_av); ai++) { 6 3 9
687 6 SV **pelem = av_fetch(merge_av, ai, 0);
688 HV *elem_hv;
689 HE *he;
690 6 ▶ if (!pelem || !SvROK(*pelem) || SvTYPE(SvRV(*pelem)) != SVt_PVHV)
Branch: 3 branches
BranchTrueFalseTotal
if (!pelem || !SvROK(*pelem) || SvTYPE(SvRV(*pelem)) != SVt_PVHV) 6 0 6
if (!pelem || !SvROK(*pelem) || SvTYPE(SvRV(*pelem)) != SVt_PVHV) 6 0 6
if (!pelem || !SvROK(*pelem) || SvTYPE(SvRV(*pelem)) != SVt_PVHV) 0 6 6
691 0 continue;
692 6 elem_hv = (HV *)SvRV(*pelem);
693 6 hv_iterinit(elem_hv);
694 22 ▶ while ((he = hv_iternext(elem_hv))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(elem_hv))) { 10 6 16
695 10 SV *hkey = hv_iterkeysv(he);
696 10 ▶ if (!hv_exists_ent(map, hkey, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!hv_exists_ent(map, hkey, 0)) { 9 1 10
697 9 SV *hval = hv_iterval(elem_hv, he);
698 9 SvREFCNT_inc(hval);
699 9 ▶ if (hv_store_ent(map, hkey, hval, 0) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (hv_store_ent(map, hkey, hval, 0) == NULL) 0 9 9
700 0 SvREFCNT_dec(hval);
701 }
702 }
703 }
704 }
705 }
706 7 SvREFCNT_dec((SV *)merge_values);
707 }
708 #endif
709 2587 sv = newRV_noinc((SV*)map);
710 #ifndef YAML_IS_JSON
711 1884 ▶ if (id) {
Branch: 1 branch
BranchTrueFalseTotal
if (id) { 27 1857 1884
712 /* bless it if necessary */
713 27 char *id_copy = savepv(id);
714 27 char *lang = id_copy;
715 27 char *type = strpbrk(id_copy, "/:");
716 27 ▶ if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; }
Branch: 2 branches
BranchTrueFalseTotal
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 23 4 27
if (type != NULL) { *type = '\0'; type++; if (*type == '\0') type = NULL; } 0 23 23
717  
718 27 ▶ if ( type != NULL ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( type != NULL ) { 23 4 27
719 23 ▶ if (strnEQ(type, "hash:", 5)) {
Branch: 1 branch
BranchTrueFalseTotal
if (strnEQ(type, "hash:", 5)) { 12 11 23
720 /* !perl/hash:Foo::Bar blesses into Foo::Bar */
721 12 type += 5;
722 }
723  
724 /* FIXME deprecated - here compatibility with %Foo::Bar style blessing */
725 23 ▶ while ( *type == '%' ) { type++; }
Branch: 1 branch
BranchTrueFalseTotal
while ( *type == '%' ) { type++; } 0 23 23
726 }
727  
728 27 ▶ if (load_blessed) {
Branch: 1 branch
BranchTrueFalseTotal
if (load_blessed) { 17 10 27
729 17 ▶ if (lang == NULL || (strEQ(lang, "perl"))) {
Branch: 2 branches
BranchTrueFalseTotal
if (lang == NULL || (strEQ(lang, "perl"))) { 17 0 17
if (lang == NULL || (strEQ(lang, "perl"))) { 12 5 17
730 /* !perl/hash on it's own causes no blessing */
731 12 ▶ if ( (type != NULL) && strNE(type, "hash") && *type != '\0' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ( (type != NULL) && strNE(type, "hash") && *type != '\0' ) { 11 1 12
if ( (type != NULL) && strNE(type, "hash") && *type != '\0' ) { 10 1 11
if ( (type != NULL) && strNE(type, "hash") && *type != '\0' ) { 10 0 10
732 10 sv_bless(sv, gv_stashpv(type, TRUE));
733 }
734 } else {
735 5 ▶ sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE));
Branch: 1 branch
BranchTrueFalseTotal
sv_bless(sv, gv_stashpv((type == NULL) ? lang : form("%s::%s", lang, type), TRUE)); 4 1 5
736 }
737 }
738 27 Safefree(id_copy);
739 }
740 #endif
741 }
742 2603 break;
743 }
744  
745 #ifndef YAML_IS_JSON
746 /* Fix bad anchors using sv_setsv */
747 18725230 ▶ if (n->id) {
Branch: 1 branch
BranchTrueFalseTotal
if (n->id) { 7 18725223 18725230
748 7 ▶ if (n->anchor)
Branch: 1 branch
BranchTrueFalseTotal
if (n->anchor) 7 0 7
749 7 resolve_bad_alias(p, n->anchor, sv);
750  
751 7 sv_setsv( perl_syck_lookup_sym(p, n->id), sv );
752 }
753 #endif
754  
755 18726921 TRACK_OBJECT(sv);
756  
757 18726921 return syck_add_sym(p, (char *)sv);
758 }
759  
760 #ifdef YAML_IS_JSON
761 156 static char* perl_json_preprocess(char *s) {
762 STRLEN i;
763 char *out;
764 char ch;
765 156 char in_string = '\0';
766 156 bool in_quote = 0;
767 char *pos;
768 156 STRLEN len = strlen(s);
769  
770 156 New(2006, out, len*2+1, char);
771 156 pos = out;
772  
773 13496 ▶ for (i = 0; i < len; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < len; i++) { 13340 156 13496
774 13340 ch = *(s+i);
775 13340 *pos++ = ch;
776 13340 ▶ if (in_quote) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_quote) { 97 13243 13340
777 97 in_quote = !in_quote;
778 97 ▶ if (ch == '\'' && json_quote_char == '\'') {
Branch: 2 branches
BranchTrueFalseTotal
if (ch == '\'' && json_quote_char == '\'') { 9 88 97
if (ch == '\'' && json_quote_char == '\'') { 9 0 9
779 /* JSON single-quote mode: \' is an escaped quote.
780 * Since we convert delimiters to " for YAML double-quote
781 * parsing, a literal ' needs no backslash inside "..." */
782 9 pos -= 2;
783 9 *pos++ = '\'';
784 }
785 88 ▶ else if (ch == '\'') {
Branch: 1 branch
BranchTrueFalseTotal
else if (ch == '\'') { 0 88 88
786 0 *(pos - 2) = '\'';
787 }
788 }
789 13243 ▶ else if (ch == '\\') {
Branch: 1 branch
BranchTrueFalseTotal
else if (ch == '\\') { 97 13146 13243
790 97 in_quote = 1;
791 }
792 13146 ▶ else if (in_string == '\0') {
Branch: 1 branch
BranchTrueFalseTotal
else if (in_string == '\0') { 6064 7082 13146
793 6064 switch (ch) {
794 1380 case ':': { *pos++ = ' '; break; }
795 70 case ',': { *pos++ = ' '; break; }
796 1452 case '"': { in_string = '"'; break; }
797 52 case '\'': {
798 52 in_string = '\'';
799 52 ▶ if (json_quote_char == '\'') {
Branch: 1 branch
BranchTrueFalseTotal
if (json_quote_char == '\'') { 51 1 52
800 /* Convert ' delimiter to " so YAML double-quote
801 * parser handles escape sequences (\b, \n, etc.) */
802 51 *(pos - 1) = '"';
803 }
804 52 break;
805 }
806 }
807 }
808 7082 ▶ else if (ch == in_string) {
Branch: 1 branch
BranchTrueFalseTotal
else if (ch == in_string) { 1504 5578 7082
809 1504 in_string = '\0';
810 1504 ▶ if (ch == '\'' && json_quote_char == '\'') {
Branch: 2 branches
BranchTrueFalseTotal
if (ch == '\'' && json_quote_char == '\'') { 52 1452 1504
if (ch == '\'' && json_quote_char == '\'') { 51 1 52
811 51 *(pos - 1) = '"';
812 }
813 }
814 5578 ▶ else if (ch == '"' && json_quote_char == '\'' && in_string == '\'') {
Branch: 3 branches
BranchTrueFalseTotal
else if (ch == '"' && json_quote_char == '\'' && in_string == '\'') { 0 5578 5578
else if (ch == '"' && json_quote_char == '\'' && in_string == '\'') { 0 0 0
else if (ch == '"' && json_quote_char == '\'' && in_string == '\'') { 0 0 0
815 /* Unescaped " inside a single-quoted JSON string needs escaping
816 * because we converted the delimiters to " for YAML parsing */
817 0 *(pos - 1) = '\\';
818 0 *pos++ = '"';
819 }
820 }
821  
822 156 *pos = '\0';
823 156 return out;
824 }
825  
826 235 void perl_json_postprocess(SV *sv) {
827 STRLEN i;
828 char ch;
829 235 bool in_string = 0;
830 235 bool in_quote = 0;
831 char *pos;
832 235 char *s = SvPVX(sv);
833 235 STRLEN len = sv_len(sv);
834 235 STRLEN final_len = len;
835  
836 235 pos = s;
837  
838 /* Horrible kluge if your quote char does not match what's wrapping this line */
839 235 ▶ if ( (json_quote_char == '\'') && (len > 1) && (*s == '\"') && (*(s+len-2) == '\"') ) {
Branch: 4 branches
BranchTrueFalseTotal
if ( (json_quote_char == '\'') && (len > 1) && (*s == '\"') && (*(s+len-2) == '\"') ) { 57 178 235
if ( (json_quote_char == '\'') && (len > 1) && (*s == '\"') && (*(s+len-2) == '\"') ) { 57 0 57
if ( (json_quote_char == '\'') && (len > 1) && (*s == '\"') && (*(s+len-2) == '\"') ) { 0 57 57
if ( (json_quote_char == '\'') && (len > 1) && (*s == '\"') && (*(s+len-2) == '\"') ) { 0 0 0
840 0 *s = '\'';
841 0 *(s+len-2) = '\'';
842 }
843  
844 /* Strip spaces after ':' and ',' outside quoted strings to produce
845 * compact JSON. The C-level emitter outputs "key": "value", ... with
846 * spaces; this in-place compaction removes them. See t/json-postprocess.t.
847 */
848 4086 ▶ for (i = 0; i < len; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < len; i++) { 3851 235 4086
849 3851 ch = *(s+i);
850 3851 *pos++ = ch;
851 3851 ▶ if (in_quote) {
Branch: 1 branch
BranchTrueFalseTotal
if (in_quote) { 96 3755 3851
852 96 in_quote = !in_quote;
853 }
854 3755 ▶ else if (ch == '\\') {
Branch: 1 branch
BranchTrueFalseTotal
else if (ch == '\\') { 96 3659 3755
855 96 in_quote = 1;
856 }
857 3659 ▶ else if (ch == json_quote_char) {
Branch: 1 branch
BranchTrueFalseTotal
else if (ch == json_quote_char) { 456 3203 3659
858 456 in_string = !in_string;
859 }
860 3203 ▶ else if ((ch == ':' || ch == ',') && !in_string) {
Branch: 3 branches
BranchTrueFalseTotal
else if ((ch == ':' || ch == ',') && !in_string) { 3132 71 3203
else if ((ch == ':' || ch == ',') && !in_string) { 67 3065 3132
else if ((ch == ':' || ch == ',') && !in_string) { 124 14 138
861 124 i++; /* has to be a space afterwards */
862 124 final_len--;
863 }
864 }
865  
866 /* Remove the trailing newline */
867 235 ▶ if (final_len > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (final_len > 0) { 235 0 235
868 235 final_len--; pos--;
869 }
870 235 *pos = '\0';
871 235 SvCUR_set(sv, final_len);
872 235 }
873 #endif
874  
875 /* Destructor for SAVEDESTRUCTOR_X: frees parser on croak.
876 * Registered after syck_new_parser() so Perl's scope unwinding handles
877 * cleanup even when croak() longjmps past the normal return path.
878 * Guarded because perl_syck.h is included twice (YAML and JSON modes). */
879 #ifndef CLEANUP_PARSER_DEFINED
880 #define CLEANUP_PARSER_DEFINED
881 static void
882 2252 cleanup_parser(pTHX_ void *p) {
883 2252 SyckParser **pp = (SyckParser **)p;
884 2252 ▶ if (*pp != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (*pp != NULL) { 32 2220 2252
885 32 syck_free_parser(*pp);
886 32 *pp = NULL;
887 }
888 2252 }
889 #endif
890  
891 #ifdef YAML_IS_JSON
892 156 static SV * LoadJSON (char *s) {
893 #else
894 2200 static SV * LoadYAML (char *s) {
895 #endif
896 SYMID v;
897 SyckParser *parser;
898 struct parser_xtra bonus;
899  
900 2356 SV *obj = &PL_sv_undef;
901 2356 SV *use_code = GvSV(gv_fetchpv(form("%s::UseCode", PACKAGE_NAME), TRUE, SVt_PV));
902 2356 SV *load_code = GvSV(gv_fetchpv(form("%s::LoadCode", PACKAGE_NAME), TRUE, SVt_PV));
903 2356 SV *implicit_typing = GvSV(gv_fetchpv(form("%s::ImplicitTyping", PACKAGE_NAME), TRUE, SVt_PV));
904 2356 SV *implicit_unicode = GvSV(gv_fetchpv(form("%s::ImplicitUnicode", PACKAGE_NAME), TRUE, SVt_PV));
905 2356 SV *singlequote = GvSV(gv_fetchpv(form("%s::SingleQuote", PACKAGE_NAME), TRUE, SVt_PV));
906 2356 SV *load_blessed = GvSV(gv_fetchpv(form("%s::LoadBlessed", PACKAGE_NAME), TRUE, SVt_PV));
907 2356 SV *max_depth = GvSV(gv_fetchpv(form("%s::MaxDepth", PACKAGE_NAME), TRUE, SVt_PV));
908 2356 ▶ json_quote_char = (SvTRUE(singlequote) ? '\'' : '"' );
Branch: 2 branches
BranchTrueFalseTotal
json_quote_char = (SvTRUE(singlequote) ? '\'' : '"' ); 14 2186 2200
json_quote_char = (SvTRUE(singlequote) ? '\'' : '"' ); 53 103 156
909  
910 2356 ENTER; SAVETMPS;
911  
912 /* Don't even bother if the string is empty. */
913 2356 ▶ if (*s == '\0') { FREETMPS; LEAVE; return &PL_sv_undef; }
Branch: 4 branches
BranchTrueFalseTotal
if (*s == '\0') { FREETMPS; LEAVE; return &PL_sv_undef; } 104 2096 2200
if (*s == '\0') { FREETMPS; LEAVE; return &PL_sv_undef; } 0 104 104
if (*s == '\0') { FREETMPS; LEAVE; return &PL_sv_undef; } 0 156 156
if (*s == '\0') { FREETMPS; LEAVE; return &PL_sv_undef; } 0 0 0
914  
915 #ifdef YAML_IS_JSON
916 156 s = perl_json_preprocess(s);
917 156 SAVEFREEPV(s); /* freed at LEAVE — also on croak */
918 #else
919 /* Special preprocessing to maintain compat with YAML.pm <= 0.35 */
920 2096 ▶ if (strnEQ( s, "--- #YAML:1.0", 13)) {
Branch: 1 branch
BranchTrueFalseTotal
if (strnEQ( s, "--- #YAML:1.0", 13)) { 2 2094 2096
921 2 s[4] = '%';
922 }
923 #endif
924  
925 2252 parser = syck_new_parser();
926  
927 /* Register destructor so croak() in parser callbacks (error_handler,
928 * parser_handler code-loading) won't leak the SyckParser. */
929 2252 SAVEDESTRUCTOR_X(cleanup_parser, &parser);
930  
931 2252 syck_parser_str_auto(parser, s, NULL);
932 2252 syck_parser_handler(parser, PERL_SYCK_PARSER_HANDLER);
933 2252 syck_parser_error_handler(parser, perl_syck_error_handler);
934 2252 syck_parser_bad_anchor_handler( parser, perl_syck_bad_anchor_handler );
935 2252 syck_parser_implicit_typing(parser, SvTRUE(implicit_typing));
936 2252 syck_parser_taguri_expansion(parser, 0);
937 2252 if (SvIOK(max_depth))
938 163 parser->max_depth = SvIV(max_depth);
939 else
940 2089 parser->max_depth = 512;
941  
942 2252 bonus.objects = (AV*)sv_2mortal((SV*)newAV());
943 2252 bonus.implicit_unicode = SvTRUE(implicit_unicode);
944 2252 ▶ bonus.load_code = SvTRUE(use_code) || SvTRUE(load_code);
Branch: 4 branches
BranchTrueFalseTotal
bonus.load_code = SvTRUE(use_code) || SvTRUE(load_code); 1579 517 2096
bonus.load_code = SvTRUE(use_code) || SvTRUE(load_code); 4 1575 1579
bonus.load_code = SvTRUE(use_code) || SvTRUE(load_code); 156 0 156
bonus.load_code = SvTRUE(use_code) || SvTRUE(load_code); 0 156 156
945 2252 bonus.load_blessed = SvTRUE(load_blessed);
946 2252 parser->bonus = &bonus;
947  
948 #ifndef YAML_IS_JSON
949 2096 bonus.bad_anchors = (HV*)sv_2mortal((SV*)newHV());
950  
951 2096 ▶ if (GIMME_V == G_ARRAY) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_ARRAY) { 214 1882 2096
952 214 SYMID prev_v = 0;
953  
954 /* Mortalize the AV so croak() during syck_parse() won't leak it.
955 * Use newRV_inc to compensate — the mortal entry decrements at LEAVE. */
956 214 obj = (SV*)sv_2mortal((SV*)newAV());
957 450 ▶ while ((v = syck_parse(parser)) && (v != prev_v)) {
Branch: 2 branches
BranchTrueFalseTotal
while ((v = syck_parse(parser)) && (v != prev_v)) { 450 0 450
while ((v = syck_parse(parser)) && (v != prev_v)) { 236 214 450
958 236 SV *cur = &PL_sv_undef;
959 236 ▶ if (!syck_lookup_sym(parser, v, (char **)&cur)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!syck_lookup_sym(parser, v, (char **)&cur)) { 0 236 236
960 0 break;
961 }
962  
963 236 av_push((AV*)obj, cur);
964 236 USE_OBJECT(cur);
965  
966 236 prev_v = v;
967 }
968 214 obj = newRV_inc(obj);
969 }
970 else
971 #endif
972 {
973 2038 v = syck_parse(parser);
974 2006 ▶ if (syck_lookup_sym(parser, v, (char **)&obj)) {
Branch: 2 branches
BranchTrueFalseTotal
if (syck_lookup_sym(parser, v, (char **)&obj)) { 1853 0 1853
if (syck_lookup_sym(parser, v, (char **)&obj)) { 153 0 153
975 2006 USE_OBJECT(obj);
976 }
977 }
978  
979 /* Normal path: free parser now and NULL the pointer so the
980 * SAVEDESTRUCTOR_X callback (at LEAVE) becomes a no-op. */
981 2220 syck_free_parser(parser);
982 2220 parser = NULL;
983  
984 /* In JSON mode, SAVEFREEPV(s) frees the preprocessed string at LEAVE. */
985  
986 2220 ▶ FREETMPS; LEAVE;
Branch: 2 branches
BranchTrueFalseTotal
FREETMPS; LEAVE; 2067 0 2067
FREETMPS; LEAVE; 153 0 153
987  
988 2220 return obj;
989 }
990  
991 void
992 #ifdef YAML_IS_JSON
993 25652 json_syck_mark_emitter
994 #else
995 7688 yaml_syck_mark_emitter
996 #endif
997 (SyckEmitter *e, SV *sv) {
998 33340 e->depth++;
999  
1000 33340 ▶ if (syck_emitter_mark_node(e, (st_data_t)sv, PERL_SYCK_EMITTER_MARK_NODE_FLAGS) == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (syck_emitter_mark_node(e, (st_data_t)sv, PERL_SYCK_EMITTER_MARK_NODE_FLAGS) == 0) { 190 7498 7688
if (syck_emitter_mark_node(e, (st_data_t)sv, PERL_SYCK_EMITTER_MARK_NODE_FLAGS) == 0) { 2 25650 25652
1001 192 e->depth--;
1002 192 return;
1003 }
1004  
1005 33148 ▶ if (e->depth >= e->max_depth) {
Branch: 2 branches
BranchTrueFalseTotal
if (e->depth >= e->max_depth) { 3 7495 7498
if (e->depth >= e->max_depth) { 46 25604 25650
1006 #ifdef YAML_IS_JSON
1007 46 croak("Dumping circular structures is not supported with JSON::Syck, consider increasing $JSON::Syck::MaxDepth higher then %d.", e->max_depth);
1008 #else
1009 3 croak("Structure is nested deeper than $YAML::Syck::MaxDepth (%d); increase $YAML::Syck::MaxDepth to dump deeper structures.", e->max_depth);
1010 #endif
1011 }
1012  
1013 33099 ▶ if (SvROK(sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(sv)) { 3101 4394 7495
if (SvROK(sv)) { 12683 12921 25604
1014 15784 PERL_SYCK_MARK_EMITTER(e, SvRV(sv));
1015 #ifdef YAML_IS_JSON
1016 907 st_insert(e->markers, (st_data_t)sv, 0);
1017 #endif
1018 3240 e->depth--;
1019 3240 return;
1020 }
1021  
1022 17315 switch (SvTYPE(sv)) {
1023 8549 case SVt_PVAV: {
1024 I32 len, i;
1025 8549 len = av_len((AV*)sv) + 1;
1026 11152 ▶ for (i = 0; i < len; i++) {
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; i < len; i++) { 2472 1078 3550
for (i = 0; i < len; i++) { 6761 841 7602
1027 9233 SV** sav = av_fetch((AV*)sv, i, 0);
1028 9233 if (sav != NULL) {
1029 9233 PERL_SYCK_MARK_EMITTER( e, *sav );
1030 }
1031 }
1032 1919 break;
1033 }
1034 6518 case SVt_PVHV: {
1035 HE *he;
1036 6518 hv_iterinit((HV*)sv);
1037 #ifdef HV_ITERNEXT_WANTPLACEHOLDERS
1038 7448 ▶ while ((he = hv_iternext_flags((HV*)sv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) {
Branch: 2 branches
BranchTrueFalseTotal
while ((he = hv_iternext_flags((HV*)sv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) { 868 593 1461
while ((he = hv_iternext_flags((HV*)sv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) { 5927 60 5987
1039 #else
1040 while ((he = hv_iternext((HV*)sv)) != NULL) {
1041 #endif
1042 6795 SV *val = hv_iterval((HV*)sv, he);
1043 6795 PERL_SYCK_MARK_EMITTER( e, val );
1044 }
1045 653 break;
1046 }
1047 2248 default:
1048 2248 break;
1049 }
1050  
1051 #ifdef YAML_IS_JSON
1052 1191 st_insert(e->markers, (st_data_t)sv, 0);
1053 #endif
1054 4820 --e->depth;
1055 }
1056  
1057  
1058 void
1059 #ifdef YAML_IS_JSON
1060 2167 json_syck_emitter_handler
1061 #else
1062 7040 yaml_syck_emitter_handler
1063 #endif
1064 (SyckEmitter *e, st_data_t data) {
1065 I32 len, i;
1066 9207 SV* sv = (SV*)data;
1067 9207 struct emitter_xtra *bonus = (struct emitter_xtra *)e->bonus;
1068 9207 char* tag = bonus->tag;
1069 9207 svtype ty = SvTYPE(sv);
1070 #ifndef YAML_IS_JSON
1071 7040 char dump_code = bonus->dump_code;
1072 7040 char implicit_binary = bonus->implicit_binary;
1073 7040 char* ref = NULL;
1074 7040 char* ref_orig = NULL;
1075 #endif
1076  
1077 #define OBJECT_TAG "tag:!perl:"
1078
1079 9207 ▶ if (SvMAGICAL(sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvMAGICAL(sv)) { 17 7023 7040
if (SvMAGICAL(sv)) { 3 2164 2167
1080 20 mg_get(sv);
1081 }
1082  
1083 #ifndef YAML_IS_JSON
1084  
1085 /* Handle blessing into the right class */
1086 7040 ▶ if (sv_isobject(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv_isobject(sv)) { 68 6972 7040
1087 68 ref = savepv(sv_reftype(SvRV(sv), TRUE));
1088 68 ref_orig = ref;
1089 68 bonus->cur_ref = ref; /* track for cleanup on croak */
1090 68 *tag = '\0';
1091 68 strcat(tag, OBJECT_TAG);
1092  
1093 68 switch (SvTYPE(SvRV(sv))) {
1094 11 case SVt_PVAV: { strcat(tag, "array:"); break; }
1095 23 case SVt_PVHV: { strcat(tag, "hash:"); break; }
1096 4 case SVt_PVCV: { strcat(tag, "code:"); break; }
1097 0 case SVt_PVGV: { strcat(tag, "glob:"); break; }
1098 #if PERL_VERSION > 10
1099 11 case SVt_REGEXP: {
1100 11 ▶ if (strEQ(ref, "Regexp")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(ref, "Regexp")) { 5 6 11
1101 5 strcat(tag, "regexp");
1102 5 ref += 6; /* empty string */
1103 } else {
1104 6 strcat(tag, "regexp:");
1105 }
1106 11 break;
1107 }
1108 #endif
1109  
1110 /* flatten scalar ref objects so that they dump as !perl/scalar:Foo::Bar foo */
1111 19 case SVt_PVMG: {
1112 19 ▶ if ( SvROK(SvRV(sv)) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( SvROK(SvRV(sv)) ) { 2 17 19
1113 2 strcat(tag, "ref:");
1114 2 break;
1115 }
1116 #if PERL_VERSION > 10
1117 else {
1118 17 strcat(tag, "scalar:");
1119 17 sv = SvRV(sv);
1120 17 ty = SvTYPE(sv);
1121 17 break;
1122 }
1123 #else
1124 else {
1125 MAGIC *mg;
1126 if ( (mg = mg_find(SvRV(sv), PERL_MAGIC_qr) ) ) {
1127 if (strEQ(ref, "Regexp")) {
1128 strcat(tag, "regexp");
1129 ref += 6; /* empty string */
1130 }
1131 else {
1132 strcat(tag, "regexp:");
1133 }
1134 sv = newSVpvn(SvPV_nolen(sv), sv_len(sv));
1135 ty = SvTYPE(sv);
1136 }
1137 else {
1138 strcat(tag, "scalar:");
1139 sv = SvRV(sv);
1140 ty = SvTYPE(sv);
1141 }
1142 break;
1143 }
1144 #endif
1145 }
1146 0 default:
1147 0 break;
1148 }
1149 {
1150 /* Grow tag buffer if ref won't fit (prevents heap overflow) */
1151 68 STRLEN need = strlen(tag) + strlen(ref) + 1;
1152 68 ▶ if (need > bonus->tag_len) {
Branch: 1 branch
BranchTrueFalseTotal
if (need > bonus->tag_len) { 2 66 68
1153 2 Renew(bonus->tag, need, char);
1154 2 bonus->tag_len = need;
1155 2 tag = bonus->tag;
1156 }
1157 }
1158 68 strcat(tag, ref);
1159 }
1160 #endif
1161  
1162 /*
1163 * For blessed scalar refs that were flattened (sv = SvRV(sv) in SVt_PVMG
1164 * above), the inner scalar may have an anchor from the marking pass.
1165 * Since we emit it via syck_emit_scalar() (not syck_emit()), we must
1166 * handle anchors/aliases manually here.
1167 */
1168 #ifndef YAML_IS_JSON
1169 7040 ▶ if (ref_orig != NULL && !SvROK(sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref_orig != NULL && !SvROK(sv)) { 68 6972 7040
if (ref_orig != NULL && !SvROK(sv)) { 17 51 68
1170 st_data_t oid;
1171 17 char *anchor_name = NULL;
1172 27 if (e->anchors != NULL &&
1173 20 ▶ st_lookup(e->markers, (st_data_t)sv, &oid) &&
Branch: 1 branch
BranchTrueFalseTotal
st_lookup(e->markers, (st_data_t)sv, &oid) && 8 2 10
1174 10 st_lookup(e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name))
1175 {
1176 8 ▶ if (e->anchored == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (e->anchored == NULL) { 4 4 8
1177 4 e->anchored = st_init_numtable();
1178 }
1179 8 ▶ if (!st_lookup(e->anchored, (st_data_t)anchor_name, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!st_lookup(e->anchored, (st_data_t)anchor_name, 0)) { 4 4 8
1180 /* First occurrence: write &N before the tag+scalar */
1181 4 char *an = S_ALLOC_N(char, strlen(anchor_name) + 3);
1182 4 sprintf(an, "&%s ", anchor_name);
1183 4 syck_emitter_write(e, an, strlen(anchor_name) + 2);
1184 4 S_FREE(an);
1185 4 st_insert(e->anchored, (st_data_t)anchor_name, 0);
1186 }
1187 else {
1188 /* Already emitted: write *N alias and return */
1189 4 char *an = S_ALLOC_N(char, strlen(anchor_name) + 2);
1190 4 sprintf(an, "*%s", anchor_name);
1191 4 syck_emitter_write(e, an, strlen(anchor_name) + 1);
1192 4 S_FREE(an);
1193 4 *tag = '\0';
1194 4 Safefree(ref_orig);
1195 4 bonus->cur_ref = NULL;
1196 4 return;
1197 }
1198 }
1199 }
1200 #endif
1201  
1202 9203 ▶ if (SvROK(sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(sv)) { 2318 4718 7036
if (SvROK(sv)) { 908 1259 2167
1203 /* emit a scalar ref */
1204 #ifdef YAML_IS_JSON
1205 908 PERL_SYCK_EMITTER_HANDLER(e, (st_data_t)SvRV(sv));
1206 #else
1207 2318 switch (SvTYPE(SvRV(sv))) {
1208 2080 case SVt_PVAV:
1209 case SVt_PVHV:
1210 case SVt_PVCV: {
1211 /* Arrays, hashes and code values are inlined, and will be wrapped by a ref in the undumping */
1212 2080 e->indent = 0;
1213 2080 syck_emit_item(e, (st_data_t)SvRV(sv));
1214 2059 e->indent = PERL_SYCK_INDENT_LEVEL;
1215 2059 break;
1216 }
1217 #if PERL_VERSION > 10
1218 11 case SVt_REGEXP: {
1219 11 STRLEN len = sv_len(sv);
1220 22 ▶ syck_emit_scalar( e, OBJOF("tag:!perl:regexp"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len );
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar( e, OBJOF("tag:!perl:regexp"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len ); 11 0 11
1221 11 syck_emit_end(e);
1222 11 break;
1223 }
1224 #endif
1225 227 default: {
1226 SV *ref_sv;
1227 227 ▶ syck_emit_map(e, OBJOF("tag:!perl:ref"), MAP_NONE);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_map(e, OBJOF("tag:!perl:ref"), MAP_NONE); 2 225 227
1228 227 *tag = '\0';
1229 227 ref_sv = newSVpvn_share(REF_LITERAL, REF_LITERAL_LENGTH, 0);
1230 227 syck_emit_item( e, (st_data_t)ref_sv );
1231 227 SvREFCNT_dec(ref_sv);
1232 227 syck_emit_item( e, (st_data_t)SvRV(sv) );
1233 227 syck_emit_end(e);
1234 }
1235 }
1236 #endif
1237 }
1238 5977 ▶ else if (ty == SVt_NULL) {
Branch: 2 branches
BranchTrueFalseTotal
else if (ty == SVt_NULL) { 7 4711 4718
else if (ty == SVt_NULL) { 17 1242 1259
1239 /* emit an undef */
1240 24 syck_emit_scalar(e, "str", scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH);
1241 }
1242 5953 ▶ else if ((ty == SVt_PVMG) && !SvOK(sv)) {
Branch: 4 branches
BranchTrueFalseTotal
else if ((ty == SVt_PVMG) && !SvOK(sv)) { 19 4692 4711
else if ((ty == SVt_PVMG) && !SvOK(sv)) { 3 16 19
else if ((ty == SVt_PVMG) && !SvOK(sv)) { 2 1240 1242
else if ((ty == SVt_PVMG) && !SvOK(sv)) { 0 2 2
1243 /* emit an undef (typically pointed from a blesed SvRV) */
1244 3 ▶ syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH); 3 0 3
1245 }
1246 8593 ▶ else if (SvPOK(sv) && ty != SVt_PVCV) {
Branch: 4 branches
BranchTrueFalseTotal
else if (SvPOK(sv) && ty != SVt_PVCV) { 2419 2289 4708
else if (SvPOK(sv) && ty != SVt_PVCV) { 2415 4 2419
else if (SvPOK(sv) && ty != SVt_PVCV) { 228 1014 1242
else if (SvPOK(sv) && ty != SVt_PVCV) { 228 0 228
1247 /* emit a string (exclude CVs: prototyped subs have SvPOK set for the
1248 * prototype string, but must go through the SVt_PVCV case below for
1249 * proper B::Deparse handling) */
1250 2643 STRLEN len = sv_len(sv);
1251  
1252 /* JSON should preserve quotes even on simple integers ("0" is true in javascript) */
1253 #ifndef YAML_IS_JSON
1254 2415 ▶ if (looks_like_number(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (looks_like_number(sv)) { 558 1857 2415
1255 558 ▶ if(!(SvIOK(sv) || SvNOK(sv))) {
Branch: 2 branches
BranchTrueFalseTotal
if(!(SvIOK(sv) || SvNOK(sv))) { 557 1 558
if(!(SvIOK(sv) || SvNOK(sv))) { 557 0 557
1256 /* POK-only: string that looks numeric — quote to preserve type */
1257 1114 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, SvPV_nolen(sv), len);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, SvPV_nolen(sv), len); 0 557 557
1258 }
1259 2 ▶ else if(syck_str_is_unquotable_integer(SvPV_nolen(sv), sv_len(sv))) {
Branch: 1 branch
BranchTrueFalseTotal
else if(syck_str_is_unquotable_integer(SvPV_nolen(sv), sv_len(sv))) { 1 0 1
1260 /* emit an unquoted number only if it's a very basic integer. /^-?[1-9][0-9]*$/ */
1261 2 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_NUMBER, 0, 0, 0, SvPV_nolen(sv), len);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_NUMBER, 0, 0, 0, SvPV_nolen(sv), len); 0 1 1
1262 }
1263 else {
1264 /* Even though it looks like a number, quote it or it won't round trip correctly. */
1265 0 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, SvPV_nolen(sv), len);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, SvPV_nolen(sv), len); 0 0 0
1266 }
1267 }
1268 else
1269 #endif
1270 2085 if (len == 0) {
1271 15 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, "", 0);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, "", 0); 0 2 2
1272 }
1273 1855 ▶ else if (IS_UTF8(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
else if (IS_UTF8(sv)) { 136 1719 1855
1274 /* if we support UTF8 and the string contains UTF8 */
1275 351 enum scalar_style old_s = e->style;
1276 351 e->style = SCALAR_UTF8;
1277 702 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len); 0 136 136
1278 351 e->style = old_s;
1279 }
1280 #ifndef YAML_IS_JSON
1281 1719 ▶ else if (implicit_binary) {
Branch: 1 branch
BranchTrueFalseTotal
else if (implicit_binary) { 47 1672 1719
1282 /* scan string for high-bits in the SV */
1283 47 bool is_ascii = TRUE;
1284 47 char *str = SvPV_nolen(sv);
1285 47 STRLEN bin_len = sv_len(sv);
1286 STRLEN bi;
1287  
1288 347 ▶ for (bi = 0; bi < bin_len; bi++) {
Branch: 1 branch
BranchTrueFalseTotal
for (bi = 0; bi < bin_len; bi++) { 301 46 347
1289 301 ▶ if (*(str + bi) & 0x80) {
Branch: 1 branch
BranchTrueFalseTotal
if (*(str + bi) & 0x80) { 1 300 301
1290 /* Binary here */
1291 1 char *base64 = syck_base64enc( str, bin_len );
1292 1 syck_emit_scalar(e, "tag:yaml.org,2002:binary", SCALAR_STRING, 0, 0, 0, base64, strlen(base64));
1293 1 syck_base64_free(base64);
1294 1 is_ascii = FALSE;
1295 1 break;
1296 }
1297 }
1298  
1299 47 ▶ if (is_ascii) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_ascii) { 46 1 47
1300 46 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, str, bin_len);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, str, bin_len); 0 46 46
1301 }
1302 }
1303 #endif
1304 else {
1305 3344 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), len); 9 1663 1672
1306 }
1307 }
1308 3307 ▶ else if (SvNIOK(sv)) {
Branch: 2 branches
BranchTrueFalseTotal
else if (SvNIOK(sv)) { 185 2108 2293
else if (SvNIOK(sv)) { 103 911 1014
1309 #ifndef YAML_IS_JSON
1310 185 int special_nv = 0;
1311 {
1312 185 NV nv = SvNV(sv);
1313 #ifdef NV_NAN
1314 185 ▶ if (nv != nv) {
Branch: 1 branch
BranchTrueFalseTotal
if (nv != nv) { 2 183 185
1315 2 ▶ syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, ".nan", 4);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, ".nan", 4); 0 2 2
1316 2 special_nv = 1;
1317 }
1318 #endif
1319 #ifdef NV_INF
1320 185 ▶ if (!special_nv && nv == NV_INF) {
Branch: 2 branches
BranchTrueFalseTotal
if (!special_nv && nv == NV_INF) { 183 2 185
if (!special_nv && nv == NV_INF) { 2 181 183
1321 2 ▶ syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, ".inf", 4);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, ".inf", 4); 0 2 2
1322 2 special_nv = 1;
1323 }
1324 185 ▶ if (!special_nv && nv == -NV_INF) {
Branch: 2 branches
BranchTrueFalseTotal
if (!special_nv && nv == -NV_INF) { 181 4 185
if (!special_nv && nv == -NV_INF) { 2 179 181
1325 2 ▶ syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, "-.inf", 5);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), scalar_plain, 0, 0, 0, "-.inf", 5); 0 2 2
1326 2 special_nv = 1;
1327 }
1328 #endif
1329 }
1330 185 ▶ if (!special_nv)
Branch: 1 branch
BranchTrueFalseTotal
if (!special_nv) 179 6 185
1331 #endif
1332 {
1333 282 SV *sv2 = newSVsv(sv);
1334 STRLEN len;
1335 282 char *str = SvPV(sv2, len);
1336 282 ▶ if (SvIOK(sv) /* original SV was an int */
Branch: 2 branches
BranchTrueFalseTotal
if (SvIOK(sv) /* original SV was an int */ 163 16 179
if (SvIOK(sv) /* original SV was an int */ 103 0 103
1337 266 ▶ && syck_str_is_unquotable_integer(str, len)) /* small enough to safely round-trip */
Branch: 2 branches
BranchTrueFalseTotal
&& syck_str_is_unquotable_integer(str, len)) /* small enough to safely round-trip */ 161 2 163
&& syck_str_is_unquotable_integer(str, len)) /* small enough to safely round-trip */ 103 0 103
1338 {
1339 264 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_NUMBER, 0, 0, 0, str, len);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_NUMBER, 0, 0, 0, str, len); 1 160 161
1340 } else {
1341 18 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, str, len);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, str, len); 0 18 18
1342 }
1343 282 SvREFCNT_dec(sv2);
1344 }
1345 }
1346 else {
1347 3019 switch (ty) {
1348 1921 case SVt_PVAV: { /* array */
1349 1921 ▶ syck_emit_seq(e, OBJOF("array"), SEQ_NONE);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_seq(e, OBJOF("array"), SEQ_NONE); 8 1071 1079
1350 1921 e->indent = PERL_SYCK_INDENT_LEVEL;
1351  
1352 1921 *tag = '\0';
1353 1921 len = av_len((AV*)sv) + 1;
1354 4529 ▶ for (i = 0; i < len; i++) {
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; i < len; i++) { 1710 1079 2789
for (i = 0; i < len; i++) { 898 842 1740
1355 2608 SV** sav = av_fetch((AV*)sv, i, 0);
1356 2608 if (sav == NULL) {
1357 0 syck_emit_item( e, (st_data_t)(&PL_sv_undef) );
1358 }
1359 else {
1360 2608 syck_emit_item( e, (st_data_t)(*sav) );
1361 }
1362 }
1363 1921 syck_emit_end(e);
1364 1921 return;
1365 }
1366 656 case SVt_PVHV: { /* hash */
1367 656 HV *hv = (HV*)sv;
1368 HE *he;
1369 656 ▶ syck_emit_map(e, OBJOF("hash"), MAP_NONE);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_map(e, OBJOF("hash"), MAP_NONE); 20 574 594
1370 656 e->indent = PERL_SYCK_INDENT_LEVEL;
1371  
1372 656 *tag = '\0';
1373 656 hv_iterinit((HV*)sv);
1374  
1375 656 if (e->sort_keys) {
1376 593 AV *av = (AV*)sv_2mortal((SV*)newAV());
1377 #ifdef HV_ITERNEXT_WANTPLACEHOLDERS
1378 1436 ▶ while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) {
Branch: 2 branches
BranchTrueFalseTotal
while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) { 843 593 1436
while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) { 0 0 0
1379 #else
1380 while ((he = hv_iternext(hv)) != NULL) {
1381 #endif
1382 843 SV *key = hv_iterkeysv(he);
1383 843 av_store(av, AvFILLp(av)+1, key); /* av_push(), really */
1384 }
1385 593 len = av_len(av) + 1;
1386 593 STORE_HASH_SORT;
1387 1436 ▶ for (i = 0; i < len; i++) {
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; i < len; i++) { 843 593 1436
for (i = 0; i < len; i++) { 0 0 0
1388 843 SV *key = av_shift(av);
1389 843 HE *he = hv_fetch_ent(hv, key, 0, 0);
1390 843 ▶ SV *val = he ? HeVAL(he) : &PL_sv_undef;
Branch: 2 branches
BranchTrueFalseTotal
SV *val = he ? HeVAL(he) : &PL_sv_undef; 843 0 843
SV *val = he ? HeVAL(he) : &PL_sv_undef; 0 0 0
1391 843 ▶ if (val == NULL) { val = &PL_sv_undef; }
Branch: 2 branches
BranchTrueFalseTotal
if (val == NULL) { val = &PL_sv_undef; } 0 843 843
if (val == NULL) { val = &PL_sv_undef; } 0 0 0
1392 843 syck_emit_item( e, (st_data_t)key );
1393 843 syck_emit_item( e, (st_data_t)val );
1394 }
1395 }
1396 else {
1397 #ifdef HV_ITERNEXT_WANTPLACEHOLDERS
1398 152 ▶ while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) {
Branch: 2 branches
BranchTrueFalseTotal
while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) { 26 1 27
while ((he = hv_iternext_flags(hv, HV_ITERNEXT_WANTPLACEHOLDERS)) != NULL) { 63 62 125
1399 #else
1400 while ((he = hv_iternext(hv)) != NULL) {
1401 #endif
1402 89 SV *key = hv_iterkeysv(he);
1403 89 SV *val = hv_iterval(hv, he);
1404 89 syck_emit_item( e, (st_data_t)key );
1405 89 syck_emit_item( e, (st_data_t)val );
1406 }
1407 }
1408 /* reset the hash pointer */
1409 656 hv_iterinit(hv);
1410 656 syck_emit_end(e);
1411 656 return;
1412 }
1413 236 case SVt_PVCV: { /* code */
1414 #ifdef YAML_IS_JSON
1415 1 syck_emit_scalar(e, "str", scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH);
1416 #else
1417  
1418 /* This following code is mostly copypasted from Storable */
1419  
1420 #if PERL_VERSION < 8
1421 syck_emit_scalar(e, OBJOF("tag:!perl:code:"), SCALAR_QUOTED, 0, 0, 0, "{ \"DUMMY\" }", 11);
1422 #else
1423 235 ▶ if ( !dump_code ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( !dump_code ) { 3 232 235
1424 3 ▶ syck_emit_scalar(e, OBJOF("tag:!perl:code:"), SCALAR_QUOTED, 0, 0, 0, "{ \"DUMMY\" }", 11);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("tag:!perl:code:"), SCALAR_QUOTED, 0, 0, 0, "{ \"DUMMY\" }", 11); 2 1 3
1425 }
1426 else {
1427 232 dSP;
1428 int count, reallen;
1429 SV *text;
1430 232 CV *cv = (CV*)sv;
1431 232 SV *bdeparse = GvSV(gv_fetchpv(form("%s::DeparseObject", PACKAGE_NAME), TRUE, SVt_PV));
1432  
1433 232 ▶ if (!SvTRUE(bdeparse)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvTRUE(bdeparse)) { 0 232 232
1434 0 croak("B::Deparse initialization failed -- cannot dump code object");
1435 }
1436  
1437 232 ENTER;
1438 232 SAVETMPS;
1439  
1440 /*
1441 * call the coderef2text method
1442 */
1443  
1444 232 ▶ PUSHMARK(sp);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(sp); 0 232 232
1445 232 ▶ XPUSHs(bdeparse); /* XXX is this already mortal? */
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(bdeparse); /* XXX is this already mortal? */ 0 232 232
1446 232 ▶ XPUSHs(sv_2mortal(newRV_inc((SV*)cv)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newRV_inc((SV*)cv))); 0 232 232
1447 232 PUTBACK;
1448 232 count = call_method("coderef2text", G_SCALAR);
1449 232 SPAGAIN;
1450 232 ▶ if (count != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (count != 1) { 0 232 232
1451 0 croak("Unexpected return value from B::Deparse::coderef2text\n");
1452 }
1453  
1454 232 text = POPs;
1455 232 reallen = strlen(SvPV_nolen(text));
1456  
1457 /*
1458 * Empty code references or XS functions are deparsed as
1459 * "(prototype) ;" or ";".
1460 */
1461  
1462 464 ▶ if (reallen == 0 || *(SvPV_nolen(text)+reallen-1) == ';') {
Branch: 2 branches
BranchTrueFalseTotal
if (reallen == 0 || *(SvPV_nolen(text)+reallen-1) == ';') { 232 0 232
if (reallen == 0 || *(SvPV_nolen(text)+reallen-1) == ';') { 21 211 232
1463 21 croak("The result of B::Deparse::coderef2text was empty - maybe you're trying to serialize an XS function?\n");
1464 }
1465  
1466 /*
1467 * Now store the source code.
1468 */
1469  
1470 422 ▶ syck_emit_scalar(e, OBJOF("tag:!perl:code:"), SCALAR_UTF8, 0, 0, 0, SvPV_nolen(text), reallen);
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("tag:!perl:code:"), SCALAR_UTF8, 0, 0, 0, SvPV_nolen(text), reallen); 2 209 211
1471  
1472 211 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 211 0 211
1473 211 LEAVE;
1474  
1475 /* END Storable */
1476 }
1477 #endif
1478 #endif
1479 215 *tag = '\0';
1480 215 break;
1481 }
1482 200 case SVt_PVGV: /* glob (not a filehandle, a symbol table entry) */
1483 case SVt_PVFM: { /* format */
1484 /* XXX TODO XXX */
1485 400 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), sv_len(sv));
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), sv_len(sv)); 0 200 200
1486 200 break;
1487 }
1488 0 case SVt_PVIO: { /* filehandle */
1489 0 ▶ syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), sv_len(sv));
Branch: 1 branch
BranchTrueFalseTotal
syck_emit_scalar(e, OBJOF("str"), SCALAR_STRING, 0, 0, 0, SvPV_nolen(sv), sv_len(sv)); 0 0 0
1490 0 break;
1491 }
1492 6 default: {
1493 6 syck_emit_scalar(e, "str", scalar_plain, 0, 0, 0, NULL_LITERAL, NULL_LITERAL_LENGTH);
1494 }
1495 }
1496 }
1497 /* cleanup: */
1498 1263 *tag = '\0';
1499 #ifndef YAML_IS_JSON
1500 5321 ▶ if (ref_orig != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref_orig != NULL) { 64 5257 5321
1501 64 Safefree(ref_orig);
1502 64 bonus->cur_ref = NULL; /* already freed — prevent double-free in destructor */
1503 }
1504 #endif
1505 }
1506  
1507 /* Destructor for SAVEDESTRUCTOR_X: frees emitter and tag buffer on croak.
1508 * Registered after allocation so Perl's scope unwinding handles cleanup
1509 * even when a croak() longjmps past the normal return path.
1510 * Guarded because perl_syck.h is included twice (YAML and JSON modes). */
1511 #ifndef CLEANUP_EMITTER_BONUS_DEFINED
1512 #define CLEANUP_EMITTER_BONUS_DEFINED
1513 static void
1514 1528 cleanup_emitter_bonus(pTHX_ void *p) {
1515 1528 struct emitter_xtra *bonus = (struct emitter_xtra *)p;
1516 1528 ▶ if (bonus->cur_ref != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (bonus->cur_ref != NULL) { 0 1528 1528
1517 0 Safefree(bonus->cur_ref);
1518 0 bonus->cur_ref = NULL;
1519 }
1520 1528 ▶ if (bonus->emitter != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (bonus->emitter != NULL) { 70 1458 1528
1521 70 syck_free_emitter((SyckEmitter *)bonus->emitter);
1522 70 bonus->emitter = NULL;
1523 }
1524 1528 ▶ if (bonus->tag != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (bonus->tag != NULL) { 70 1458 1528
1525 70 Safefree(bonus->tag);
1526 70 bonus->tag = NULL;
1527 }
1528 1528 }
1529 #endif
1530  
1531 void
1532 #ifdef YAML_IS_JSON
1533 281 DumpJSONImpl
1534 #else
1535 1247 DumpYAMLImpl
1536 #endif
1537 (SV *sv, struct emitter_xtra *bonus, SyckOutputHandler output_handler) {
1538 SyckEmitter *emitter;
1539 1528 SV *headless = GvSV(gv_fetchpv(form("%s::Headless", PACKAGE_NAME), TRUE, SVt_PV));
1540 1528 SV *implicit_binary = GvSV(gv_fetchpv(form("%s::ImplicitBinary", PACKAGE_NAME), TRUE, SVt_PV));
1541 1528 SV *use_code = GvSV(gv_fetchpv(form("%s::UseCode", PACKAGE_NAME), TRUE, SVt_PV));
1542 1528 SV *dump_code = GvSV(gv_fetchpv(form("%s::DumpCode", PACKAGE_NAME), TRUE, SVt_PV));
1543 1528 SV *sortkeys = GvSV(gv_fetchpv(form("%s::SortKeys", PACKAGE_NAME), TRUE, SVt_PV));
1544 1528 SV *max_depth = GvSV(gv_fetchpv(form("%s::MaxDepth", PACKAGE_NAME), TRUE, SVt_PV));
1545 #ifdef YAML_IS_JSON
1546 281 SV *singlequote = GvSV(gv_fetchpv(form("%s::SingleQuote", PACKAGE_NAME), TRUE, SVt_PV));
1547 281 ▶ json_quote_char = (SvTRUE(singlequote) ? '\'' : '"' );
Branch: 1 branch
BranchTrueFalseTotal
json_quote_char = (SvTRUE(singlequote) ? '\'' : '"' ); 57 224 281
1548 281 ▶ json_quote_style = (SvTRUE(singlequote) ? scalar_2quote_1 : scalar_2quote );
Branch: 1 branch
BranchTrueFalseTotal
json_quote_style = (SvTRUE(singlequote) ? scalar_2quote_1 : scalar_2quote ); 57 224 281
1549 #else
1550 1247 SV *singlequote = GvSV(gv_fetchpv(form("%s::SingleQuote", PACKAGE_NAME), TRUE, SVt_PV));
1551 1247 yaml_quote_style = (SvTRUE(singlequote) ? scalar_1quote : scalar_none);
1552 #endif
1553  
1554 1528 ENTER; SAVETMPS;
1555  
1556 /* Initialize B::Deparse BEFORE allocating the emitter, so that if
1557 * eval_pv croaks (longjmp) we don't leak the SyckEmitter. */
1558 #ifndef YAML_IS_JSON
1559 1247 ▶ if (SvTRUE(use_code) || SvTRUE(dump_code)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(use_code) || SvTRUE(dump_code)) { 428 819 1247
if (SvTRUE(use_code) || SvTRUE(dump_code)) { 28 400 428
1560 847 SV *bdeparse = GvSV(gv_fetchpv(form("%s::DeparseObject", PACKAGE_NAME), TRUE, SVt_PV));
1561  
1562 847 ▶ if (!SvTRUE(bdeparse)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvTRUE(bdeparse)) { 5 842 847
1563 5 eval_pv(form(
1564 "local $@; require B::Deparse; $%s::DeparseObject = B::Deparse->new",
1565 PACKAGE_NAME
1566 ), 1);
1567 }
1568 }
1569 #endif
1570  
1571 1528 emitter = syck_new_emitter();
1572  
1573 1528 if (SvIOK(max_depth))
1574 282 emitter->max_depth = SvIV(max_depth);
1575 #ifdef YAML_IS_JSON
1576 else
1577 0 emitter->max_depth = json_max_depth;
1578 281 emitter->indent = PERL_SYCK_INDENT_LEVEL;
1579 281 emitter->json_mode = 1;
1580 #endif
1581  
1582 1528 emitter->headless = SvTRUE(headless);
1583 1528 emitter->sort_keys = SvTRUE(sortkeys);
1584 1528 emitter->anchor_format = "%d";
1585  
1586 1528 New(801, bonus->tag, 512, char);
1587 1528 bonus->tag_len = 512;
1588 1528 *(bonus->tag) = '\0';
1589 1528 ▶ bonus->dump_code = SvTRUE(use_code) || SvTRUE(dump_code);
Branch: 4 branches
BranchTrueFalseTotal
bonus->dump_code = SvTRUE(use_code) || SvTRUE(dump_code); 428 819 1247
bonus->dump_code = SvTRUE(use_code) || SvTRUE(dump_code); 28 400 428
bonus->dump_code = SvTRUE(use_code) || SvTRUE(dump_code); 281 0 281
bonus->dump_code = SvTRUE(use_code) || SvTRUE(dump_code); 0 281 281
1590 1528 bonus->implicit_binary = SvTRUE(implicit_binary);
1591 1528 bonus->emitter = emitter;
1592 1528 bonus->cur_ref = NULL;
1593 1528 emitter->bonus = bonus;
1594  
1595 /* Register destructor so croak() in callbacks (mark_emitter,
1596 * emitter_handler) won't leak the emitter or tag buffer. */
1597 1528 SAVEDESTRUCTOR_X(cleanup_emitter_bonus, bonus);
1598  
1599 1528 syck_emitter_handler( emitter, PERL_SYCK_EMITTER_HANDLER );
1600 1528 syck_output_handler( emitter, output_handler );
1601  
1602 1528 PERL_SYCK_MARK_EMITTER( emitter, sv );
1603  
1604 #ifdef YAML_IS_JSON
1605 235 st_free_table(emitter->markers);
1606 235 emitter->markers = st_init_numtable();
1607 #endif
1608  
1609 1479 syck_emit( emitter, (st_data_t)sv );
1610 1458 syck_emitter_flush( emitter, 0 );
1611  
1612 /* Normal path: clean up now and NULL the pointers so the
1613 * SAVEDESTRUCTOR_X callback (at LEAVE) becomes a no-op. */
1614 1458 syck_free_emitter( emitter );
1615 1458 bonus->emitter = NULL;
1616 1458 Safefree(bonus->tag);
1617 1458 bonus->tag = NULL;
1618  
1619 1458 ▶ FREETMPS; LEAVE;
Branch: 2 branches
BranchTrueFalseTotal
FREETMPS; LEAVE; 1077 146 1223
FREETMPS; LEAVE; 52 183 235
1620  
1621 1458 return;
1622 }
1623  
1624  
1625 SV*
1626 #ifdef YAML_IS_JSON
1627 268 DumpJSON
1628 #else
1629 1225 DumpYAML
1630 #endif
1631 (SV *sv) {
1632 1493 SV *implicit_unicode = GvSV(gv_fetchpv(form("%s::ImplicitUnicode", PACKAGE_NAME), TRUE, SVt_PV));
1633 struct emitter_xtra bonus;
1634 /* Mortalize so croak inside DumpImpl won't leak the SV.
1635 * SvREFCNT_inc before return counteracts the XS wrapper's sv_2mortal. */
1636 1493 SV *out = sv_2mortal(newSVpvn("", 0));
1637 1493 bonus.out.outsv = out;
1638 #ifdef YAML_IS_JSON
1639 268 DumpJSONImpl(sv, &bonus, perl_syck_output_handler_pv);
1640 222 ▶ if (SvCUR(out) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvCUR(out) > 0) { 222 0 222
1641 222 perl_json_postprocess(out);
1642 }
1643 #else
1644 1225 DumpYAMLImpl(sv, &bonus, perl_syck_output_handler_pv);
1645 #endif
1646 #ifdef SvUTF8_on
1647 1423 ▶ if (SvTRUE(implicit_unicode)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(implicit_unicode)) { 138 1063 1201
if (SvTRUE(implicit_unicode)) { 52 170 222
1648 190 SvUTF8_on(out);
1649 }
1650 #endif
1651 1423 ▶ SvREFCNT_inc_simple_void(out);
Branch: 2 branches
BranchTrueFalseTotal
SvREFCNT_inc_simple_void(out); 1201 0 1201
SvREFCNT_inc_simple_void(out); 222 0 222
1652 1423 return out;
1653 }
1654  
1655 int
1656 #ifdef YAML_IS_JSON
1657 6 DumpJSONFile
1658 #else
1659 11 DumpYAMLFile
1660 #endif
1661 (SV *sv, PerlIO *out) {
1662 struct emitter_xtra bonus;
1663 17 bonus.out.outio = out;
1664 17 bonus.ioerror = 0;
1665 #ifdef YAML_IS_JSON
1666 {
1667 /* Buffer into an SV so we can apply perl_json_postprocess(),
1668 * then write the postprocessed result to the file handle.
1669 * Mortalize buf so croak inside DumpJSONImpl won't leak it. */
1670 6 SV *buf = sv_2mortal(newSVpvn("", 0));
1671 STRLEN len;
1672 char *s;
1673 6 bonus.out.outsv = buf;
1674 6 DumpJSONImpl(sv, &bonus, perl_syck_output_handler_pv);
1675 6 ▶ if (SvCUR(buf) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvCUR(buf) > 0) { 6 0 6
1676 6 perl_json_postprocess(buf);
1677 }
1678 6 s = SvPV(buf, len);
1679 6 ▶ if (len > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (len > 0) { 6 0 6
1680 6 ▶ if (PerlIO_write(out, s, len) != (SSize_t)len) {
Branch: 1 branch
BranchTrueFalseTotal
if (PerlIO_write(out, s, len) != (SSize_t)len) { 0 6 6
1681 0 bonus.ioerror = errno;
1682 }
1683 }
1684 }
1685 #else
1686 11 DumpYAMLImpl(sv, &bonus, perl_syck_output_handler_io);
1687 #endif
1688 17 return bonus.ioerror;
1689 }
1690  
1691 int
1692 #ifdef YAML_IS_JSON
1693 7 DumpJSONInto
1694 #else
1695 11 DumpYAMLInto
1696 #endif
1697 (SV *sv, SV *out) {
1698 18 SV *implicit_unicode = GvSV(gv_fetchpv(form("%s::ImplicitUnicode", PACKAGE_NAME), TRUE, SVt_PV));
1699 struct emitter_xtra bonus;
1700 18 if (SvROK(out)) {
1701 18 out = SvRV(out);
1702 18 ▶ if (! SvPOK(out)) {
Branch: 2 branches
BranchTrueFalseTotal
if (! SvPOK(out)) { 6 5 11
if (! SvPOK(out)) { 5 2 7
1703 11 sv_setpv(out, "");
1704 }
1705 } else {
1706 0 return 0; /* perl wrapper should die for us */
1707 }
1708 18 bonus.out.outsv = out;
1709 #ifdef YAML_IS_JSON
1710 7 DumpJSONImpl(sv, &bonus, perl_syck_output_handler_mg);
1711 7 ▶ if (SvCUR(out) > 0) { /* XXX: needs to handle magic? */
Branch: 1 branch
BranchTrueFalseTotal
if (SvCUR(out) > 0) { /* XXX: needs to handle magic? */ 7 0 7
1712 7 perl_json_postprocess(out);
1713 }
1714 #else
1715 11 DumpYAMLImpl(sv, &bonus, perl_syck_output_handler_mg);
1716 #endif
1717 #ifdef SvUTF8_on
1718 18 ▶ if (SvTRUE(implicit_unicode)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(implicit_unicode)) { 0 11 11
if (SvTRUE(implicit_unicode)) { 0 7 7
1719 0 SvUTF8_on(out); /* XXX: needs to handle magic? */
1720 }
1721 #endif
1722 18 return 1;
1723 }
1724  
« syck_.c ↑ Summary perl_common.h »