File Coverage

easyxs/easyxs_string.h
Criterion Covered Total %
statement 0 7 0.0
branch 0 10 0.0
condition n/a
subroutine n/a
pod n/a
total 0 17 0.0


line stmt bran cond sub pod time code
1             #ifndef EASYXS_STRING_H
2             #define EASYXS_STRING_H 1
3              
4             #include "init.h"
5              
6 0           static inline char* _easyxs_sv_to_str (pTHX_ SV* sv, U8 is_utf8) {
7 0 0         if (SvROK(sv)) _EASYXS_CROAK_STRINGIFY_REFERENCE(sv);
8              
9 0 0         char *str = is_utf8 ? SvPVutf8_nolen(sv) : SvPVbyte_nolen(sv);
    0          
    0          
10              
11 0           size_t len = strnlen(str, 1 + SvCUR(sv));
12 0 0         if (len != SvCUR(sv)) {
13 0           croak("Cannot convert scalar to C string (NUL byte detected, offset %" UVf ")", (UV) len);
14             }
15              
16 0           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