Preparation.xs

filter: Statementstmt 87.5% 35 / 40 Branchbran 67.3% 31 / 46 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 76.7% 66 / 86 SCAR 0
CC
0
Cov
0%
CRAP 0
« precis_preparation.c ↑ Summary
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;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ix; 4557 52 4609
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;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ix; 278 44 322
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 ▶ if (SvOK(string))
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(string)) 4611 2 4613
54 4611 buf = SvPV(string, buflen);
55 else
56 2 XSRETURN_EMPTY;
57  
58 4611 ▶ switch (stringclass) {
Branch: 1 branch
BranchTrueFalseTotal
switch (stringclass) { 4611 0 4611
59 4611 case 0:
60 case PRECIS_FREE_FORM_CLASS:
61 case PRECIS_IDENTIFIER_CLASS:
62 4611 break;
63 0 default:
64 0 XSRETURN_EMPTY;
65 }
66  
67 4611 ▶ if (unicode_version < 0 || 0xFF < unicode_version)
Branch: 2 branches
BranchTrueFalseTotal
if (unicode_version < 0 || 0xFF < unicode_version) 4611 0 4611
if (unicode_version < 0 || 0xFF < unicode_version) 35 4576 4611
68 35 XSRETURN_EMPTY;
69  
70 4576 switch (GIMME_V) {
71 4 case G_SCALAR:
72 4 retval = precis_prepare((U8 *)buf, buflen, stringclass,
73 unicode_version, NULL, NULL, NULL, NULL);
74 4 ▶ if (retval != PRECIS_PVALID)
Branch: 1 branch
BranchTrueFalseTotal
if (retval != PRECIS_PVALID) 0 4 4
75 0 XSRETURN_EMPTY;
76 4 ▶ XPUSHs(sv_2mortal(newSViv(1)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(1))); 0 4 4
77 4 XSRETURN(1);
78  
79 4572 case G_ARRAY:
80 4572 retval = precis_prepare((U8 *)buf, buflen, stringclass,
81 unicode_version, &err, &errlen, &idx, &cp);
82 4572 ▶ XPUSHs(sv_2mortal(newSVpv("result", 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv("result", 0))); 0 4572 4572
83 4572 ▶ XPUSHs(sv_2mortal(newSViv(retval)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(retval))); 0 4572 4572
84 4572 ▶ XPUSHs(sv_2mortal(newSVpv("offset", 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv("offset", 0))); 0 4572 4572
85 4572 ▶ if (SvUTF8(string))
Branch: 1 branch
BranchTrueFalseTotal
if (SvUTF8(string)) 2152 2420 4572
86 2152 ▶ XPUSHs(sv_2mortal(newSViv(idx)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(idx))); 0 2152 2152
87 else
88 2420 ▶ XPUSHs(sv_2mortal(newSViv(err - (U8 *)buf)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(err - (U8 *)buf))); 0 2420 2420
89 4572 ▶ if (retval == PRECIS_PVALID || errlen == 0)
Branch: 2 branches
BranchTrueFalseTotal
if (retval == PRECIS_PVALID || errlen == 0) 4407 165 4572
if (retval == PRECIS_PVALID || errlen == 0) 52 4355 4407
90 217 XSRETURN(4);
91  
92 4355 ▶ XPUSHs(sv_2mortal(newSVpv("length", 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv("length", 0))); 0 4355 4355
93 4355 ▶ if (SvUTF8(string))
Branch: 1 branch
BranchTrueFalseTotal
if (SvUTF8(string)) 2115 2240 4355
94 2115 ▶ XPUSHs(sv_2mortal(newSViv(1)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(1))); 0 2115 2115
95 else
96 2240 ▶ XPUSHs(sv_2mortal(newSViv(errlen)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(errlen))); 0 2240 2240
97 4355 ▶ XPUSHs(sv_2mortal(newSVpv("ord", 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv("ord", 0))); 0 4355 4355
98 4355 ▶ XPUSHs(sv_2mortal(newSViv(cp)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSViv(cp))); 0 4355 4355
99 4355 XSRETURN(8);
100  
101 0 default:
102 0 XSRETURN_EMPTY;
103 }
104  
105 void
106 __utf8_on(string)
107 SV *string
108 PROTOTYPE: $
109 PPCODE:
110 2150 ▶ if (SvOK(string))
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(string)) 2150 0 2150
111 2150 SvUTF8_on(string);
112  
« precis_preparation.c ↑ Summary