File Coverage

lib/Escape/Houdini.xs
Criterion Covered Total %
statement 20 20 100.0
branch 42 60 70.0
condition n/a
subroutine n/a
pod n/a
total 62 80 77.5


line stmt bran cond sub pod time code
1             #include "EXTERN.h"
2             #include "perl.h"
3             #include "XSUB.h"
4             #include
5              
6             #define WRAPPER(name) \
7             SV *_##name(SV *input){ \
8             gh_buf buffer = GH_BUF_INIT; \
9             SV *result; \
10             STRLEN slen; \
11             char *src_string; \
12             \
13             if( !SvPOK(input) && !SvNOK(input) && !SvIOK(input) ) {\
14             croak( #name "() argument not a string"); \
15             } \
16             \
17             src_string = SvPV(input, slen); \
18             \
19             if( !houdini_##name( &buffer, src_string, slen ) ) { \
20             return newSVsv(input); \
21             } \
22             \
23             result = newSVpvn( buffer.ptr, buffer.size ); \
24             gh_buf_free(&buffer); \
25             SvUTF8_on(result); \
26             \
27             return result; \
28             }
29              
30 15 100         WRAPPER(escape_html)
    100          
    100          
31 13 100         WRAPPER(unescape_html)
    100          
    100          
32 6 50         WRAPPER(escape_xml)
    50          
    50          
33 8 50         WRAPPER(escape_url)
    50          
    50          
34 8 50         WRAPPER(escape_uri)
    50          
    100          
35 8 50         WRAPPER(unescape_url)
    50          
    100          
36 8 50         WRAPPER(unescape_uri)
    50          
    100          
37 8 50         WRAPPER(escape_js)
    50          
    100          
38 8 50         WRAPPER(unescape_js)
    50          
    100          
39 8 50         WRAPPER(escape_href)
    50          
    100          
40              
41             MODULE = Escape::Houdini PACKAGE = Escape::Houdini
42              
43             SV *
44             escape_xml(str)
45             SV *str;
46             CODE:
47 3           RETVAL = _escape_xml(str);
48             OUTPUT:
49             RETVAL
50              
51             SV *
52             escape_html(str)
53             SV *str;
54             CODE:
55 8           RETVAL = _escape_html(str);
56             OUTPUT:
57             RETVAL
58              
59             SV *
60             unescape_html(str)
61             SV *str;
62             CODE:
63 7           RETVAL = _unescape_html(str);
64             OUTPUT:
65             RETVAL
66              
67             SV *
68             escape_uri(str)
69             SV *str;
70             CODE:
71 4           RETVAL = _escape_uri(str);
72             OUTPUT:
73             RETVAL
74              
75             SV *
76             escape_url(str)
77             SV *str;
78             CODE:
79 4           RETVAL = _escape_url(str);
80             OUTPUT:
81             RETVAL
82              
83             SV *
84             escape_href(str)
85             SV *str;
86             CODE:
87 4           RETVAL = _escape_href(str);
88             OUTPUT:
89             RETVAL
90              
91             SV *
92             unescape_uri(str)
93             SV *str;
94             CODE:
95 4           RETVAL = _unescape_uri(str);
96             OUTPUT:
97             RETVAL
98              
99             SV *
100             unescape_url(str)
101             SV *str;
102             CODE:
103 4           RETVAL = _unescape_url(str);
104             OUTPUT:
105             RETVAL
106              
107             SV *
108             escape_js(str)
109             SV *str;
110             CODE:
111 4           RETVAL = _escape_js(str);
112             OUTPUT:
113             RETVAL
114              
115             SV *
116             unescape_js(str)
117             SV *str;
118             CODE:
119 4           RETVAL = _unescape_js(str);
120             OUTPUT:
121             RETVAL