xs/internal.xs

filter: Statementstmt 95.8% 208 / 217 Branchbran 69.8% 109 / 156 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 84.9% 317 / 373 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/frx/frx_entity.h ↑ Summary include/frx/frx_obj.h »
1  
2 # Private accessors for the test suite. Underscored, so pod-coverage
3 # ignores them; kept, because the tests need them for the life of the dist.
4  
5 MODULE = File::Raw::XML PACKAGE = File::Raw::XML
6  
7 IV
8 _arena_selftest()
9 PREINIT:
10 frx_arena a;
11 frx_buf b;
12 void *first, *p;
13 size_t i;
14 1 ▶ int ok = 1;
Branch: 1 branch
BranchTrueFalseTotal
int ok = 1; 1 0 1
15 CODE:
16 1 frx_arena_init(&a);
17 1 frx_buf_init(&b);
18  
19 /* the first pointer is aligned and stays put across ten pages */
20 1 first = frx_arena_alloc(&a, 24);
21 1 ▶ if (!first || ((size_t)first & (FRX_ARENA_ALIGN - 1))) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
if (!first || ((size_t)first & (FRX_ARENA_ALIGN - 1))) ok = 0; 1 0 1
if (!first || ((size_t)first & (FRX_ARENA_ALIGN - 1))) ok = 0; 0 1 1
22 1 memset(first, 0xA5, 24);
23 641 ▶ for (i = 0; ok && i < 10 * (FRX_ARENA_PAGE / 1024); i++) {
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; ok && i < 10 * (FRX_ARENA_PAGE / 1024); i++) { 641 0 641
for (i = 0; ok && i < 10 * (FRX_ARENA_PAGE / 1024); i++) { 640 1 641
24 640 p = frx_arena_alloc(&a, 1000);
25 640 ▶ if (!p || ((size_t)p & (FRX_ARENA_ALIGN - 1))) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
if (!p || ((size_t)p & (FRX_ARENA_ALIGN - 1))) ok = 0; 640 0 640
if (!p || ((size_t)p & (FRX_ARENA_ALIGN - 1))) ok = 0; 0 640 640
26 }
27 1 ▶ if (ok && a.pages < 10) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
if (ok && a.pages < 10) ok = 0; 1 0 1
if (ok && a.pages < 10) ok = 0; 0 1 1
28 1 ▶ if (ok && ((unsigned char *)first)[0] != 0xA5) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
if (ok && ((unsigned char *)first)[0] != 0xA5) ok = 0; 1 0 1
if (ok && ((unsigned char *)first)[0] != 0xA5) ok = 0; 0 1 1
29 1 ▶ if (ok && ((unsigned char *)first)[23] != 0xA5) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
if (ok && ((unsigned char *)first)[23] != 0xA5) ok = 0; 1 0 1
if (ok && ((unsigned char *)first)[23] != 0xA5) ok = 0; 0 1 1
30  
31 /* an oversize allocation gets its own page */
32 1 ▶ if (ok) {
Branch: 1 branch
BranchTrueFalseTotal
if (ok) { 1 0 1
33 1 size_t before = a.pages;
34 1 p = frx_arena_alloc(&a, FRX_ARENA_BIG + 1);
35 1 ▶ if (!p || a.pages != before + 1) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
if (!p || a.pages != before + 1) ok = 0; 1 0 1
if (!p || a.pages != before + 1) ok = 0; 0 1 1
36 1 else memset(p, 0x5A, FRX_ARENA_BIG + 1);
37 }
38  
39 /* a string comes back NUL-terminated with its length */
40 1 ▶ if (ok) {
Branch: 1 branch
BranchTrueFalseTotal
if (ok) { 1 0 1
41 1 frx_str s = frx_arena_strndup(&a, "abc\0def", 7);
42 1 ▶ if (!s.p || s.len != 7 || s.p[7] != '\0' || memcmp(s.p, "abc\0def", 7)) ok = 0;
Branch: 4 branches
BranchTrueFalseTotal
if (!s.p || s.len != 7 || s.p[7] != '\0' || memcmp(s.p, "abc\0def", 7)) ok = 0; 1 0 1
if (!s.p || s.len != 7 || s.p[7] != '\0' || memcmp(s.p, "abc\0def", 7)) ok = 0; 1 0 1
if (!s.p || s.len != 7 || s.p[7] != '\0' || memcmp(s.p, "abc\0def", 7)) ok = 0; 1 0 1
if (!s.p || s.len != 7 || s.p[7] != '\0' || memcmp(s.p, "abc\0def", 7)) ok = 0; 0 1 1
43 }
44  
45 /* the buffer grows across its doubling boundaries and stays terminated */
46 100001 ▶ for (i = 0; ok && i < 100000; i++) frx_buf_append_ch(&b, (char)('a' + i % 26));
Branch: 2 branches
BranchTrueFalseTotal
for (i = 0; ok && i < 100000; i++) frx_buf_append_ch(&b, (char)('a' + i % 26)); 100001 0 100001
for (i = 0; ok && i < 100000; i++) frx_buf_append_ch(&b, (char)('a' + i % 26)); 100000 1 100001
47 1 frx_buf_append(&b, "!");
48 1 ▶ if (ok && (b.failed || b.len != 100001 || b.p[b.len] != '\0'
Branch: 4 branches
BranchTrueFalseTotal
if (ok && (b.failed || b.len != 100001 || b.p[b.len] != '\0' 1 0 1
if (ok && (b.failed || b.len != 100001 || b.p[b.len] != '\0' 1 0 1
if (ok && (b.failed || b.len != 100001 || b.p[b.len] != '\0' 1 0 1
if (ok && (b.failed || b.len != 100001 || b.p[b.len] != '\0' 1 0 1
49 1 ▶ || b.p[0] != 'a' || b.p[100000] != '!')) ok = 0;
Branch: 2 branches
BranchTrueFalseTotal
|| b.p[0] != 'a' || b.p[100000] != '!')) ok = 0; 1 0 1
|| b.p[0] != 'a' || b.p[100000] != '!')) ok = 0; 0 1 1
50  
51 1 frx_buf_free(&b);
52 1 frx_arena_free(&a);
53 1 ▶ if (ok && (a.head || a.big || a.pages)) ok = 0;
Branch: 4 branches
BranchTrueFalseTotal
if (ok && (a.head || a.big || a.pages)) ok = 0; 1 0 1
if (ok && (a.head || a.big || a.pages)) ok = 0; 1 0 1
if (ok && (a.head || a.big || a.pages)) ok = 0; 1 0 1
if (ok && (a.head || a.big || a.pages)) ok = 0; 0 1 1
54 1 ▶ RETVAL = ok;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ok; 0 1 1
55 OUTPUT:
56 RETVAL
57  
58 SV *
59 _lex(bytes, ...)
60 SV *bytes
61 PREINIT:
62 STRLEN len;
63 const char *in;
64 frx_opts o;
65 frx_arena arena;
66 frx_lex l;
67 frx_tok t;
68 AV *rows;
69 char msg[512];
70 size_t n;
71 CODE:
72 /* _lex($bytes, $max_bytes = 0): every token as
73 * [kind, offset, name, value-or-attrs], or a croak in the one
74 * message shape. The arena is freed on both paths. */
75 124 in = SvPVbyte(bytes, len);
76 124 ▶ o.max_bytes = items > 1 ? (size_t)SvUV(ST(1)) : 0;
Branch: 1 branch
BranchTrueFalseTotal
o.max_bytes = items > 1 ? (size_t)SvUV(ST(1)) : 0; 3 121 124
77 124 o.max_depth = 0;
78 124 o.id_attrs = NULL;
79 124 o.n_id_attrs = 0;
80 124 frx_arena_init(&arena);
81 124 rows = newAV();
82 124 ▶ if (frx_lex_init(&l, (const unsigned char *)in, (size_t)len, &o, FRX_PROFILE_STRICT, &arena)) {
Branch: 1 branch
BranchTrueFalseTotal
if (frx_lex_init(&l, (const unsigned char *)in, (size_t)len, &o, FRX_PROFILE_STRICT, &arena)) { 112 12 124
83 258 ▶ while (frx_lex_next(&l, &t)) {
Branch: 1 branch
BranchTrueFalseTotal
while (frx_lex_next(&l, &t)) { 146 112 258
84 146 AV *row = newAV();
85 146 const char *kind = "?";
86 146 switch (t.kind) {
87 68 case FRX_TOK_START: kind = "start"; break;
88 25 case FRX_TOK_END: kind = "end"; break;
89 22 case FRX_TOK_EMPTY: kind = "empty"; break;
90 20 ▶ case FRX_TOK_TEXT: kind = t.cdata ? "cdata" : "text"; break;
Branch: 1 branch
BranchTrueFalseTotal
case FRX_TOK_TEXT: kind = t.cdata ? "cdata" : "text"; break; 5 15 20
91 5 case FRX_TOK_COMMENT: kind = "comment"; break;
92 6 case FRX_TOK_PI: kind = "pi"; break;
93 }
94 146 av_push(row, newSVpv(kind, 0));
95 146 av_push(row, newSVuv((UV)t.offset));
96 146 ▶ av_push(row, t.name.p ? newSVpvn(t.name.p, t.name.len) : newSV(0));
Branch: 1 branch
BranchTrueFalseTotal
av_push(row, t.name.p ? newSVpvn(t.name.p, t.name.len) : newSV(0)); 121 25 146
97 236 ▶ if (t.kind == FRX_TOK_START || t.kind == FRX_TOK_EMPTY) {
Branch: 2 branches
BranchTrueFalseTotal
if (t.kind == FRX_TOK_START || t.kind == FRX_TOK_EMPTY) { 78 68 146
if (t.kind == FRX_TOK_START || t.kind == FRX_TOK_EMPTY) { 22 56 78
98 90 AV *attrs = newAV();
99 int i;
100 101 ▶ for (i = 0; i < t.n_attrs; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < t.n_attrs; i++) { 11 90 101
101 11 AV *pair = newAV();
102 11 av_push(pair, newSVpvn(t.attrs[i].name.p, t.attrs[i].name.len));
103 11 av_push(pair, newSVpvn(t.attrs[i].value.p, t.attrs[i].value.len));
104 11 av_push(attrs, newRV_noinc((SV *)pair));
105 }
106 90 av_push(row, newRV_noinc((SV *)attrs));
107 } else {
108 56 ▶ av_push(row, t.value.p ? newSVpvn(t.value.p, t.value.len) : newSV(0));
Branch: 1 branch
BranchTrueFalseTotal
av_push(row, t.value.p ? newSVpvn(t.value.p, t.value.len) : newSV(0)); 31 25 56
109 }
110 146 av_push(rows, newRV_noinc((SV *)row));
111 }
112 }
113 124 ▶ if (l.failed) {
Branch: 1 branch
BranchTrueFalseTotal
if (l.failed) { 81 43 124
114 81 n = frx_err_format(&l.err, in, (size_t)len, msg, sizeof msg);
115 81 frx_lex_free(&l);
116 81 frx_arena_free(&arena);
117 81 SvREFCNT_dec((SV *)rows);
118 81 croak("%.*s", (int)n, msg);
119 }
120 43 frx_lex_free(&l);
121 43 frx_arena_free(&arena);
122 43 RETVAL = newRV_noinc((SV *)rows);
123 OUTPUT:
124 RETVAL
125  
126 SV *
127 _dump(bytes, ...)
128 SV *bytes
129 PREINIT:
130 STRLEN len;
131 const char *in;
132 frx_opts o;
133 frx_err e;
134 frx_doc *d;
135 62 const char **names = NULL;
136 62 int n_names = 0;
137 char msg[512];
138 size_t n;
139 AV *root_row;
140 /* an explicit stack of (node, children AV): no recursion, rule 2 */
141 62 frx_dump_frame *stack = NULL;
142 62 int sp = 0, cap = 0;
143 CODE:
144 /* _dump($bytes, $max_depth = 0, \@id_attrs = []): the tree as
145 * nested arrayrefs, or a croak in the one message shape.
146 * element: ['element', ns, prefix, local, [[ns,prefix,local,value]...],
147 * [[prefix,uri]...], [children...], ns_ptr]
148 * text: ['text', value] comment: ['comment', value]
149 * pi: ['pi', target, data]
150 * document: ['document', [children...]] */
151 62 in = SvPVbyte(bytes, len);
152 62 o.max_bytes = 0;
153 62 ▶ o.max_depth = items > 1 ? (int)SvIV(ST(1)) : 0;
Branch: 1 branch
BranchTrueFalseTotal
o.max_depth = items > 1 ? (int)SvIV(ST(1)) : 0; 11 51 62
154 62 o.id_attrs = NULL;
155 62 o.n_id_attrs = 0;
156 62 ▶ if (items > 2 && SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVAV) {
Branch: 3 branches
BranchTrueFalseTotal
if (items > 2 && SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVAV) { 6 56 62
if (items > 2 && SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVAV) { 6 0 6
if (items > 2 && SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVAV) { 6 0 6
157 6 AV *av = (AV *)SvRV(ST(2));
158 int i;
159 6 n_names = (int)(av_len(av) + 1);
160 6 ▶ if (n_names) {
Branch: 1 branch
BranchTrueFalseTotal
if (n_names) { 5 1 6
161 5 Newx(names, n_names, const char *);
162 5 SAVEFREEPV(names);
163 11 ▶ for (i = 0; i < n_names; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n_names; i++) { 6 5 11
164 6 SV **e = av_fetch(av, i, 0);
165 12 ▶ names[i] = e ? SvPV_nolen(*e) : "";
Branch: 1 branch
BranchTrueFalseTotal
names[i] = e ? SvPV_nolen(*e) : ""; 6 0 6
166 }
167 5 o.id_attrs = names;
168 5 o.n_id_attrs = n_names;
169 }
170 }
171 62 d = frx_parse_doc(in, (size_t)len, &o, &e);
172 62 ▶ if (!d) {
Branch: 1 branch
BranchTrueFalseTotal
if (!d) { 31 31 62
173 31 n = frx_err_format(&e, in, (size_t)len, msg, sizeof msg);
174 31 croak("%.*s", (int)n, msg);
175 }
176 {
177 31 const frx_node *cur = d->document;
178 31 AV *doc_children = newAV();
179 31 root_row = newAV();
180 31 av_push(root_row, newSVpvs("document"));
181 31 av_push(root_row, newRV_noinc((SV *)doc_children));
182 31 cap = 16;
183 31 Newx(stack, cap, frx_dump_frame);
184 31 stack[0].node = cur; stack[0].children = doc_children; sp = 1;
185 31 cur = cur->first_child;
186 100654 ▶ while (cur) {
Branch: 1 branch
BranchTrueFalseTotal
while (cur) { 100623 31 100654
187 100623 AV *row = newAV();
188 100623 AV *kids = NULL;
189 /* pop to the row's parent */
190 200632 ▶ while (sp > 0 && stack[sp - 1].node != cur->parent) sp--;
Branch: 2 branches
BranchTrueFalseTotal
while (sp > 0 && stack[sp - 1].node != cur->parent) sp--; 200632 0 200632
while (sp > 0 && stack[sp - 1].node != cur->parent) sp--; 100009 100623 200632
191 100623 switch (cur->kind) {
192 100607 case FRX_ELEMENT: {
193 100607 AV *attrs = newAV(), *decls = newAV();
194 int i;
195 100607 kids = newAV();
196 100607 av_push(row, newSVpvs("element"));
197 100607 av_push(row, newSVpvn(cur->ns.p, cur->ns.len));
198 100607 av_push(row, newSVpvn(cur->prefix.p, cur->prefix.len));
199 100607 av_push(row, newSVpvn(cur->local.p, cur->local.len));
200 110624 ▶ for (i = 0; i < cur->n_attrs; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < cur->n_attrs; i++) { 10017 100607 110624
201 10017 AV *a = newAV();
202 10017 av_push(a, newSVpvn(cur->attrs[i].ns.p, cur->attrs[i].ns.len));
203 10017 av_push(a, newSVpvn(cur->attrs[i].prefix.p, cur->attrs[i].prefix.len));
204 10017 av_push(a, newSVpvn(cur->attrs[i].local.p, cur->attrs[i].local.len));
205 10017 av_push(a, newSVpvn(cur->attrs[i].value.p, cur->attrs[i].value.len));
206 10017 av_push(attrs, newRV_noinc((SV *)a));
207 }
208 100625 ▶ for (i = 0; i < cur->n_decls; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < cur->n_decls; i++) { 18 100607 100625
209 18 AV *a = newAV();
210 18 av_push(a, newSVpvn(cur->decls[i].prefix.p, cur->decls[i].prefix.len));
211 18 av_push(a, newSVpvn(cur->decls[i].uri.p, cur->decls[i].uri.len));
212 18 av_push(decls, newRV_noinc((SV *)a));
213 }
214 100607 av_push(row, newRV_noinc((SV *)attrs));
215 100607 av_push(row, newRV_noinc((SV *)decls));
216 100607 av_push(row, newRV_noinc((SV *)kids));
217 100607 av_push(row, newSViv(PTR2IV(cur->ns.p)));
218 100607 break;
219 }
220 11 case FRX_TEXT:
221 11 av_push(row, newSVpvs("text"));
222 11 av_push(row, newSVpvn(cur->value.p, cur->value.len));
223 11 break;
224 3 case FRX_COMMENT:
225 3 av_push(row, newSVpvs("comment"));
226 3 av_push(row, newSVpvn(cur->value.p, cur->value.len));
227 3 break;
228 2 case FRX_PI:
229 2 av_push(row, newSVpvs("pi"));
230 2 av_push(row, newSVpvn(cur->local.p, cur->local.len));
231 2 av_push(row, newSVpvn(cur->value.p, cur->value.len));
232 2 break;
233 0 default:
234 0 av_push(row, newSVpvs("?"));
235 0 break;
236 }
237 100623 av_push(stack[sp - 1].children, newRV_noinc((SV *)row));
238 100623 ▶ if (kids) {
Branch: 1 branch
BranchTrueFalseTotal
if (kids) { 100607 16 100623
239 100607 ▶ if (sp == cap) { cap *= 2; Renew(stack, cap, frx_dump_frame); }
Branch: 1 branch
BranchTrueFalseTotal
if (sp == cap) { cap *= 2; Renew(stack, cap, frx_dump_frame); } 10 100597 100607
240 100607 stack[sp].node = cur; stack[sp].children = kids; sp++;
241 }
242 100623 cur = frx_walk_next(cur, d->document);
243 }
244 31 Safefree(stack);
245 }
246 31 frx_doc_free(d);
247 31 RETVAL = newRV_noinc((SV *)root_row);
248 OUTPUT:
249 RETVAL
250  
251 SV *
252 _by_id(bytes, id_attrs, attr, value)
253 SV *bytes
254 SV *id_attrs
255 const char *attr
256 SV *value
257 PREINIT:
258 STRLEN len, vlen;
259 const char *in, *v;
260 frx_opts o;
261 frx_err e;
262 frx_doc *d;
263 12 const char **names = NULL;
264 12 ▶ int n_names = 0, i;
Branch: 1 branch
BranchTrueFalseTotal
int n_names = 0, i; 12 0 12
265 const frx_node *hit;
266 char msg[512];
267 size_t n;
268 CODE:
269 /* _by_id($bytes, \@id_attrs, $attr, $value): [qname, offset] or undef */
270 12 ▶ in = SvPVbyte(bytes, len);
Branch: 1 branch
BranchTrueFalseTotal
in = SvPVbyte(bytes, len); 12 0 12
271 12 v = SvPVbyte(value, vlen);
272 12 o.max_bytes = 0; o.max_depth = 0; o.id_attrs = NULL; o.n_id_attrs = 0;
273 12 ▶ if (SvROK(id_attrs) && SvTYPE(SvRV(id_attrs)) == SVt_PVAV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(id_attrs) && SvTYPE(SvRV(id_attrs)) == SVt_PVAV) { 12 0 12
if (SvROK(id_attrs) && SvTYPE(SvRV(id_attrs)) == SVt_PVAV) { 12 0 12
274 12 AV *av = (AV *)SvRV(id_attrs);
275 12 n_names = (int)(av_len(av) + 1);
276 12 ▶ if (n_names) {
Branch: 1 branch
BranchTrueFalseTotal
if (n_names) { 11 1 12
277 11 Newx(names, n_names, const char *);
278 11 SAVEFREEPV(names);
279 23 ▶ for (i = 0; i < n_names; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n_names; i++) { 12 11 23
280 12 SV **el = av_fetch(av, i, 0);
281 24 ▶ names[i] = el ? SvPV_nolen(*el) : "";
Branch: 1 branch
BranchTrueFalseTotal
names[i] = el ? SvPV_nolen(*el) : ""; 12 0 12
282 }
283 11 o.id_attrs = names; o.n_id_attrs = n_names;
284 }
285 }
286 12 d = frx_parse_doc(in, (size_t)len, &o, &e);
287 12 ▶ if (!d) {
Branch: 1 branch
BranchTrueFalseTotal
if (!d) { 0 12 12
288 0 n = frx_err_format(&e, in, (size_t)len, msg, sizeof msg);
289 0 croak("%.*s", (int)n, msg);
290 }
291 12 hit = frx_by_id(d, attr, v, (size_t)vlen);
292 12 ▶ if (hit) {
Branch: 1 branch
BranchTrueFalseTotal
if (hit) { 7 5 12
293 7 AV *row = newAV();
294 7 av_push(row, newSVpvn(hit->qname.p, hit->qname.len));
295 7 av_push(row, newSVuv((UV)hit->offset));
296 7 RETVAL = newRV_noinc((SV *)row);
297 } else {
298 5 RETVAL = newSV(0);
299 }
300 12 frx_doc_free(d);
301 OUTPUT:
302 RETVAL
303  
304 SV *
305 _walk(bytes, ns, local)
306 SV *bytes
307 SV *ns
308 const char *local
309 PREINIT:
310 STRLEN len;
311 const char *in, *nsp;
312 frx_err e;
313 frx_doc *d;
314 const frx_node *c;
315 HV *out;
316 AV *found, *desc;
317 frx_buf text;
318 char msg[512];
319 size_t n;
320 CODE:
321 /* _walk($bytes, $ns, $local): { find => [qnames of the root's direct
322 * children matching], descendants => [every descendant element's
323 * qname in document order], text => the root's text }. ns undef is
324 * any namespace, '' is none: the ABI's NULL versus "". */
325 5 in = SvPVbyte(bytes, len);
326 8 ▶ nsp = SvOK(ns) ? SvPV_nolen(ns) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
nsp = SvOK(ns) ? SvPV_nolen(ns) : NULL; 3 2 5
327 5 d = frx_parse_doc(in, (size_t)len, NULL, &e);
328 5 ▶ if (!d) {
Branch: 1 branch
BranchTrueFalseTotal
if (!d) { 0 5 5
329 0 n = frx_err_format(&e, in, (size_t)len, msg, sizeof msg);
330 0 croak("%.*s", (int)n, msg);
331 }
332 5 out = newHV();
333 5 found = newAV();
334 5 desc = newAV();
335 10 ▶ for (c = frx_find(d->root, nsp, local, NULL); c; c = frx_find(d->root, nsp, local, c))
Branch: 1 branch
BranchTrueFalseTotal
for (c = frx_find(d->root, nsp, local, NULL); c; c = frx_find(d->root, nsp, local, c)) 5 5 10
336 5 av_push(found, newSVpvn(c->qname.p, c->qname.len));
337 293 ▶ for (c = d->root->first_child; c; c = frx_walk_next(c, d->root))
Branch: 1 branch
BranchTrueFalseTotal
for (c = d->root->first_child; c; c = frx_walk_next(c, d->root)) 288 5 293
338 288 ▶ if (c->kind == FRX_ELEMENT) av_push(desc, newSVpvn(c->qname.p, c->qname.len));
Branch: 1 branch
BranchTrueFalseTotal
if (c->kind == FRX_ELEMENT) av_push(desc, newSVpvn(c->qname.p, c->qname.len)); 275 13 288
339 5 frx_buf_init(&text);
340 5 frx_text(d->root, &text);
341 {
342 /* attr => the root's attribute value for (ns, local), or undef */
343 5 const frx_str *v = frx_attr_value(d->root, nsp, local);
344 5 ▶ (void)hv_stores(out, "attr", v ? newSVpvn(v->p, v->len) : newSV(0));
Branch: 1 branch
BranchTrueFalseTotal
(void)hv_stores(out, "attr", v ? newSVpvn(v->p, v->len) : newSV(0)); 3 2 5
345 }
346 5 (void)hv_stores(out, "find", newRV_noinc((SV *)found));
347 5 (void)hv_stores(out, "descendants", newRV_noinc((SV *)desc));
348 5 ▶ (void)hv_stores(out, "text", newSVpvn(text.p ? text.p : "", text.len));
Branch: 1 branch
BranchTrueFalseTotal
(void)hv_stores(out, "text", newSVpvn(text.p ? text.p : "", text.len)); 5 0 5
349 5 (void)hv_stores(out, "n_ids", newSViv(d->n_ids));
350 5 frx_buf_free(&text);
351 5 frx_doc_free(d);
352 5 RETVAL = newRV_noinc((SV *)out);
353 OUTPUT:
354 RETVAL
355  
356 SV *
357 _join_base(base, ref)
358 SV *base
359 SV *ref
360 PREINIT:
361 STRLEN blen, rlen;
362 const char *b, *r;
363 frx_buf out;
364 CODE:
365 /* join-URI-References(base, ref), Canonical XML 1.1 section 2.4 */
366 16 ▶ b = SvPVbyte(base, blen);
Branch: 1 branch
BranchTrueFalseTotal
b = SvPVbyte(base, blen); 16 0 16
367 16 r = SvPVbyte(ref, rlen);
368 16 frx_buf_init(&out);
369 16 ▶ if (!frx_join_base(&out, b, (size_t)blen, r, (size_t)rlen)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!frx_join_base(&out, b, (size_t)blen, r, (size_t)rlen)) { 0 16 16
370 0 frx_buf_free(&out);
371 0 croak("File::Raw::XML: _join_base: out of memory");
372 }
373 16 ▶ RETVAL = newSVpvn(out.p ? out.p : "", out.len);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = newSVpvn(out.p ? out.p : "", out.len); 16 0 16
374 16 frx_buf_free(&out);
375 OUTPUT:
376 RETVAL
377  
378 SV *
379 _err_format(what, offset, bytes)
380 const char *what
381 UV offset
382 SV *bytes
383 PREINIT:
384 STRLEN len;
385 const char *in;
386 char out[512];
387 frx_err e;
388 size_t n;
389 CODE:
390 3 in = SvPVbyte(bytes, len);
391 3 frx_err_set(&e, FRX_E_SYNTAX, (size_t)offset, what);
392 3 n = frx_err_format(&e, in, (size_t)len, out, sizeof out);
393 3 RETVAL = newSVpvn(out, n);
394 OUTPUT:
395 RETVAL
« include/frx/frx_entity.h ↑ Summary include/frx/frx_obj.h »