line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "ppport.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include "precis_preparation.h" |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
/* for Win32 with Visual Studio (MSVC) */ |
10
|
|
|
|
|
|
|
#ifdef _MSC_VER |
11
|
|
|
|
|
|
|
# define strcasecmp _stricmp |
12
|
|
|
|
|
|
|
#endif /* _MSC_VER */ |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
MODULE = Unicode::Precis::Preparation PACKAGE = Unicode::Precis::Preparation |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
int |
17
|
|
|
|
|
|
|
_classname() |
18
|
|
|
|
|
|
|
ALIAS: |
19
|
|
|
|
|
|
|
ValidUTF8 = 0 |
20
|
|
|
|
|
|
|
FreeFormClass = PRECIS_FREE_FORM_CLASS |
21
|
|
|
|
|
|
|
IdentifierClass = PRECIS_IDENTIFIER_CLASS |
22
|
|
|
|
|
|
|
CODE: |
23
|
4609
|
|
|
|
|
|
RETVAL = ix; |
24
|
|
|
|
|
|
|
OUTPUT: |
25
|
|
|
|
|
|
|
RETVAL |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
int |
28
|
|
|
|
|
|
|
_propname() |
29
|
|
|
|
|
|
|
ALIAS: |
30
|
|
|
|
|
|
|
UNASSIGNED = PRECIS_UNASSIGNED |
31
|
|
|
|
|
|
|
PVALID = PRECIS_PVALID |
32
|
|
|
|
|
|
|
CONTEXTJ = PRECIS_CONTEXTJ |
33
|
|
|
|
|
|
|
CONTEXTO = PRECIS_CONTEXTO |
34
|
|
|
|
|
|
|
DISALLOWED = PRECIS_DISALLOWED |
35
|
|
|
|
|
|
|
CODE: |
36
|
322
|
|
|
|
|
|
RETVAL = ix; |
37
|
|
|
|
|
|
|
OUTPUT: |
38
|
|
|
|
|
|
|
RETVAL |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
void |
41
|
|
|
|
|
|
|
_prepare(string, stringclass = 0, unicode_version = 0) |
42
|
|
|
|
|
|
|
SV *string |
43
|
|
|
|
|
|
|
int stringclass |
44
|
|
|
|
|
|
|
int unicode_version |
45
|
|
|
|
|
|
|
PROTOTYPE: $;$$ |
46
|
|
|
|
|
|
|
PREINIT: |
47
|
|
|
|
|
|
|
char *buf; |
48
|
|
|
|
|
|
|
U8 *err; |
49
|
|
|
|
|
|
|
STRLEN buflen, errlen, idx; |
50
|
|
|
|
|
|
|
int retval; |
51
|
|
|
|
|
|
|
U32 cp; |
52
|
|
|
|
|
|
|
PPCODE: |
53
|
4613
|
100
|
|
|
|
|
if (SvOK(string)) |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
54
|
4611
|
50
|
|
|
|
|
buf = SvPV(string, buflen); |
55
|
|
|
|
|
|
|
else |
56
|
2
|
|
|
|
|
|
XSRETURN_EMPTY; |
57
|
|
|
|
|
|
|
|
58
|
4611
|
50
|
|
|
|
|
switch (stringclass) { |
59
|
|
|
|
|
|
|
case 0: |
60
|
|
|
|
|
|
|
case PRECIS_FREE_FORM_CLASS: |
61
|
|
|
|
|
|
|
case PRECIS_IDENTIFIER_CLASS: |
62
|
4611
|
|
|
|
|
|
break; |
63
|
|
|
|
|
|
|
default: |
64
|
0
|
|
|
|
|
|
XSRETURN_EMPTY; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
4611
|
50
|
|
|
|
|
if (unicode_version < 0 || 0xFF < unicode_version) |
|
|
50
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
XSRETURN_EMPTY; |
69
|
|
|
|
|
|
|
|
70
|
4611
|
50
|
|
|
|
|
switch (GIMME_V) { |
71
|
|
|
|
|
|
|
case G_SCALAR: |
72
|
17
|
|
|
|
|
|
retval = precis_prepare((U8 *)buf, buflen, stringclass, |
73
|
|
|
|
|
|
|
unicode_version, NULL, NULL, NULL, NULL); |
74
|
17
|
100
|
|
|
|
|
if (retval != PRECIS_PVALID) |
75
|
7
|
|
|
|
|
|
XSRETURN_EMPTY; |
76
|
10
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv(1))); |
77
|
10
|
|
|
|
|
|
XSRETURN(1); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
case G_ARRAY: |
80
|
4594
|
|
|
|
|
|
retval = precis_prepare((U8 *)buf, buflen, stringclass, |
81
|
|
|
|
|
|
|
unicode_version, &err, &errlen, &idx, &cp); |
82
|
4594
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSVpv("result", 0))); |
83
|
4594
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv(retval))); |
84
|
4594
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSVpv("offset", 0))); |
85
|
4594
|
100
|
|
|
|
|
if (SvUTF8(string)) |
86
|
2163
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv(idx))); |
87
|
|
|
|
|
|
|
else |
88
|
2431
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv(err - (U8 *)buf))); |
89
|
4594
|
100
|
|
|
|
|
if (retval == PRECIS_PVALID || errlen == 0) |
|
|
100
|
|
|
|
|
|
90
|
225
|
|
|
|
|
|
XSRETURN(4); |
91
|
|
|
|
|
|
|
|
92
|
4369
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSVpv("length", 0))); |
93
|
4369
|
100
|
|
|
|
|
if (SvUTF8(string)) |
94
|
2122
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv(1))); |
95
|
|
|
|
|
|
|
else |
96
|
2247
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv(errlen))); |
97
|
4369
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSVpv("ord", 0))); |
98
|
4369
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSViv(cp))); |
99
|
4369
|
|
|
|
|
|
XSRETURN(8); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
default: |
102
|
4613
|
|
|
|
|
|
XSRETURN_EMPTY; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
void |
106
|
|
|
|
|
|
|
__utf8_on(string) |
107
|
|
|
|
|
|
|
SV *string |
108
|
|
|
|
|
|
|
PROTOTYPE: $ |
109
|
|
|
|
|
|
|
PPCODE: |
110
|
2150
|
50
|
|
|
|
|
if (SvOK(string)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
111
|
2150
|
|
|
|
|
|
SvUTF8_on(string); |
112
|
|
|
|
|
|
|
|