MapUTF.xs

filter: Statementstmt 92.5% 137 / 148 Branchbran 85.1% 281 / 330 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 87.4% 418 / 478 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« scmuni.h ↑ Summary blib/lib/ShiftJIS/CP932/MapUTF.pm »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 #include "scmuni.h"
6  
7 #include "fmcp932.h"
8 #include "tocp932.h"
9  
10 #define PkgName "ShiftJIS::CP932::MapUTF"
11  
12 #define Is_CP932_LED(i) (0x81<=(i) && (i)<=0x9F || 0xE0<=(i) && (i)<=0xFC)
13 #define Is_CP932_TRL(i) (0x40<=(i) && (i)<=0x7E || 0x80<=(i) && (i)<=0xFC)
14 #define Is_CP932_EUDC(i) (0xF0<=(i) && (i)<=0xF9)
15 #define Is_CP932_UDSB(i) ((i)==0x80 || (i)==0xA0 || 0xFD<=(i) && (i)<=0xFF)
16 #define Is_CP932_SNG(i) (0x00<=(i) && (i)<=0x80 || 0xA0<=(i) && (i)<=0xDF \
17 || 0xFD<=(i) && (i)<=0xFF)
18  
19 #define CP932_UDSB2PUA(i) ((i) == 0x80 ? 0x80 : (i) == 0xA0 ? 0xF8F0 \
20 : (i) + 0xF8F0 - 0xFC)
21  
22 #define Is_CP932_PUAe(uv) (0xE000 <= (uv) && (uv) <= 0xE757)
23 #define Is_CP932_PUAs(uv) ((uv)==0x80 || 0xF8F0 <= (uv) && (uv) <= 0xF8F3)
24 #define Is_CP932_L1FB(uv) ((uv)==0x3094 || 0xA0 <= (uv) && (uv) <= 0xFF)
25  
26 #define CP932_PUA_BASE (0xE000)
27 #define CP932_PUA2UDSB(uv) ((uv) == 0x80 ? 0x80 : (uv) == 0xF8F0 ? 0xA0 \
28 : (uv) - 0xF8F0 + 0xFC)
29 #define CP932_FB2MB(uv) ((uv) == 0x3094 ? 0x8394 \
30 : fb_latin1_to_cp932[0x7f & ((uv) - 0xA0)])
31  
32  
33 #define STMT_ASSIGN_CVREF_AND_SRC(func_name) \
34 cvref = NULL; \
35 if (SvROK(ST(0))) { \
36 if (SvTYPE(SvRV(ST(0))) == SVt_PVCV) \
37 cvref = SvRV(ST(0)); \
38 else \
39 croak("RV other than CODEREF " \
40 "cannot be used in %s", func_name); \
41 } \
42 src = cvref \
43 ? (1 < items) ? ST(1) : &PL_sv_undef \
44 : ST(0); \
45 mod = cvref \
46 ? (2 < items) ? ST(2) : &PL_sv_no \
47 : (1 < items) ? ST(1) : &PL_sv_no;
48  
49  
50 #define STMT_ASSIGN_LENDST(maxlen) \
51 s = (U8*)SvPV(src,srclen); \
52 e = s + srclen; \
53 dstlen = srclen * maxlen + 1; \
54 dst = sv_2mortal(newSV(dstlen)); \
55 (void)SvPOK_only(dst);
56  
57  
58 #define STMT_GET_MBLEN \
59 mblen = Is_CP932_LED(*(p)) && 2 <= (e - p) \
60 ? (!mod_t || Is_CP932_TRL((p)[1])) ? 2 : 0 \
61 : Is_CP932_SNG(*(p)) ? 1 : 0;
62  
63  
64 #define STMT_GET_UV_FROM_MB \
65 if (mod_g && Is_CP932_EUDC(*(p)) && \
66 Is_CP932_TRL((p)[1]) ) { \
67 uv = 0xE000 + 188 * (*(p) - 0xF0) + \
68 (p)[1] - ((p)[1] > 0x7E ? 0x41 : 0x40); \
69 } \
70 else if (mod_s && Is_CP932_UDSB(*(p))) { \
71 uv = (UV) CP932_UDSB2PUA(*(p)); \
72 } \
73 else { \
74 lb = fmcp932_tbl[*p]; \
75 uv = lb.tbl ? lb.tbl[p[1]] : lb.sbc; \
76 }
77  
78  
79 /* Perl 5.6.1 ? */
80 #ifndef uvuni_to_utf8
81 #define uvuni_to_utf8 uv_to_utf8
82 #endif /* uvuni_to_utf8 */
83  
84 /* Perl 5.6.1 ? */
85 #ifndef utf8n_to_uvuni
86 #define utf8n_to_uvuni utf8_to_uv
87 #endif /* utf8n_to_uvuni */
88  
89 static void
90 108019 sv_cat_retcvref (SV *dst, SV *cv, SV *sv, bool isbyte)
91 {
92 108019 dSP;
93 int count;
94 108019 ENTER;
95 108019 SAVETMPS;
96 108019 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 108019 108019
97 108019 ▶ if (isbyte)
Branch: 1 branch
BranchTrueFalseTotal
if (isbyte) 90 107929 108019
98 90 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 90 90
99 108019 ▶ XPUSHs(sv_2mortal(sv));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(sv)); 0 108019 108019
100 108019 PUTBACK;
101 108019 count = call_sv(cv, (G_EVAL|G_SCALAR));
102 108019 SPAGAIN;
103 108019 ▶ if (SvTRUE(ERRSV) || count != 1) {
Branch: 3 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV) || count != 1) { 108019 0 108019
if (SvTRUE(ERRSV) || count != 1) { 108019 0 108019
if (SvTRUE(ERRSV) || count != 1) { 0 108019 108019
104 0 croak("died in XS, " PkgName "\n");
105 }
106 108019 sv_catsv(dst,POPs);
107 108019 PUTBACK;
108 108019 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 108019 0 108019
109 108019 LEAVE;
110 108019 }
111  
112 static char* funcname_to[] = {
113 "cp932_to_unicode",
114 "cp932_to_utf8",
115 "cp932_to_utf16le",
116 "cp932_to_utf16be",
117 "cp932_to_utf32le",
118 "cp932_to_utf32be",
119 };
120  
121 static char* funcname_fm[] = {
122 "unicode_to_cp932",
123 "utf8_to_cp932",
124 "utf16le_to_cp932",
125 "utf16be_to_cp932",
126 "utf32le_to_cp932",
127 "utf32be_to_cp932",
128 "utf16_to_cp932",
129 "utf32_to_cp932"
130 };
131  
132 static STRLEN maxlen_to[] = {
133 MaxLenToUni,
134 MaxLenToU8,
135 MaxLenToU16,
136 MaxLenToU16,
137 MaxLenToU32,
138 MaxLenToU32,
139 };
140  
141 static STRLEN maxlen_fm[] = {
142 MaxLenFmUni,
143 MaxLenFmU8,
144 MaxLenFmU16,
145 MaxLenFmU16,
146 MaxLenFmU32,
147 MaxLenFmU32,
148 MaxLenFmU16,
149 MaxLenFmU32,
150 };
151  
152 static U8* (*app_uv_in[])(U8*, UV) = {
153 NULL,
154 app_in_utf8,
155 app_in_utf16le,
156 app_in_utf16be,
157 app_in_utf32le,
158 app_in_utf32be,
159 };
160  
161 static UV (*ord_uv_in[])(U8 *, STRLEN, STRLEN *) = {
162 NULL,
163 ord_in_utf8,
164 ord_in_utf16le,
165 ord_in_utf16be,
166 ord_in_utf32le,
167 ord_in_utf32be,
168 ord_in_utf16be, /* w/o BOM*/
169 ord_in_utf32be, /* w/o BOM*/
170 };
171  
172  
173 MODULE = ShiftJIS::CP932::MapUTF PACKAGE = ShiftJIS::CP932::MapUTF
174  
175 PROTOTYPES: DISABLE
176  
177 void
178 cp932_to_unicode(...)
179 ALIAS:
180 cp932_to_utf8 = 1
181 cp932_to_utf16le = 2
182 cp932_to_utf16be = 3
183 cp932_to_utf32le = 4
184 cp932_to_utf32be = 5
185 PREINIT:
186 SV *src, *dst, *cvref, *mod;
187 STRLEN srclen, dstlen, modlen, mblen, ulen;
188 U8 *s, *e, *p, *d, *m, *m_e, uni[UTF8_MAXLEN + 1];
189 UV uv;
190 struct leading lb;
191 U8* (*app_uv)(U8*, UV);
192 bool mod_g, mod_s, mod_t;
193 PPCODE:
194 672 ▶ STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix])
Branch: 7 branches
BranchTrueFalseTotal
STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix]) 300 372 672
STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix]) 300 0 300
STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix]) 300 372 672
STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix]) 300 0 300
STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix]) 300 372 672
STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix]) 168 132 300
STMT_ASSIGN_CVREF_AND_SRC(funcname_to[ix]) 240 132 372
195 672 ▶ if (SvUTF8(src)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvUTF8(src)) { 6 666 672
196 6 src = sv_mortalcopy(src);
197 6 sv_utf8_downgrade(src, 0);
198 }
199 672 STMT_ASSIGN_LENDST(maxlen_to[ix])
200 672 ▶ if (ix == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (ix == 0) 112 560 672
201 112 SvUTF8_on(dst);
202  
203 672 m = (U8*)SvPV(mod, modlen);
204 888 ▶ for (p = m, m_e = m + modlen; p < m_e; p++) {
Branch: 1 branch
BranchTrueFalseTotal
for (p = m, m_e = m + modlen; p < m_e; p++) { 216 672 888
205 216 ▶ if (*p == 'g' || *p == 's' || *p == 't')
Branch: 3 branches
BranchTrueFalseTotal
if (*p == 'g' || *p == 's' || *p == 't') 120 96 216
if (*p == 'g' || *p == 's' || *p == 't') 54 66 120
if (*p == 'g' || *p == 's' || *p == 't') 54 0 54
206 216 continue;
207 0 croak("Unknown option in %s: '%c'", funcname_to[ix], *p);
208 }
209 672 mod_g = memchr((void*)m, 'g', modlen) != NULL;
210 672 mod_s = memchr((void*)m, 's', modlen) != NULL;
211 672 mod_t = memchr((void*)m, 't', modlen) != NULL;
212  
213 672 app_uv = app_uv_in[ix];
214  
215 672 ▶ if (cvref) {
Branch: 1 branch
BranchTrueFalseTotal
if (cvref) { 300 372 672
216 6822 ▶ for (p = s; p < e; p += mblen) {
Branch: 1 branch
BranchTrueFalseTotal
for (p = s; p < e; p += mblen) { 6522 300 6822
217 6522 ▶ STMT_GET_MBLEN
Branch: 14 branches
BranchTrueFalseTotal
STMT_GET_MBLEN 6372 150 6522
STMT_GET_MBLEN 162 6210 6372
STMT_GET_MBLEN 144 168 312
STMT_GET_MBLEN 108 36 144
STMT_GET_MBLEN 6282 36 6318
STMT_GET_MBLEN 36 6246 6282
STMT_GET_MBLEN 24 12 36
STMT_GET_MBLEN 24 0 24
STMT_GET_MBLEN 24 12 36
STMT_GET_MBLEN 18 6 24
STMT_GET_MBLEN 90 150 240
STMT_GET_MBLEN 66 24 90
STMT_GET_MBLEN 48 18 66
STMT_GET_MBLEN 36 36 72
218  
219 6522 ▶ if (!mblen) {
Branch: 1 branch
BranchTrueFalseTotal
if (!mblen) { 54 6468 6522
220 54 sv_cat_retcvref(dst, cvref, newSVuv((UV)*p), TRUE);
221 54 p++;
222 54 continue;
223 }
224  
225 6468 ▶ STMT_GET_UV_FROM_MB
Branch: 15 branches
BranchTrueFalseTotal
STMT_GET_UV_FROM_MB 54 6414 6468
STMT_GET_UV_FROM_MB 54 0 54
STMT_GET_UV_FROM_MB 48 6 54
STMT_GET_UV_FROM_MB 36 12 48
STMT_GET_UV_FROM_MB 36 0 36
STMT_GET_UV_FROM_MB 24 24 48
STMT_GET_UV_FROM_MB 6 18 24
STMT_GET_UV_FROM_MB 6 0 6
STMT_GET_UV_FROM_MB 48 6414 6462
STMT_GET_UV_FROM_MB 48 0 48
STMT_GET_UV_FROM_MB 42 6 48
STMT_GET_UV_FROM_MB 18 24 42
STMT_GET_UV_FROM_MB 24 0 24
STMT_GET_UV_FROM_MB 18 6 24
STMT_GET_UV_FROM_MB 6198 240 6438
226  
227 6468 ▶ if (uv || !*p) {
Branch: 2 branches
BranchTrueFalseTotal
if (uv || !*p) { 6186 282 6468
if (uv || !*p) { 36 6150 6186
228 265 ulen = ix ? app_uv(uni, uv) - uni
229 583 ▶ : uvuni_to_utf8(uni, uv) - uni;
Branch: 1 branch
BranchTrueFalseTotal
: uvuni_to_utf8(uni, uv) - uni; 265 53 318
230 318 sv_catpvn(dst, (char*)uni, ulen);
231 } else
232 6150 sv_cat_retcvref(dst, cvref, newSVpvn((char*)p, mblen), FALSE);
233 }
234 }
235 else {
236 372 d = (U8*)SvPVX(dst);
237 30996 ▶ for (p = s; p < e; p += mblen) {
Branch: 1 branch
BranchTrueFalseTotal
for (p = s; p < e; p += mblen) { 30624 372 30996
238 30624 ▶ STMT_GET_MBLEN
Branch: 14 branches
BranchTrueFalseTotal
STMT_GET_MBLEN 30504 120 30624
STMT_GET_MBLEN 30300 204 30504
STMT_GET_MBLEN 282 30138 30420
STMT_GET_MBLEN 228 54 282
STMT_GET_MBLEN 396 36 432
STMT_GET_MBLEN 78 318 396
STMT_GET_MBLEN 66 12 78
STMT_GET_MBLEN 48 18 66
STMT_GET_MBLEN 36 24 60
STMT_GET_MBLEN 18 18 36
STMT_GET_MBLEN 30108 120 30228
STMT_GET_MBLEN 30084 24 30108
STMT_GET_MBLEN 66 30018 30084
STMT_GET_MBLEN 54 36 90
239  
240 30624 ▶ if (!mblen) {
Branch: 1 branch
BranchTrueFalseTotal
if (!mblen) { 78 30546 30624
241 78 p++;
242 78 continue;
243 }
244  
245 30546 ▶ STMT_GET_UV_FROM_MB
Branch: 15 branches
BranchTrueFalseTotal
STMT_GET_UV_FROM_MB 126 30420 30546
STMT_GET_UV_FROM_MB 114 12 126
STMT_GET_UV_FROM_MB 102 12 114
STMT_GET_UV_FROM_MB 90 12 102
STMT_GET_UV_FROM_MB 60 30 90
STMT_GET_UV_FROM_MB 48 24 72
STMT_GET_UV_FROM_MB 30 18 48
STMT_GET_UV_FROM_MB 30 30 60
STMT_GET_UV_FROM_MB 66 30420 30486
STMT_GET_UV_FROM_MB 60 6 66
STMT_GET_UV_FROM_MB 54 6 60
STMT_GET_UV_FROM_MB 24 30 54
STMT_GET_UV_FROM_MB 30 6 36
STMT_GET_UV_FROM_MB 24 6 30
STMT_GET_UV_FROM_MB 204 30246 30450
246  
247 30546 ▶ if (uv || !*p) {
Branch: 2 branches
BranchTrueFalseTotal
if (uv || !*p) { 204 30342 30546
if (uv || !*p) { 30 174 204
248 30372 ▶ d = ix ? app_uv(d, uv) : uvuni_to_utf8(d, uv);
Branch: 1 branch
BranchTrueFalseTotal
d = ix ? app_uv(d, uv) : uvuni_to_utf8(d, uv); 25310 5062 30372
249 }
250 }
251 372 *d = '\0';
252 372 SvCUR_set(dst, d - (U8*)SvPVX(dst));
253 }
254 672 ▶ XPUSHs(dst);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(dst); 0 672 672
255  
256  
257 void
258 unicode_to_cp932(...)
259 ALIAS:
260 utf8_to_cp932 = 1
261 utf16le_to_cp932 = 2
262 utf16be_to_cp932 = 3
263 utf32le_to_cp932 = 4
264 utf32be_to_cp932 = 5
265 utf16_to_cp932 = 6
266 utf32_to_cp932 = 7
267 PREINIT:
268 SV *src, *dst, *cvref, *mod;
269 STRLEN srclen, dstlen, modlen, retlen;
270 U8 *s, *e, *p, *d, *m, *m_e, mbc[3];
271 U16 j, *t;
272 UV uv;
273 UV (*ord_uv)(U8 *, STRLEN, STRLEN *);
274 bool mod_g, mod_s, mod_f;
275 PPCODE:
276 1206 ▶ STMT_ASSIGN_CVREF_AND_SRC(funcname_fm[ix])
Branch: 7 branches
BranchTrueFalseTotal
STMT_ASSIGN_CVREF_AND_SRC(funcname_fm[ix]) 609 597 1206
STMT_ASSIGN_CVREF_AND_SRC(funcname_fm[ix]) 609 0 609
STMT_ASSIGN_CVREF_AND_SRC(funcname_fm[ix]) 609 597 1206
STMT_ASSIGN_CVREF_AND_SRC(funcname_fm[ix]) 609 0 609
STMT_ASSIGN_CVREF_AND_SRC(funcname_fm[ix]) 609 597 1206
STMT_ASSIGN_CVREF_AND_SRC(funcname_fm[ix]) 121 488 609
STMT_ASSIGN_CVREF_AND_SRC(funcname_fm[ix]) 302 295 597
277 1206 ▶ if (ix == 0 && !SvUTF8(src)) {
Branch: 2 branches
BranchTrueFalseTotal
if (ix == 0 && !SvUTF8(src)) { 72 1134 1206
if (ix == 0 && !SvUTF8(src)) { 7 65 72
278 7 src = sv_mortalcopy(src);
279 7 sv_utf8_upgrade(src);
280 }
281 1199 ▶ else if (ix && SvUTF8(src)) {
Branch: 2 branches
BranchTrueFalseTotal
else if (ix && SvUTF8(src)) { 1134 65 1199
else if (ix && SvUTF8(src)) { 11 1123 1134
282 11 src = sv_mortalcopy(src);
283 11 sv_utf8_downgrade(src, FALSE);
284 }
285 1206 ▶ STMT_ASSIGN_LENDST(maxlen_fm[ix])
Branch: 1 branch
BranchTrueFalseTotal
STMT_ASSIGN_LENDST(maxlen_fm[ix]) 1206 0 1206
286  
287 1206 m = (U8*)SvPV(mod, modlen);
288 1629 ▶ for (p = m, m_e = m + modlen; p < m_e; p++) {
Branch: 1 branch
BranchTrueFalseTotal
for (p = m, m_e = m + modlen; p < m_e; p++) { 423 1206 1629
289 423 ▶ if (*p == 'g' || *p == 's' || *p == 'f')
Branch: 3 branches
BranchTrueFalseTotal
if (*p == 'g' || *p == 's' || *p == 'f') 303 120 423
if (*p == 'g' || *p == 's' || *p == 'f') 242 61 303
if (*p == 'g' || *p == 's' || *p == 'f') 242 0 242
290 423 continue;
291 0 croak("Unknown option in %s: '%c'", funcname_fm[ix], *p);
292 }
293 1206 mod_g = memchr((void*)m, 'g', modlen) != NULL;
294 1206 mod_s = memchr((void*)m, 's', modlen) != NULL;
295 1206 mod_f = memchr((void*)m, 'f', modlen) != NULL;
296  
297 1206 ord_uv = ord_uv_in[ix];
298  
299 1206 ▶ if (ix == 6 && 2 <= e - s) { /* UTF-16 */
Branch: 2 branches
BranchTrueFalseTotal
if (ix == 6 && 2 <= e - s) { /* UTF-16 */ 281 925 1206
if (ix == 6 && 2 <= e - s) { /* UTF-16 */ 279 2 281
300 558 ▶ if (memEQ("\xFF\xFE",s,2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (memEQ("\xFF\xFE",s,2)) { 94 185 279
301 94 s += 2;
302 94 ord_uv = ord_in_utf16le;
303 }
304 185 ▶ else if (memEQ("\xFE\xFF",s,2)) {
Branch: 1 branch
BranchTrueFalseTotal
else if (memEQ("\xFE\xFF",s,2)) { 94 91 185
305 94 s += 2;
306 }
307 }
308 927 ▶ else if (ix == 7 && 4 <= e - s) { /* UTF-32 */
Branch: 2 branches
BranchTrueFalseTotal
else if (ix == 7 && 4 <= e - s) { /* UTF-32 */ 283 644 927
else if (ix == 7 && 4 <= e - s) { /* UTF-32 */ 281 2 283
309 281 ▶ if (memEQ("\xFF\xFE\x00\x00",s,4)) {
Branch: 1 branch
BranchTrueFalseTotal
if (memEQ("\xFF\xFE\x00\x00",s,4)) { 94 187 281
310 94 s += 4;
311 94 ord_uv = ord_in_utf32le;
312 }
313 187 ▶ else if (memEQ("\x00\x00\xFE\xFF",s,4)) {
Branch: 1 branch
BranchTrueFalseTotal
else if (memEQ("\x00\x00\xFE\xFF",s,4)) { 94 93 187
314 94 s += 4;
315 }
316 }
317  
318 1206 ▶ if (cvref) {
Branch: 1 branch
BranchTrueFalseTotal
if (cvref) { 609 597 1206
319 115254 ▶ for (p = s; p < e;) {
Branch: 1 branch
BranchTrueFalseTotal
for (p = s; p < e;) { 114645 609 115254
320 114645 uv = ix
321 94285 ? ord_uv(p, e - p, &retlen)
322 114645 ▶ : utf8n_to_uvuni(p, (e - p), &retlen, 0);
Branch: 1 branch
BranchTrueFalseTotal
: utf8n_to_uvuni(p, (e - p), &retlen, 0); 94285 20360 114645
323  
324 114645 ▶ if (retlen)
Branch: 1 branch
BranchTrueFalseTotal
if (retlen) 114609 36 114645
325 114609 p += retlen;
326 else {
327 36 sv_cat_retcvref(dst, cvref, newSVuv((UV)*p), TRUE);
328 36 p++;
329 36 continue;
330 }
331  
332 114609 ▶ if (mod_g && Is_CP932_PUAe(uv)) {
Branch: 3 branches
BranchTrueFalseTotal
if (mod_g && Is_CP932_PUAe(uv)) { 0 114609 114609
if (mod_g && Is_CP932_PUAe(uv)) { 0 0 0
if (mod_g && Is_CP932_PUAe(uv)) { 0 0 0
333 0 uv -= CP932_PUA_BASE;
334 0 mbc[0] = (U8)((uv / 188) + 0xF0);
335 0 ▶ mbc[1] = (U8)(uv % 188 + (uv % 188 > 0x3E ? 0x41 : 0x40));
Branch: 1 branch
BranchTrueFalseTotal
mbc[1] = (U8)(uv % 188 + (uv % 188 > 0x3E ? 0x41 : 0x40)); 0 0 0
336 0 sv_catpvn(dst, (char*)mbc, 2);
337 0 continue;
338 }
339 114609 ▶ if (mod_s && Is_CP932_PUAs(uv)) {
Branch: 4 branches
BranchTrueFalseTotal
if (mod_s && Is_CP932_PUAs(uv)) { 0 114609 114609
if (mod_s && Is_CP932_PUAs(uv)) { 0 0 0
if (mod_s && Is_CP932_PUAs(uv)) { 0 0 0
if (mod_s && Is_CP932_PUAs(uv)) { 0 0 0
340 0 ▶ mbc[0] = (U8) CP932_PUA2UDSB(uv);
Branch: 2 branches
BranchTrueFalseTotal
mbc[0] = (U8) CP932_PUA2UDSB(uv); 0 0 0
mbc[0] = (U8) CP932_PUA2UDSB(uv); 0 0 0
341 0 sv_catpvn(dst, (char*)mbc, 1);
342 0 continue;
343 }
344  
345 114609 ▶ t = uv < 0x10000 ? tocp932_tbl[uv >> 8] : NULL;
Branch: 1 branch
BranchTrueFalseTotal
t = uv < 0x10000 ? tocp932_tbl[uv >> 8] : NULL; 92187 22422 114609
346 114609 ▶ j = t ? t[uv & 0xff] : 0;
Branch: 1 branch
BranchTrueFalseTotal
j = t ? t[uv & 0xff] : 0; 19045 95564 114609
347  
348 114609 ▶ if (mod_f && j == 0 && Is_CP932_L1FB(uv)) {
Branch: 5 branches
BranchTrueFalseTotal
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 121 114488 114609
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 121 0 121
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 110 11 121
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 110 0 110
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 110 0 110
349 121 ▶ j = (U16) CP932_FB2MB(uv);
Branch: 1 branch
BranchTrueFalseTotal
j = (U16) CP932_FB2MB(uv); 110 11 121
350 }
351  
352 114609 ▶ if (j || !uv) {
Branch: 2 branches
BranchTrueFalseTotal
if (j || !uv) { 101854 12755 114609
if (j || !uv) { 75 101779 101854
353 12830 ▶ if (j >= 256) {
Branch: 1 branch
BranchTrueFalseTotal
if (j >= 256) { 12332 498 12830
354 12332 mbc[0] = (U8)(j >> 8);
355 12332 mbc[1] = (U8)(j & 0xff);
356 12332 sv_catpvn(dst, (char*)mbc, 2);
357 }
358 else {
359 498 mbc[0] = (U8)(j & 0xff);
360 498 sv_catpvn(dst, (char*)mbc, 1);
361 }
362 } else
363 101779 sv_cat_retcvref(dst, cvref, newSVuv(uv), FALSE);
364 }
365 }
366 else {
367 597 d = (U8*)SvPVX(dst);
368 11523 ▶ for (p = s; p < e;) {
Branch: 1 branch
BranchTrueFalseTotal
for (p = s; p < e;) { 10926 597 11523
369 10926 uv = ix
370 847 ? ord_uv(p, e - p, &retlen)
371 10926 ▶ : utf8n_to_uvuni(p, (e - p), &retlen, 0);
Branch: 1 branch
BranchTrueFalseTotal
: utf8n_to_uvuni(p, (e - p), &retlen, 0); 847 10079 10926
372  
373 10926 ▶ if (retlen)
Branch: 1 branch
BranchTrueFalseTotal
if (retlen) 10898 28 10926
374 10898 p += retlen;
375 else {
376 28 p++;
377 28 continue;
378 }
379  
380 10898 ▶ if (mod_g && Is_CP932_PUAe(uv)) {
Branch: 3 branches
BranchTrueFalseTotal
if (mod_g && Is_CP932_PUAe(uv)) { 120 10778 10898
if (mod_g && Is_CP932_PUAe(uv)) { 120 0 120
if (mod_g && Is_CP932_PUAe(uv)) { 120 0 120
381 120 uv -= CP932_PUA_BASE;
382 120 *d++ = (U8)((uv / 188) + 0xF0);
383 120 ▶ *d++ = (U8)(uv % 188 + (uv % 188 > 0x3E ? 0x41 : 0x40));
Branch: 1 branch
BranchTrueFalseTotal
*d++ = (U8)(uv % 188 + (uv % 188 > 0x3E ? 0x41 : 0x40)); 60 60 120
384 120 continue;
385 }
386 10778 ▶ if (mod_s && Is_CP932_PUAs(uv)) {
Branch: 4 branches
BranchTrueFalseTotal
if (mod_s && Is_CP932_PUAs(uv)) { 62 10716 10778
if (mod_s && Is_CP932_PUAs(uv)) { 49 13 62
if (mod_s && Is_CP932_PUAs(uv)) { 48 1 49
if (mod_s && Is_CP932_PUAs(uv)) { 48 0 48
387 61 ▶ *d++ = (U8) CP932_PUA2UDSB(uv);
Branch: 2 branches
BranchTrueFalseTotal
*d++ = (U8) CP932_PUA2UDSB(uv); 48 13 61
*d++ = (U8) CP932_PUA2UDSB(uv); 36 12 48
388 61 continue;
389 }
390  
391 10717 ▶ t = uv < 0x10000 ? tocp932_tbl[uv >> 8] : NULL;
Branch: 1 branch
BranchTrueFalseTotal
t = uv < 0x10000 ? tocp932_tbl[uv >> 8] : NULL; 10697 20 10717
392 10717 ▶ j = t ? t[uv & 0xff] : 0;
Branch: 1 branch
BranchTrueFalseTotal
j = t ? t[uv & 0xff] : 0; 10689 28 10717
393  
394 10717 ▶ if (mod_f && j == 0 && Is_CP932_L1FB(uv)) {
Branch: 5 branches
BranchTrueFalseTotal
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 121 10596 10717
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 121 0 121
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 110 11 121
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 110 0 110
if (mod_f && j == 0 && Is_CP932_L1FB(uv)) { 110 0 110
395 121 ▶ j = (U16) CP932_FB2MB(uv);
Branch: 1 branch
BranchTrueFalseTotal
j = (U16) CP932_FB2MB(uv); 110 11 121
396 }
397  
398 10717 ▶ if (j || !uv) {
Branch: 2 branches
BranchTrueFalseTotal
if (j || !uv) { 110 10607 10717
if (j || !uv) { 72 38 110
399 10679 ▶ if (j >= 256)
Branch: 1 branch
BranchTrueFalseTotal
if (j >= 256) 5349 5330 10679
400 5349 *d++ = (U8)(j >> 8);
401 10679 *d++ = (U8)(j & 0xff);
402 }
403 }
404 597 *d = '\0';
405 597 SvCUR_set(dst, d - (U8*)SvPVX(dst));
406 }
407 1206 ▶ XPUSHs(dst);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(dst); 0 1206 1206
408  
« scmuni.h ↑ Summary blib/lib/ShiftJIS/CP932/MapUTF.pm »