easyxs/easyxs_string.h

filter: Statementstmt 85.7% 6 / 7 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 69.2% 9 / 13 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« libwireguard.c ↑ Summary blib/lib/Linux/WireGuard.pm »
1 #ifndef EASYXS_STRING_H
2 #define EASYXS_STRING_H 1
3  
4 #include "init.h"
5  
6 2 static inline char* _easyxs_sv_to_str (pTHX_ SV* sv, U8 is_utf8) {
7 2 ▶ if (SvROK(sv)) _EASYXS_CROAK_STRINGIFY_REFERENCE(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv)) _EASYXS_CROAK_STRINGIFY_REFERENCE(sv); 0 2 2
8  
9 4 ▶ char *str = is_utf8 ? SvPVutf8_nolen(sv) : SvPVbyte_nolen(sv);
Branch: 1 branch
BranchTrueFalseTotal
char *str = is_utf8 ? SvPVutf8_nolen(sv) : SvPVbyte_nolen(sv); 0 2 2
10  
11 2 size_t len = strnlen(str, 1 + SvCUR(sv));
12 2 ▶ if (len != SvCUR(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (len != SvCUR(sv)) { 0 2 2
13 0 croak("Cannot convert scalar to C string (NUL byte detected, offset %" UVf ")", (UV) len);
14 }
15  
16 2 return str;
17 }
18  
19 /* ---------------------------------------------------------------------- */
20  
21 #define exs_SvPVbyte_nolen(sv) _easyxs_sv_to_str(aTHX_ sv, 0)
22 #define exs_SvPVutf8_nolen(sv) _easyxs_sv_to_str(aTHX_ sv, 1)
23  
24 #endif
« libwireguard.c ↑ Summary blib/lib/Linux/WireGuard.pm »