| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
2
|
|
|
|
|
|
|
#include "perl.h" |
|
3
|
|
|
|
|
|
|
#include "XSUB.h" |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "strip_html.h" |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
MODULE = HTML::Strip PACKAGE = HTML::Strip |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Stripper * |
|
12
|
|
|
|
|
|
|
_create() |
|
13
|
|
|
|
|
|
|
PREINIT: |
|
14
|
|
|
|
|
|
|
Stripper * stripper; |
|
15
|
|
|
|
|
|
|
CODE: |
|
16
|
18
|
|
|
|
|
|
Newx( stripper, 1, Stripper ); |
|
17
|
18
|
|
|
|
|
|
_reset( stripper ); |
|
18
|
18
|
|
|
|
|
|
RETVAL = stripper; |
|
19
|
|
|
|
|
|
|
OUTPUT: |
|
20
|
|
|
|
|
|
|
RETVAL |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
void |
|
23
|
|
|
|
|
|
|
_xs_destroy( stripper ) |
|
24
|
|
|
|
|
|
|
Stripper * stripper |
|
25
|
|
|
|
|
|
|
CODE: |
|
26
|
18
|
|
|
|
|
|
Safefree( stripper ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
SV * |
|
29
|
|
|
|
|
|
|
_strip_html( stripper, text ) |
|
30
|
|
|
|
|
|
|
Stripper * stripper |
|
31
|
|
|
|
|
|
|
SV * text |
|
32
|
|
|
|
|
|
|
PREINIT: |
|
33
|
41
|
50
|
|
|
|
|
char * raw = (char *)SvPV_nolen(text); |
|
34
|
|
|
|
|
|
|
char * clean; |
|
35
|
41
|
|
|
|
|
|
int size = strlen(raw)+1; |
|
36
|
|
|
|
|
|
|
INIT: |
|
37
|
41
|
|
|
|
|
|
Newx( clean, size+1, char); |
|
38
|
|
|
|
|
|
|
CODE: |
|
39
|
41
|
|
|
|
|
|
_strip_html( stripper, raw, clean, SvUTF8(text) ); |
|
40
|
41
|
|
|
|
|
|
RETVAL = newSVpv(clean, strlen(clean)); |
|
41
|
41
|
100
|
|
|
|
|
if( SvUTF8(text) ) |
|
42
|
3
|
|
|
|
|
|
SvUTF8_on(RETVAL); |
|
43
|
|
|
|
|
|
|
OUTPUT: |
|
44
|
|
|
|
|
|
|
RETVAL |
|
45
|
|
|
|
|
|
|
CLEANUP: |
|
46
|
41
|
|
|
|
|
|
Safefree( clean ); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
void |
|
49
|
|
|
|
|
|
|
_reset( stripper ) |
|
50
|
|
|
|
|
|
|
Stripper * stripper |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
void |
|
53
|
|
|
|
|
|
|
clear_striptags( stripper ) |
|
54
|
|
|
|
|
|
|
Stripper * stripper |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
void |
|
57
|
|
|
|
|
|
|
add_striptag( stripper, tag ) |
|
58
|
|
|
|
|
|
|
Stripper * stripper |
|
59
|
|
|
|
|
|
|
char * tag |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
void |
|
62
|
|
|
|
|
|
|
set_emit_spaces( stripper, emit ) |
|
63
|
|
|
|
|
|
|
Stripper * stripper |
|
64
|
|
|
|
|
|
|
int emit |
|
65
|
|
|
|
|
|
|
CODE: |
|
66
|
18
|
|
|
|
|
|
stripper->o_emit_spaces = emit; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
void |
|
69
|
|
|
|
|
|
|
set_emit_newlines( stripper, emit ) |
|
70
|
|
|
|
|
|
|
Stripper * stripper |
|
71
|
|
|
|
|
|
|
int emit |
|
72
|
|
|
|
|
|
|
CODE: |
|
73
|
18
|
|
|
|
|
|
stripper->o_emit_newlines = emit; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
void |
|
76
|
|
|
|
|
|
|
set_decode_entities( stripper, decode ) |
|
77
|
|
|
|
|
|
|
Stripper * stripper |
|
78
|
|
|
|
|
|
|
int decode |
|
79
|
|
|
|
|
|
|
CODE: |
|
80
|
18
|
|
|
|
|
|
stripper->o_decode_entities = decode; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
int |
|
83
|
|
|
|
|
|
|
decode_entities( stripper ) |
|
84
|
|
|
|
|
|
|
Stripper * stripper |
|
85
|
|
|
|
|
|
|
CODE: |
|
86
|
39
|
|
|
|
|
|
RETVAL = stripper->o_decode_entities; |
|
87
|
|
|
|
|
|
|
OUTPUT: |
|
88
|
|
|
|
|
|
|
RETVAL |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
void |
|
91
|
|
|
|
|
|
|
_set_striptags_ref( stripper, tagref ) |
|
92
|
|
|
|
|
|
|
Stripper * stripper |
|
93
|
|
|
|
|
|
|
SV * tagref |
|
94
|
|
|
|
|
|
|
PREINIT: |
|
95
|
|
|
|
|
|
|
AV * tags; |
|
96
|
20
|
|
|
|
|
|
I32 numtags = 0; |
|
97
|
|
|
|
|
|
|
int n; |
|
98
|
20
|
50
|
|
|
|
|
if( (SvROK(tagref)) && |
|
|
|
50
|
|
|
|
|
|
|
99
|
20
|
|
|
|
|
|
(SvTYPE(SvRV(tagref)) == SVt_PVAV) ) { |
|
100
|
20
|
|
|
|
|
|
tags = (AV *) SvRV(tagref); |
|
101
|
|
|
|
|
|
|
} else { |
|
102
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
20
|
|
|
|
|
|
numtags = av_len(tags); |
|
105
|
20
|
50
|
|
|
|
|
if( numtags < 0 ) { |
|
106
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
CODE: |
|
109
|
20
|
|
|
|
|
|
clear_striptags( stripper ); |
|
110
|
95
|
100
|
|
|
|
|
for (n = 0; n <= numtags; n++) { |
|
111
|
|
|
|
|
|
|
STRLEN l; |
|
112
|
75
|
50
|
|
|
|
|
char * tag = SvPV(*av_fetch(tags, n, 0), l); |
|
113
|
75
|
|
|
|
|
|
add_striptag( stripper, tag ); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
void |
|
117
|
|
|
|
|
|
|
set_auto_reset( stripper, value ) |
|
118
|
|
|
|
|
|
|
Stripper * stripper |
|
119
|
|
|
|
|
|
|
int value |
|
120
|
|
|
|
|
|
|
CODE: |
|
121
|
18
|
|
|
|
|
|
stripper->o_auto_reset = value; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
int |
|
124
|
|
|
|
|
|
|
auto_reset( stripper ) |
|
125
|
|
|
|
|
|
|
Stripper * stripper |
|
126
|
|
|
|
|
|
|
CODE: |
|
127
|
0
|
|
|
|
|
|
RETVAL = stripper->o_auto_reset; |
|
128
|
|
|
|
|
|
|
OUTPUT: |
|
129
|
|
|
|
|
|
|
RETVAL |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
void |
|
132
|
|
|
|
|
|
|
set_debug( stripper, value ) |
|
133
|
|
|
|
|
|
|
Stripper * stripper |
|
134
|
|
|
|
|
|
|
int value |
|
135
|
|
|
|
|
|
|
CODE: |
|
136
|
18
|
|
|
|
|
|
stripper->o_debug = value; |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
int |
|
139
|
|
|
|
|
|
|
debug( stripper ) |
|
140
|
|
|
|
|
|
|
Stripper * stripper |
|
141
|
|
|
|
|
|
|
CODE: |
|
142
|
0
|
|
|
|
|
|
RETVAL = stripper->o_debug; |
|
143
|
|
|
|
|
|
|
OUTPUT: |
|
144
|
|
|
|
|
|
|
RETVAL |