scan_raw.c

filter: Statementstmt 69.8% 44 / 63 Branchbran 39.4% 15 / 38 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 58.4% 59 / 101 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« scan_search_request.c ↑ Summary pack_add_request.c »
1 #include "scan.h"
2  
3 static int
4 11 peek_raw_notag(const char **src, const char *max, SV *sv) {
5 const char *s;
6 STRLEN len;
7 11 ▶ if (peek_length(src, max, &len)) {
Branch: 1 branch
BranchTrueFalseTotal
if (peek_length(src, max, &len)) { 11 0 11
8 11 ▶ if (max - *src >= len) {
Branch: 1 branch
BranchTrueFalseTotal
if (max - *src >= len) { 11 0 11
9 11 sv_setpvn(sv, *src, len);
10 11 *src += len;
11 11 return 1;
12 }
13 }
14 0 return 0;
15 }
16  
17 int
18 1 peek_raw_utf8_notag(const char **src, const char *max, SV *sv) {
19 1 ▶ if (peek_raw_notag(src, max, sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (peek_raw_notag(src, max, sv)) { 1 0 1
20 1 ▶ if (!sv_utf8_decode(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_utf8_decode(sv)) 0 1 1
21 0 croak("scan_raw_utf8: invalid UTF8 data received");
22 1 return 1;
23 }
24 0 return 0;
25 }
26 int
27 0 peek_raw(const char **src, const char *max, U8 *type, U32 *tag, SV *sv) {
28 0 return (peek_tag(src, max, type, tag) &&
29 0 peek_raw_notag(src, max, sv));
30 }
31  
32 void
33 180 scan_raw_notag(const char **src, const char *max, SV *sv) {
34 const char *s;
35 STRLEN len;
36 180 scan_length(src, max, &len);
37 180 ▶ if (len > max - *src)
Branch: 1 branch
BranchTrueFalseTotal
if (len > max - *src) 0 180 180
38 0 croak("scan_raw_notag: packet too short");
39 180 sv_setpvn(sv, *src, len);
40 180 *src += len;
41 180 }
42  
43 void
44 8 scan_raw_utf8_notag(const char **src, const char *max, SV *sv) {
45 8 scan_raw_notag(src, max, sv);
46 8 ▶ if (!sv_utf8_decode(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_utf8_decode(sv)) 0 8 8
47 0 croak("scan_raw_utf8_notag: invalid UTF8 data received");
48 8 }
49  
50 void
51 8 scan_raw(const char **src, const char *max, U8 *type, U32* tag, SV *sv) {
52 8 scan_tag(src, max, type, tag);
53 8 scan_raw_notag(src, max, sv);
54 8 }
55  
56 void
57 2 scan_raw_utf8(const char **src, const char *max,
58 U8 *type, U32* tag, SV *sv) {
59 2 scan_raw(src, max, type, tag, sv);
60 2 ▶ if (!sv_utf8_decode(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_utf8_decode(sv)) 0 2 2
61 0 croak("scan_raw_utf8: invalid UTF8 data received");
62 2 }
63  
64 void
65 0 scan_raw_with_small_tt(const char **src, const char *max, U8 tt, SV *sv) {
66 0 ▶ scan_small_tag_with_tt(src, max, tt);
Branch: 2 branches
BranchTrueFalseTotal
scan_small_tag_with_tt(src, max, tt); 0 0 0
scan_small_tag_with_tt(src, max, tt); 0 0 0
67 0 scan_raw_notag(src, max, sv);
68 0 }
69  
70 void
71 146 scan_raw_utf8_with_small_tt(const char **src, const char *max, U8 tt, SV *sv) {
72 146 ▶ scan_small_tag_with_tt(src, max, tt);
Branch: 2 branches
BranchTrueFalseTotal
scan_small_tag_with_tt(src, max, tt); 146 0 146
scan_small_tag_with_tt(src, max, tt); 146 0 146
73 146 scan_raw_notag(src, max, sv);
74 146 ▶ if (!sv_utf8_decode(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_utf8_decode(sv)) 0 146 146
75 0 croak("scan_raw_utf8: invalid UTF8 data received");
76 146 }
77  
78 int
79 0 peek_raw_with_small_tt(const char **src, const char *max, U8 tt, SV *sv) {
80 0 ▶ return (peek_small_tag_with_tt(src, max, tt) &&
Branch: 3 branches
BranchTrueFalseTotal
return (peek_small_tag_with_tt(src, max, tt) && 0 0 0
return (peek_small_tag_with_tt(src, max, tt) && 0 0 0
return (peek_small_tag_with_tt(src, max, tt) && 0 0 0
81 0 peek_raw_notag(src, max, sv));
82 }
83  
84 int
85 10 peek_raw_utf8_with_small_tt(const char **src, const char *max, U8 tt, SV *sv) {
86 20 ▶ if (peek_small_tag_with_tt(src, max, tt) &&
Branch: 2 branches
BranchTrueFalseTotal
if (peek_small_tag_with_tt(src, max, tt) && 10 0 10
if (peek_small_tag_with_tt(src, max, tt) && 0 10 10
87 10 peek_raw_notag(src, max, sv)) {
88 10 ▶ if (!sv_utf8_decode(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_utf8_decode(sv)) 0 10 10
89 0 croak("scan_raw_utf8: invalid UTF8 data received");
90 10 return 1;
91 }
92 0 return 0;
93 }
94  
95 void
96 4 scan_array_of_raw_utf8_with_small_tt(const char **src, const char *max, U8 tt, AV *av) {
97 16 ▶ while (*src < max) {
Branch: 1 branch
BranchTrueFalseTotal
while (*src < max) { 12 4 16
98 12 SV *sv = newSV(0);
99 12 av_push(av, sv);
100 12 scan_raw_utf8_with_small_tt(src, max, tt, sv);
101 }
102 4 }
« scan_search_request.c ↑ Summary pack_add_request.c »