| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "hunspell.hxx" |
|
2
|
|
|
|
|
|
|
#include "assert.h" |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
5
|
|
|
|
|
|
|
extern "C" { |
|
6
|
|
|
|
|
|
|
#endif |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
9
|
|
|
|
|
|
|
#include "perl.h" |
|
10
|
|
|
|
|
|
|
#include "XSUB.h" |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
#endif |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
using namespace std; |
|
19
|
|
|
|
|
|
|
/*using namespace Hunspell;*/ |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
|
static void * get_mortalspace ( size_t nbytes ) { |
|
22
|
|
|
|
|
|
|
SV * mortal; |
|
23
|
1
|
|
|
|
|
|
mortal = sv_2mortal( NEWSV(0, nbytes ) ); |
|
24
|
1
|
|
|
|
|
|
return (void *)SvPVX(mortal); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
MODULE = Text::Hunspell PACKAGE = Text::Hunspell |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Make sure that we have at least xsubpp version 1.922. |
|
32
|
|
|
|
|
|
|
REQUIRE: 1.922 |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Hunspell * |
|
35
|
|
|
|
|
|
|
Hunspell::new(aff,dic ) |
|
36
|
|
|
|
|
|
|
char *aff; |
|
37
|
|
|
|
|
|
|
char *dic; |
|
38
|
|
|
|
|
|
|
CODE: |
|
39
|
8
|
50
|
|
|
|
|
RETVAL = new Hunspell(aff, dic); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
OUTPUT: |
|
42
|
|
|
|
|
|
|
RETVAL |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
int |
|
45
|
|
|
|
|
|
|
Hunspell::delete(h) |
|
46
|
|
|
|
|
|
|
Hunspell *h; |
|
47
|
|
|
|
|
|
|
CODE: |
|
48
|
0
|
|
|
|
|
|
warn("Text::Hunspell::delete() is deprecated and no replacement is needed"); |
|
49
|
0
|
|
|
|
|
|
RETVAL = 1; |
|
50
|
|
|
|
|
|
|
OUTPUT: |
|
51
|
|
|
|
|
|
|
RETVAL |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
void |
|
54
|
|
|
|
|
|
|
Hunspell::DESTROY() |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
int |
|
57
|
|
|
|
|
|
|
Hunspell::add_dic(dic) |
|
58
|
|
|
|
|
|
|
char *dic; |
|
59
|
|
|
|
|
|
|
CODE: |
|
60
|
1
|
|
|
|
|
|
RETVAL = THIS->add_dic(dic); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
OUTPUT: |
|
63
|
|
|
|
|
|
|
RETVAL |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
int |
|
66
|
|
|
|
|
|
|
Hunspell::check(buf) |
|
67
|
|
|
|
|
|
|
char *buf; |
|
68
|
|
|
|
|
|
|
CODE: |
|
69
|
11
|
|
|
|
|
|
RETVAL = THIS->spell(buf); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
OUTPUT: |
|
72
|
|
|
|
|
|
|
RETVAL |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
void |
|
75
|
|
|
|
|
|
|
Hunspell::suggest(buf) |
|
76
|
|
|
|
|
|
|
char *buf; |
|
77
|
|
|
|
|
|
|
PREINIT: |
|
78
|
|
|
|
|
|
|
char **wlsti; |
|
79
|
|
|
|
|
|
|
int i, val; |
|
80
|
|
|
|
|
|
|
PPCODE: |
|
81
|
1
|
50
|
|
|
|
|
val = THIS->suggest(&wlsti, buf); |
|
82
|
4
|
100
|
|
|
|
|
for (int i = 0; i < val; i++) { |
|
83
|
3
|
50
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 ))); |
|
|
|
50
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
|
85
|
1
|
50
|
|
|
|
|
THIS->free_list(&wlsti, val); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
void |
|
88
|
|
|
|
|
|
|
Hunspell::analyze(buf) |
|
89
|
|
|
|
|
|
|
char *buf; |
|
90
|
|
|
|
|
|
|
PREINIT: |
|
91
|
|
|
|
|
|
|
char **wlsti; |
|
92
|
|
|
|
|
|
|
int i, val; |
|
93
|
|
|
|
|
|
|
PPCODE: |
|
94
|
1
|
50
|
|
|
|
|
val = THIS->analyze(&wlsti, buf); |
|
95
|
2
|
100
|
|
|
|
|
for (i = 0; i < val; i++) { |
|
96
|
1
|
50
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv(wlsti[i], 0))); |
|
|
|
50
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
|
98
|
1
|
50
|
|
|
|
|
THIS->free_list(&wlsti, val); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
void |
|
102
|
|
|
|
|
|
|
Hunspell::stem( buf) |
|
103
|
|
|
|
|
|
|
char *buf; |
|
104
|
|
|
|
|
|
|
PREINIT: |
|
105
|
|
|
|
|
|
|
char **wlsti; |
|
106
|
|
|
|
|
|
|
int i, val; |
|
107
|
|
|
|
|
|
|
PPCODE: |
|
108
|
0
|
0
|
|
|
|
|
val = THIS->stem(&wlsti, buf); |
|
109
|
0
|
0
|
|
|
|
|
for (int i = 0; i < val; i++) { |
|
110
|
0
|
0
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 ))); |
|
|
|
0
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
0
|
0
|
|
|
|
|
THIS->free_list(&wlsti, val); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
void |
|
116
|
|
|
|
|
|
|
Hunspell::generate( buf, sample) |
|
117
|
|
|
|
|
|
|
char *buf; |
|
118
|
|
|
|
|
|
|
char *sample; |
|
119
|
|
|
|
|
|
|
PREINIT: |
|
120
|
|
|
|
|
|
|
char **wlsti; |
|
121
|
|
|
|
|
|
|
int i, val; |
|
122
|
|
|
|
|
|
|
PPCODE: |
|
123
|
16
|
50
|
|
|
|
|
val = THIS->generate(&wlsti, buf, sample); |
|
124
|
32
|
100
|
|
|
|
|
for (int i = 0; i < val; i++) { |
|
125
|
16
|
50
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 ))); |
|
|
|
50
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
|
127
|
16
|
50
|
|
|
|
|
THIS->free_list(&wlsti, val); |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
void |
|
131
|
|
|
|
|
|
|
Hunspell::generate2( buf, avref) |
|
132
|
|
|
|
|
|
|
AV * avref; |
|
133
|
|
|
|
|
|
|
char *buf; |
|
134
|
|
|
|
|
|
|
PREINIT: |
|
135
|
|
|
|
|
|
|
char ** array; |
|
136
|
|
|
|
|
|
|
char **wlsti; |
|
137
|
|
|
|
|
|
|
int len; |
|
138
|
|
|
|
|
|
|
SV ** elem; |
|
139
|
|
|
|
|
|
|
int i, val; |
|
140
|
|
|
|
|
|
|
PPCODE: |
|
141
|
1
|
50
|
|
|
|
|
len = av_len(avref) + 1; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
/* First allocate some memory for the pointers */ |
|
144
|
1
|
50
|
|
|
|
|
array = (char **) get_mortalspace( len * sizeof( *array )); |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
/* Loop over each element copying pointers to the new array */ |
|
147
|
2
|
100
|
|
|
|
|
for (i=0; i
|
|
148
|
1
|
50
|
|
|
|
|
elem = av_fetch( avref, i, 0 ); |
|
149
|
1
|
50
|
|
|
|
|
array[i] = SvPV( *elem, PL_na ); |
|
|
|
0
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
1
|
50
|
|
|
|
|
val = THIS->generate(&wlsti, buf, array, len); |
|
153
|
|
|
|
|
|
|
|
|
154
|
2
|
100
|
|
|
|
|
for (int i = 0; i < val; i++) { |
|
155
|
1
|
50
|
|
|
|
|
PUSHs(sv_2mortal(newSVpv( wlsti[i] ,0 ))); |
|
|
|
50
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
} |
|
157
|
1
|
50
|
|
|
|
|
THIS->free_list(&wlsti, val); |
|
158
|
|
|
|
|
|
|
|