LineBreak.xs

filter: Statementstmt 55.9% 432 / 772 Branchbran 41.9% 288 / 686 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 49.3% 720 / 1458 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Unicode/GCString.pm ↑ Summary blib/lib/Unicode/LineBreak/Constants.pm »
1 /*
2 * LineBreak.xs - Perl XS glue for Sombok package.
3 *
4 * Copyright (C) 2009-2013 Hatuka*nezumi - IKEDA Soji <hatuka(at)nezumi.nu>.
5 *
6 * This file is part of the Unicode::LineBreak package. This program is
7 * free software; you can redistribute it and/or modify it under the same
8 * terms as Perl itself.
9 *
10 * $Id$
11 */
12  
13 #include "EXTERN.h"
14 #include "perl.h"
15 #include "XSUB.h"
16 #define NEED_newRV_noinc
17 #define NEED_sv_2pv_flags
18 #define NEED_newRV_noinc_GLOBAL
19 #define NEED_sv_2pv_flags_GLOBAL
20 #define NEED_sv_2pv_nolen
21 #include "ppport.h"
22 #include "sombok.h"
23  
24 /* for Win32 with Visual Studio (MSVC) */
25 #ifdef _MSC_VER
26 # ifndef snprintf
27 # define snprintf _snprintf
28 # endif /* snprintf */
29 # define strcasecmp _stricmp
30 #endif /* _MSC_VER */
31  
32 /* Type synonyms for typemap. */
33 typedef IV swapspec_t;
34 typedef gcstring_t *generic_string;
35  
36 /***
37 *** Data conversion.
38 ***/
39  
40 /*
41 * Create Unicode string from Perl utf8-flagged string.
42 */
43 static
44 11229 unistr_t *SVtounistr(unistr_t *buf, SV *str)
45 {
46 U8 *utf8, *utf8ptr;
47 STRLEN utf8len, unilen, len;
48 unichar_t *uniptr;
49  
50 11229 ▶ if (buf == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (buf == NULL) { 0 11229 11229
51 0 ▶ if ((buf = malloc(sizeof(unistr_t))) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((buf = malloc(sizeof(unistr_t))) == NULL) 0 0 0
52 0 croak("SVtounistr: %s", strerror(errno));
53 11229 ▶ } else if (buf->str)
Branch: 1 branch
BranchTrueFalseTotal
} else if (buf->str) 0 11229 11229
54 0 free(buf->str);
55 11229 buf->str = NULL;
56 11229 buf->len = 0;
57  
58 11229 ▶ if (SvOK(str))
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(str)) 11229 0 11229
59 11229 utf8 = (U8 *)SvPV(str, utf8len);
60 else
61 0 return buf;
62 11229 ▶ if (utf8len <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (utf8len <= 0) 0 11229 11229
63 0 return buf;
64 11229 unilen = utf8_length(utf8, utf8 + utf8len);
65 11229 ▶ if ((buf->str = (unichar_t *)malloc(sizeof(unichar_t) * unilen)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((buf->str = (unichar_t *)malloc(sizeof(unichar_t) * unilen)) == NULL) 0 11229 11229
66 0 croak("SVtounistr: %s", strerror(errno));
67  
68 11229 utf8ptr = utf8;
69 11229 uniptr = buf->str;
70 98180 ▶ while (utf8ptr < utf8 + utf8len) {
Branch: 1 branch
BranchTrueFalseTotal
while (utf8ptr < utf8 + utf8len) { 86951 11229 98180
71 #if PERL_VERSION >= 20 || (PERL_VERSION == 19 && PERL_SUBVERSION >= 4)
72 86951 *uniptr = (unichar_t) NATIVE_TO_UNI(
73 utf8_to_uvchr_buf(utf8ptr, utf8 + utf8len, &len));
74 #elif PERL_VERSION >= 16 || (PERL_VERSION == 15 && PERL_SUBVERSION >= 9)
75 *uniptr = (unichar_t) utf8_to_uvuni_buf(utf8ptr, utf8 + utf8len,
76 &len);
77 #else
78 *uniptr = (unichar_t) utf8n_to_uvuni(utf8ptr,
79 utf8 + utf8len - utf8ptr, &len,
80 ckWARN(WARN_UTF8) ? 0 :
81 UTF8_ALLOW_ANY);
82 #endif
83 if (len < 0) {
84 free(buf->str);
85 buf->str = NULL;
86 buf->len = 0;
87 croak("SVtounistr: Not well-formed UTF-8");
88 }
89 86951 ▶ if (len == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (len == 0) { 0 86951 86951
90 0 free(buf->str);
91 0 buf->str = NULL;
92 0 buf->len = 0;
93 0 croak("SVtounistr: Internal error");
94 }
95 86951 utf8ptr += len;
96 86951 uniptr++;
97 }
98 11229 buf->len = unilen;
99 11229 return buf;
100 }
101  
102 /*
103 * Create Unicode string from Perl string NOT utf8-flagged.
104 */
105 static
106 35 unistr_t *SVupgradetounistr(unistr_t *buf, SV *str)
107 {
108 char *s;
109 size_t len, i;
110  
111 35 ▶ if (buf == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (buf == NULL) { 0 35 35
112 0 ▶ if ((buf = malloc(sizeof(unistr_t))) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((buf = malloc(sizeof(unistr_t))) == NULL) 0 0 0
113 0 croak("SVupgradetounistr: %s", strerror(errno));
114 35 ▶ } else if (buf->str)
Branch: 1 branch
BranchTrueFalseTotal
} else if (buf->str) 0 35 35
115 0 free(buf->str);
116 35 buf->str = NULL;
117 35 buf->len = 0;
118  
119 35 ▶ if (SvOK(str))
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(str)) 35 0 35
120 35 s = SvPV(str, len);
121 else
122 0 return buf;
123 35 ▶ if (len == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (len == 0) 0 35 35
124 0 return buf;
125 35 ▶ if ((buf->str = malloc(sizeof(unichar_t) * len)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((buf->str = malloc(sizeof(unichar_t) * len)) == NULL) 0 35 35
126 0 croak("SVupgradetounistr: %s", strerror(errno));
127  
128 97 ▶ for (i = 0; i < len; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < len; i++) 62 35 97
129 62 buf->str[i] = (unichar_t)(unsigned char)s[i];
130 35 buf->len = len;
131 35 return buf;
132 }
133  
134 /*
135 * Create Perl utf8-flagged string from Unicode string.
136 */
137 static
138 14550 SV *unistrtoSV(unistr_t *unistr, size_t uniidx, size_t unilen)
139 {
140 14550 U8 *buf = NULL, *newbuf;
141 STRLEN utf8len;
142 unichar_t *uniptr;
143 SV *utf8;
144  
145 14550 ▶ if (unistr == NULL || unistr->str == NULL || unilen == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (unistr == NULL || unistr->str == NULL || unilen == 0) { 14550 0 14550
if (unistr == NULL || unistr->str == NULL || unilen == 0) { 12324 2226 14550
if (unistr == NULL || unistr->str == NULL || unilen == 0) { 2 12322 12324
146 2228 utf8 = newSVpvn("", 0);
147 2228 SvUTF8_on(utf8);
148 2228 return utf8;
149 }
150  
151 12322 utf8len = 0;
152 12322 uniptr = unistr->str + uniidx;
153 114554 ▶ while (uniptr < unistr->str + uniidx + unilen &&
Branch: 1 branch
BranchTrueFalseTotal
while (uniptr < unistr->str + uniidx + unilen && 102232 12322 114554
154 102232 ▶ uniptr < unistr->str + unistr->len) {
Branch: 1 branch
BranchTrueFalseTotal
uniptr < unistr->str + unistr->len) { 102232 0 102232
155 102232 if ((newbuf = realloc(buf,
156 102232 ▶ sizeof(U8) * (utf8len + UTF8_MAXLEN + 1)))
Branch: 1 branch
BranchTrueFalseTotal
sizeof(U8) * (utf8len + UTF8_MAXLEN + 1))) 0 102232 102232
157 == NULL) {
158 0 free(buf);
159 0 croak("unistrtoSV: %s", strerror(errno));
160 }
161 102232 buf = newbuf;
162 #if PERL_VERSION >= 20 || (PERL_VERSION == 19 && PERL_SUBVERSION >= 4)
163 102232 utf8len = uvchr_to_utf8(buf + utf8len, UNI_TO_NATIVE(*uniptr)) - buf;
164 #else
165 utf8len = uvuni_to_utf8(buf + utf8len, *uniptr) - buf;
166 #endif
167 102232 uniptr++;
168 }
169  
170 12322 utf8 = newSVpvn((char *)(void *)buf, utf8len);
171 12322 SvUTF8_on(utf8);
172 12322 free(buf);
173 12322 return utf8;
174 }
175  
176 /*
177 * Convert Perl object to C object
178 */
179 #define PerltoC(type, arg) \
180 (INT2PTR(type, SvIV((SV *)SvRV(arg))))
181  
182 /*
183 * Create Perl object from C object
184 */
185 # define setCtoPerl(arg, klass, var) \
186 STMT_START { \
187 sv_setref_iv(arg, klass, (IV)(var)); \
188 SvREADONLY_on(arg); \
189 } STMT_END
190 static
191 32636 SV *CtoPerl(char *klass, void *obj)
192 {
193 SV *sv;
194  
195 32636 sv = newSViv(0);
196 32636 setCtoPerl(sv, klass, obj);
197 32636 return sv;
198 }
199  
200 /*
201 * Convert Perl utf8-flagged string (GCString) to grapheme cluster string.
202 */
203 static
204 572 gcstring_t *SVtogcstring(SV *sv, linebreak_t *lbobj)
205 {
206 572 unistr_t unistr = {NULL, 0};
207  
208 572 ▶ if (!sv_isobject(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_isobject(sv)) { 462 110 572
209 462 SVtounistr(&unistr, sv);
210 462 return gcstring_new(&unistr, lbobj);
211 110 ▶ } else if (sv_derived_from(sv, "Unicode::GCString"))
Branch: 1 branch
BranchTrueFalseTotal
} else if (sv_derived_from(sv, "Unicode::GCString")) 110 0 110
212 110 return PerltoC(gcstring_t *, sv);
213 else
214 0 ▶ croak("Unknown object %s", HvNAME(SvSTASH(SvRV(sv))));
Branch: 6 branches
BranchTrueFalseTotal
croak("Unknown object %s", HvNAME(SvSTASH(SvRV(sv)))); 0 0 0
croak("Unknown object %s", HvNAME(SvSTASH(SvRV(sv)))); 0 0 0
croak("Unknown object %s", HvNAME(SvSTASH(SvRV(sv)))); 0 0 0
croak("Unknown object %s", HvNAME(SvSTASH(SvRV(sv)))); 0 0 0
croak("Unknown object %s", HvNAME(SvSTASH(SvRV(sv)))); 0 0 0
croak("Unknown object %s", HvNAME(SvSTASH(SvRV(sv)))); 0 0 0
215 }
216  
217 #if 0
218 /*
219 * Convert Perl LineBreak object to C linebreak object.
220 */
221 static
222 linebreak_t *SVtolinebreak(SV *sv)
223 {
224 if (!sv_isobject(sv))
225 croak("Not object");
226 else if (sv_derived_from(sv, "Unicode::LineBreak"))
227 return PerltoC(linebreak_t *, sv);
228 else
229 croak("Unknown object %s", HvNAME(SvSTASH(SvRV(sv))));
230 }
231 #endif /* 0 */
232  
233 /*
234 * Convert Perl SV to boolean (n.b. string "YES" means true).
235 */
236 static
237 2732 int SVtoboolean(SV *sv)
238 {
239 char *str;
240  
241 2732 ▶ if (!sv || !SvOK(sv))
Branch: 2 branches
BranchTrueFalseTotal
if (!sv || !SvOK(sv)) 2732 0 2732
if (!sv || !SvOK(sv)) 0 2732 2732
242 0 return 0;
243 2732 ▶ if (SvPOK(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (SvPOK(sv)) 2732 0 2732
244 3565 ▶ return strcasecmp((str = SvPV_nolen(sv)), "YES") == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
return strcasecmp((str = SvPV_nolen(sv)), "YES") == 0 || 833 1899 2732
245 833 ▶ atof(str) != 0.0;
Branch: 1 branch
BranchTrueFalseTotal
atof(str) != 0.0; 0 833 833
246 0 return SvNV(sv) != 0.0;
247 }
248  
249 /***
250 *** Other utilities
251 ***/
252  
253 /*
254 * Do regex match once then returns offset and length.
255 */
256 78 void do_pregexec_once(REGEXP *rx, unistr_t *str)
257 {
258 SV *screamer;
259 char *str_arg, *str_beg, *str_end;
260 size_t offs_beg, offs_end;
261  
262 78 screamer = unistrtoSV(str, 0, str->len);
263 78 SvREADONLY_on(screamer);
264 78 str_beg = str_arg = SvPVX(screamer);
265 78 str_end = SvEND(screamer);
266  
267 78 ▶ if (pregexec(rx, str_arg, str_end, str_beg, 0, screamer, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (pregexec(rx, str_arg, str_end, str_beg, 0, screamer, 1)) { 48 30 78
268 #if PERL_VERSION >= 11
269 48 offs_beg = ((regexp *)SvANY(rx))->offs[0].start;
270 48 offs_end = ((regexp *)SvANY(rx))->offs[0].end;
271 #elif ((PERL_VERSION == 10) || (PERL_VERSION == 9 && PERL_SUBVERSION >= 5))
272 offs_beg = rx->offs[0].start;
273 offs_end = rx->offs[0].end;
274 #else /* PERL_VERSION */
275 offs_beg = rx->startp[0];
276 offs_end = rx->endp[0];
277 #endif
278 48 str->str += utf8_length((U8 *)str_beg, (U8 *)(str_beg + offs_beg));
279 48 str->len = utf8_length((U8 *)(str_beg + offs_beg),
280 (U8 *)(str_beg + offs_end));
281 } else
282 30 str->str = NULL;
283  
284 78 SvREFCNT_dec(screamer);
285 78 }
286  
287 /***
288 *** Callbacks for Sombok library.
289 ***/
290  
291 /*
292 * Increment/decrement reference count
293 */
294 1032 void ref_func(void *sv, int datatype, int d)
295 {
296 1032 ▶ if (sv == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (sv == NULL) 0 1032 1032
297 0 return;
298 1032 ▶ if (0 < d)
Branch: 1 branch
BranchTrueFalseTotal
if (0 < d) 516 516 1032
299 516 SvREFCNT_inc((SV *)sv);
300 516 ▶ else if (d < 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (d < 0) 516 0 516
301 516 SvREFCNT_dec((SV *)sv);
302 }
303  
304 /*
305 * Call preprocessing function
306 */
307 static
308 126 gcstring_t *prep_func(linebreak_t *lbobj, void *dataref, unistr_t *str,
309 unistr_t *text)
310 {
311 AV *data;
312 126 SV *sv, **pp, *func = NULL;
313 126 REGEXP *rx = NULL;
314 size_t count, i, j;
315 gcstring_t *gcstr, *ret;
316  
317 126 ▶ if (dataref == NULL ||
Branch: 1 branch
BranchTrueFalseTotal
if (dataref == NULL || 126 0 126
318 126 ▶ (data = (AV *)SvRV((SV *)dataref)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
(data = (AV *)SvRV((SV *)dataref)) == NULL) 0 126 126
319 0 return (lbobj->errnum = EINVAL), NULL;
320  
321 /* Pass I */
322  
323 126 ▶ if (text != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (text != NULL) { 78 48 126
324 78 ▶ if ((pp = av_fetch(data, 0, 0)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((pp = av_fetch(data, 0, 0)) == NULL) 0 78 78
325 0 return (lbobj->errnum = EINVAL), NULL;
326  
327 #if ((PERL_VERSION >= 10) || (PERL_VERSION >= 9 && PERL_SUBVERSION >= 5))
328 78 ▶ if (SvRXOK(*pp))
Branch: 1 branch
BranchTrueFalseTotal
if (SvRXOK(*pp)) 78 0 78
329 78 rx = SvRX(*pp);
330 #else /* PERL_VERSION */
331 if (SvROK(*pp) && SvMAGICAL(sv = SvRV(*pp))) {
332 MAGIC *mg;
333 if ((mg = mg_find(sv, PERL_MAGIC_qr)) != NULL)
334 rx = (REGEXP *)mg->mg_obj;
335 }
336 #endif /* PERL_VERSION */
337 78 ▶ if (rx == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (rx == NULL) 0 78 78
338 0 return (lbobj->errnum = EINVAL), NULL;
339  
340 78 do_pregexec_once(rx, str);
341 78 return NULL;
342 }
343  
344 /* Pass II */
345  
346 48 ▶ if ((pp = av_fetch(data, 1, 0)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((pp = av_fetch(data, 1, 0)) == NULL) 0 48 48
347 0 func = NULL;
348 48 ▶ else if (SvOK(*pp))
Branch: 1 branch
BranchTrueFalseTotal
else if (SvOK(*pp)) 48 0 48
349 48 func = *pp;
350 else
351 0 func = NULL;
352  
353 48 ▶ if (func == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (func == NULL) { 0 48 48
354 0 ▶ if ((ret = gcstring_newcopy(str, lbobj)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((ret = gcstring_newcopy(str, lbobj)) == NULL) 0 0 0
355 0 ▶ return (lbobj->errnum = errno ? errno : ENOMEM), NULL;
Branch: 1 branch
BranchTrueFalseTotal
return (lbobj->errnum = errno ? errno : ENOMEM), NULL; 0 0 0
356 } else {
357 48 dSP;
358 48 ENTER;
359 48 SAVETMPS;
360 48 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 48 48
361 48 linebreak_incref(lbobj); /* mortal but should not be destroyed.*/
362 48 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::LineBreak", lbobj)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::LineBreak", lbobj))); 0 48 48
363 48 ▶ XPUSHs(sv_2mortal(unistrtoSV(str, 0, str->len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(unistrtoSV(str, 0, str->len))); 0 48 48
364 48 PUTBACK;
365 48 count = call_sv(func, G_ARRAY | G_EVAL);
366  
367 48 SPAGAIN;
368 48 ▶ if (SvTRUE(ERRSV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) { 48 0 48
if (SvTRUE(ERRSV)) { 0 48 48
369 0 ▶ if (!lbobj->errnum)
Branch: 1 branch
BranchTrueFalseTotal
if (!lbobj->errnum) 0 0 0
370 0 lbobj->errnum = LINEBREAK_EEXTN;
371 0 return NULL;
372 }
373  
374 48 ▶ if ((ret = gcstring_new(NULL, lbobj)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((ret = gcstring_new(NULL, lbobj)) == NULL) 0 48 48
375 0 ▶ return (lbobj->errnum = errno ? errno : ENOMEM), NULL;
Branch: 1 branch
BranchTrueFalseTotal
return (lbobj->errnum = errno ? errno : ENOMEM), NULL; 0 0 0
376  
377 268 ▶ for (i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < count; i++) { 220 48 268
378 220 sv = POPs;
379 220 ▶ if (!SvOK(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(sv)) 0 220 220
380 0 continue;
381 220 gcstr = SVtogcstring(sv, lbobj);
382  
383 2528 ▶ for (j = 0; j < gcstr->gclen; j++) {
Branch: 1 branch
BranchTrueFalseTotal
for (j = 0; j < gcstr->gclen; j++) { 2308 220 2528
384 2308 ▶ if (gcstr->gcstr[j].flag &
Branch: 1 branch
BranchTrueFalseTotal
if (gcstr->gcstr[j].flag & 0 2308 2308
385 (LINEBREAK_FLAG_ALLOW_BEFORE |
386 LINEBREAK_FLAG_PROHIBIT_BEFORE))
387 0 continue;
388 2308 ▶ if (i < count - 1 && j == 0)
Branch: 2 branches
BranchTrueFalseTotal
if (i < count - 1 && j == 0) 958 1350 2308
if (i < count - 1 && j == 0) 172 786 958
389 172 gcstr->gcstr[j].flag |= LINEBREAK_FLAG_ALLOW_BEFORE;
390 2136 ▶ else if (0 < j)
Branch: 1 branch
BranchTrueFalseTotal
else if (0 < j) 2088 48 2136
391 2088 gcstr->gcstr[j].flag |= LINEBREAK_FLAG_PROHIBIT_BEFORE;
392 }
393  
394 220 gcstring_replace(ret, 0, 0, gcstr);
395 220 ▶ if (!sv_isobject(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_isobject(sv)) 220 0 220
396 220 gcstring_destroy(gcstr);
397 }
398  
399 48 PUTBACK;
400 48 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 48 0 48
401 48 LEAVE;
402 }
403  
404 48 return ret;
405 }
406  
407 /*
408 * Call format function
409 */
410 static
411 char *linebreak_states[] = {
412 NULL, "sot", "sop", "sol", "", "eol", "eop", "eot", NULL
413 };
414 static
415 750 gcstring_t *format_func(linebreak_t *lbobj, linebreak_state_t action,
416 gcstring_t *str)
417 {
418 SV *sv;
419 char *actionstr;
420 int count;
421 gcstring_t *ret;
422  
423 750 dSP;
424 750 ▶ if (action <= LINEBREAK_STATE_NONE || LINEBREAK_STATE_MAX <= action)
Branch: 2 branches
BranchTrueFalseTotal
if (action <= LINEBREAK_STATE_NONE || LINEBREAK_STATE_MAX <= action) 750 0 750
if (action <= LINEBREAK_STATE_NONE || LINEBREAK_STATE_MAX <= action) 0 750 750
425 0 return NULL;
426 750 actionstr = linebreak_states[(size_t)action];
427 750 ENTER;
428 750 SAVETMPS;
429 750 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 750 750
430 750 linebreak_incref(lbobj); /* mortal but should not be destroyed. */
431 750 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::LineBreak", lbobj)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::LineBreak", lbobj))); 0 750 750
432 750 ▶ XPUSHs(sv_2mortal(newSVpv(actionstr, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(actionstr, 0))); 0 750 750
433 750 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(str))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(str)))); 0 750 750
434 750 PUTBACK;
435 750 count = call_sv(lbobj->format_data, G_SCALAR | G_EVAL);
436  
437 750 SPAGAIN;
438 750 ▶ if (SvTRUE(ERRSV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) { 750 0 750
if (SvTRUE(ERRSV)) { 0 750 750
439 0 ▶ if (!lbobj->errnum)
Branch: 1 branch
BranchTrueFalseTotal
if (!lbobj->errnum) 0 0 0
440 0 lbobj->errnum = LINEBREAK_EEXTN;
441 0 POPs;
442 0 return NULL;
443 750 ▶ } else if (count != 1)
Branch: 1 branch
BranchTrueFalseTotal
} else if (count != 1) 0 750 750
444 0 croak("format_func: internal error");
445 else
446 750 sv = POPs;
447 750 ▶ if (!SvOK(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(sv)) 398 352 750
448 398 ret = NULL;
449 else
450 352 ret = SVtogcstring(sv, lbobj);
451 750 ▶ if (sv_isobject(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (sv_isobject(sv)) 110 640 750
452 110 ret = gcstring_copy(ret);
453  
454 750 PUTBACK;
455 750 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 750 0 750
456 750 LEAVE;
457  
458 750 return ret;
459 }
460  
461 /*
462 * Call sizing function
463 */
464 static
465 2320 double sizing_func(linebreak_t *lbobj, double len,
466 gcstring_t *pre, gcstring_t *spc, gcstring_t *str)
467 {
468 int count;
469 double ret;
470  
471 2320 dSP;
472 2320 ENTER;
473 2320 SAVETMPS;
474 2320 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 2320 2320
475 2320 linebreak_incref(lbobj); /* mortal but should not be destroyed. */
476 2320 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::LineBreak", lbobj)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::LineBreak", lbobj))); 0 2320 2320
477 2320 ▶ XPUSHs(sv_2mortal(newSVnv(len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVnv(len))); 0 2320 2320
478 2320 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(pre))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(pre)))); 0 2320 2320
479 2320 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(spc))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(spc)))); 0 2320 2320
480 2320 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(str))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(str)))); 0 2320 2320
481 2320 PUTBACK;
482 2320 count = call_sv(lbobj->sizing_data, G_SCALAR | G_EVAL);
483  
484 2320 SPAGAIN;
485 2320 ▶ if (SvTRUE(ERRSV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) { 2320 0 2320
if (SvTRUE(ERRSV)) { 0 2320 2320
486 0 ▶ if (!lbobj->errnum)
Branch: 1 branch
BranchTrueFalseTotal
if (!lbobj->errnum) 0 0 0
487 0 lbobj->errnum = LINEBREAK_EEXTN;
488 0 POPs;
489 0 return -1;
490 2320 ▶ } else if (count != 1)
Branch: 1 branch
BranchTrueFalseTotal
} else if (count != 1) 0 2320 2320
491 0 croak("sizing_func: internal error");
492 else
493 2320 ret = POPn;
494  
495 2320 PUTBACK;
496 2320 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 2320 0 2320
497 2320 LEAVE;
498  
499 2320 return ret;
500 }
501  
502 /*
503 * Call urgent breaking function
504 */
505 static
506 0 gcstring_t *urgent_func(linebreak_t *lbobj, gcstring_t *str)
507 {
508 SV *sv;
509 int count;
510 size_t i;
511 gcstring_t *gcstr, *ret;
512  
513 0 dSP;
514 0 ENTER;
515 0 SAVETMPS;
516 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
517 0 linebreak_incref(lbobj); /* mortal but should not be destroyed. */
518 0 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::LineBreak", lbobj)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::LineBreak", lbobj))); 0 0 0
519 0 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(str))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", gcstring_copy(str)))); 0 0 0
520 0 PUTBACK;
521 0 count = call_sv(lbobj->urgent_data, G_ARRAY | G_EVAL);
522  
523 0 SPAGAIN;
524 0 ▶ if (SvTRUE(ERRSV)) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) { 0 0 0
if (SvTRUE(ERRSV)) { 0 0 0
525 0 ▶ if (!lbobj->errnum)
Branch: 1 branch
BranchTrueFalseTotal
if (!lbobj->errnum) 0 0 0
526 0 lbobj->errnum = LINEBREAK_EEXTN;
527 0 return NULL;
528 0 ▶ } if (count == 0)
Branch: 1 branch
BranchTrueFalseTotal
} if (count == 0) 0 0 0
529 0 return NULL;
530  
531 0 ret = gcstring_new(NULL, lbobj);
532 0 ▶ for (i = count; i; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = count; i; i--) { 0 0 0
533 0 sv = POPs;
534 0 ▶ if (SvOK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(sv)) { 0 0 0
535 0 gcstr = SVtogcstring(sv, lbobj);
536 0 ▶ if (gcstr->gclen)
Branch: 1 branch
BranchTrueFalseTotal
if (gcstr->gclen) 0 0 0
537 0 gcstr->gcstr[0].flag = LINEBREAK_FLAG_ALLOW_BEFORE;
538 0 gcstring_replace(ret, 0, 0, gcstr);
539 0 ▶ if (!sv_isobject(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_isobject(sv)) 0 0 0
540 0 gcstring_destroy(gcstr);
541 }
542 }
543  
544 0 PUTBACK;
545 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
546 0 LEAVE;
547  
548 0 return ret;
549 }
550  
551  
552 MODULE = Unicode::LineBreak PACKAGE = Unicode::LineBreak
553  
554 void
555 EAWidths()
556 INIT:
557 char **p;
558 PPCODE:
559 210 ▶ for (p = (char **)linebreak_propvals_EA; *p != NULL; p++)
Branch: 1 branch
BranchTrueFalseTotal
for (p = (char **)linebreak_propvals_EA; *p != NULL; p++) 189 21 210
560 189 ▶ XPUSHs(sv_2mortal(newSVpv(*p, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(*p, 0))); 0 189 189
561  
562 void
563 LBClasses()
564 INIT:
565 char **p;
566 PPCODE:
567 861 ▶ for (p = (char **)linebreak_propvals_LB; *p != NULL; p++)
Branch: 1 branch
BranchTrueFalseTotal
for (p = (char **)linebreak_propvals_LB; *p != NULL; p++) 840 21 861
568 840 ▶ XPUSHs(sv_2mortal(newSVpv(*p, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(*p, 0))); 0 840 840
569  
570 linebreak_t *
571 _new(klass)
572 char *klass;
573 PROTOTYPE: $
574 CODE:
575 482 ▶ if ((RETVAL = linebreak_new(ref_func)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((RETVAL = linebreak_new(ref_func)) == NULL) 0 482 482
576 0 croak("%s->_new: %s", klass, strerror(errno));
577 482 linebreak_set_stash(RETVAL, newRV_noinc((SV *)newHV()));
578 482 SvREFCNT_dec(RETVAL->stash); /* fixup */
579 OUTPUT:
580 RETVAL
581  
582 linebreak_t *
583 copy(self)
584 linebreak_t *self;
585 PROTOTYPE: $
586 CODE:
587 0 RETVAL = linebreak_copy(self);
588 OUTPUT:
589 RETVAL
590  
591 void
592 DESTROY(self)
593 linebreak_t *self;
594 PROTOTYPE: $
595 CODE:
596 3600 linebreak_destroy(self);
597  
598 SV *
599 _config(self, ...)
600 linebreak_t *self;
601 PREINIT:
602 size_t i;
603 char *key;
604 void *func;
605 SV *val;
606 char *opt;
607 CODE:
608 1339 RETVAL = NULL;
609 1339 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 1339 1339
610 0 croak("_config: Too few arguments");
611 1339 ▶ else if (items < 3) {
Branch: 1 branch
BranchTrueFalseTotal
else if (items < 3) { 348 991 1339
612 348 key = (char *)SvPV_nolen(ST(1));
613  
614 348 ▶ if (strcasecmp(key, "BreakIndent") == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (strcasecmp(key, "BreakIndent") == 0) 0 348 348
615 0 RETVAL = newSVuv(self->options &
616 LINEBREAK_OPTION_BREAK_INDENT);
617 348 ▶ else if (strcasecmp(key, "CharMax") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "CharMax") == 0) 0 348 348
618 0 RETVAL = newSVuv(self->charmax);
619 348 ▶ else if (strcasecmp(key, "ColMax") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "ColMax") == 0) 54 294 348
620 54 RETVAL = newSVnv((NV)self->colmax);
621 294 ▶ else if (strcasecmp(key, "ColMin") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "ColMin") == 0) 0 294 294
622 0 RETVAL = newSVnv((NV)self->colmin);
623 294 ▶ else if (strcasecmp(key, "ComplexBreaking") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "ComplexBreaking") == 0) 0 294 294
624 0 RETVAL = newSVuv(self->options &
625 LINEBREAK_OPTION_COMPLEX_BREAKING);
626 294 ▶ else if (strcasecmp(key, "Context") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "Context") == 0) { 0 294 294
627 0 ▶ if (self->options & LINEBREAK_OPTION_EASTASIAN_CONTEXT)
Branch: 1 branch
BranchTrueFalseTotal
if (self->options & LINEBREAK_OPTION_EASTASIAN_CONTEXT) 0 0 0
628 0 RETVAL = newSVpvn("EASTASIAN", 9);
629 else
630 0 RETVAL = newSVpvn("NONEASTASIAN", 12);
631 294 ▶ } else if (strcasecmp(key, "EAWidth") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "EAWidth") == 0) { 0 294 294
632 0 AV *av, *codes = NULL, *ret = NULL;
633 0 propval_t p = PROP_UNKNOWN;
634 unichar_t c;
635 size_t i;
636  
637 0 ▶ if (self->map == NULL || self->mapsiz == 0)
Branch: 2 branches
BranchTrueFalseTotal
if (self->map == NULL || self->mapsiz == 0) 0 0 0
if (self->map == NULL || self->mapsiz == 0) 0 0 0
638 0 XSRETURN_UNDEF;
639  
640 0 ▶ for (i = 0; i < self->mapsiz; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < self->mapsiz; i++) 0 0 0
641 0 ▶ if (self->map[i].eaw != PROP_UNKNOWN) {
Branch: 1 branch
BranchTrueFalseTotal
if (self->map[i].eaw != PROP_UNKNOWN) { 0 0 0
642 0 ▶ if (p != self->map[i].eaw){
Branch: 1 branch
BranchTrueFalseTotal
if (p != self->map[i].eaw){ 0 0 0
643 0 p = self->map[i].eaw;
644 0 codes = newAV();
645 0 av = newAV();
646 0 av_push(av, newRV_noinc((SV *)codes));
647 0 av_push(av, newSViv((IV)p));
648 0 ▶ if (ret == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (ret == NULL) 0 0 0
649 0 ret = newAV();
650 0 av_push(ret, newRV_noinc((SV *)av));
651 }
652 0 ▶ for (c = self->map[i].beg; c <= self->map[i].end; c++)
Branch: 1 branch
BranchTrueFalseTotal
for (c = self->map[i].beg; c <= self->map[i].end; c++) 0 0 0
653 0 av_push(codes, newSVuv(c));
654 }
655  
656 0 ▶ if (ret == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (ret == NULL) 0 0 0
657 0 XSRETURN_UNDEF;
658 0 RETVAL = newRV_noinc((SV *)ret);
659 294 ▶ } else if (strcasecmp(key, "Format") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Format") == 0) { 0 294 294
660 0 func = self->format_func;
661 0 ▶ if (func == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (func == NULL) 0 0 0
662 0 XSRETURN_UNDEF;
663 0 ▶ else if (func == linebreak_format_NEWLINE)
Branch: 1 branch
BranchTrueFalseTotal
else if (func == linebreak_format_NEWLINE) 0 0 0
664 0 RETVAL = newSVpvn("NEWLINE", 7);
665 0 ▶ else if (func == linebreak_format_SIMPLE)
Branch: 1 branch
BranchTrueFalseTotal
else if (func == linebreak_format_SIMPLE) 0 0 0
666 0 RETVAL = newSVpvn("SIMPLE", 6);
667 0 ▶ else if (func == linebreak_format_TRIM)
Branch: 1 branch
BranchTrueFalseTotal
else if (func == linebreak_format_TRIM) 0 0 0
668 0 RETVAL = newSVpvn("TRIM", 4);
669 0 ▶ else if (func == format_func) {
Branch: 1 branch
BranchTrueFalseTotal
else if (func == format_func) { 0 0 0
670 0 ▶ if ((val = (SV *)self->format_data) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((val = (SV *)self->format_data) == NULL) 0 0 0
671 0 XSRETURN_UNDEF;
672 0 ST(0) = val; /* should not be mortal. */
673 0 XSRETURN(1);
674 } else
675 0 croak("_config: internal error");
676 294 ▶ } else if (strcasecmp(key, "HangulAsAL") == 0)
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "HangulAsAL") == 0) 0 294 294
677 0 RETVAL = newSVuv(self->options &
678 LINEBREAK_OPTION_HANGUL_AS_AL);
679 294 ▶ else if (strcasecmp(key, "LBClass") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "LBClass") == 0) { 0 294 294
680 0 AV *av, *codes = NULL, *ret = NULL;
681 0 propval_t p = PROP_UNKNOWN;
682 unichar_t c;
683 size_t i;
684  
685 0 ▶ if (self->map == NULL || self->mapsiz == 0)
Branch: 2 branches
BranchTrueFalseTotal
if (self->map == NULL || self->mapsiz == 0) 0 0 0
if (self->map == NULL || self->mapsiz == 0) 0 0 0
686 0 XSRETURN_UNDEF;
687  
688 0 ▶ for (i = 0; i < self->mapsiz; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < self->mapsiz; i++) 0 0 0
689 0 ▶ if (self->map[i].lbc != PROP_UNKNOWN) {
Branch: 1 branch
BranchTrueFalseTotal
if (self->map[i].lbc != PROP_UNKNOWN) { 0 0 0
690 0 ▶ if (p != self->map[i].lbc){
Branch: 1 branch
BranchTrueFalseTotal
if (p != self->map[i].lbc){ 0 0 0
691 0 p = self->map[i].lbc;
692 0 codes = newAV();
693 0 av = newAV();
694 0 av_push(av, newRV_noinc((SV *)codes));
695 0 av_push(av, newSViv((IV)p));
696 0 ▶ if (ret == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (ret == NULL) 0 0 0
697 0 ret = newAV();
698 0 av_push(ret, newRV_noinc((SV *)av));
699 }
700 0 ▶ for (c = self->map[i].beg; c <= self->map[i].end; c++)
Branch: 1 branch
BranchTrueFalseTotal
for (c = self->map[i].beg; c <= self->map[i].end; c++) 0 0 0
701 0 av_push(codes, newSVuv(c));
702 }
703  
704 0 ▶ if (ret == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (ret == NULL) 0 0 0
705 0 XSRETURN_UNDEF;
706 0 RETVAL = newRV_noinc((SV *)ret);
707 294 ▶ } else if (strcasecmp(key, "LegacyCM") == 0)
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "LegacyCM") == 0) 0 294 294
708 0 RETVAL = newSVuv(self->options & LINEBREAK_OPTION_LEGACY_CM);
709 294 ▶ else if (strcasecmp(key, "Newline") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "Newline") == 0) { 294 0 294
710 294 unistr_t unistr = {self->newline.str, self->newline.len};
711 294 ▶ if (self->newline.str == NULL || self->newline.len == 0)
Branch: 2 branches
BranchTrueFalseTotal
if (self->newline.str == NULL || self->newline.len == 0) 294 0 294
if (self->newline.str == NULL || self->newline.len == 0) 0 294 294
712 0 RETVAL = unistrtoSV(&unistr, 0, 0);
713 else
714 294 RETVAL = unistrtoSV(&unistr, 0, self->newline.len);
715 0 ▶ } else if (strcasecmp(key, "Prep") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Prep") == 0) { 0 0 0
716 AV *av;
717 0 ▶ if (self->prep_func == NULL || self->prep_func[0] == NULL)
Branch: 2 branches
BranchTrueFalseTotal
if (self->prep_func == NULL || self->prep_func[0] == NULL) 0 0 0
if (self->prep_func == NULL || self->prep_func[0] == NULL) 0 0 0
718 0 XSRETURN_UNDEF;
719 0 av = newAV();
720 0 ▶ for (i = 0; (func = self->prep_func[i]) != NULL; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; (func = self->prep_func[i]) != NULL; i++) 0 0 0
721 0 ▶ if (func == linebreak_prep_URIBREAK) {
Branch: 1 branch
BranchTrueFalseTotal
if (func == linebreak_prep_URIBREAK) { 0 0 0
722 0 ▶ if (self->prep_data == NULL ||
Branch: 1 branch
BranchTrueFalseTotal
if (self->prep_data == NULL || 0 0 0
723 0 ▶ self->prep_data[i] == NULL)
Branch: 1 branch
BranchTrueFalseTotal
self->prep_data[i] == NULL) 0 0 0
724 0 av_push(av, newSVpvn("NONBREAKURI", 11));
725 else
726 0 av_push(av, newSVpvn("BREAKURI", 8));
727 0 ▶ } else if (func == prep_func) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (func == prep_func) { 0 0 0
728 0 ▶ if (self->prep_data == NULL ||
Branch: 1 branch
BranchTrueFalseTotal
if (self->prep_data == NULL || 0 0 0
729 0 ▶ self->prep_data[i] == NULL)
Branch: 1 branch
BranchTrueFalseTotal
self->prep_data[i] == NULL) 0 0 0
730 0 croak("_config: internal error");
731 0 SvREFCNT_inc(self->prep_data[i]); /* avoid freed */
732 0 av_push(av, self->prep_data[i]);
733 } else
734 0 croak("_config: internal error");
735 0 RETVAL = newRV_noinc((SV *)av);
736 0 ▶ } else if (strcasecmp(key, "Sizing") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Sizing") == 0) { 0 0 0
737 0 func = self->sizing_func;
738 0 ▶ if (func == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (func == NULL) 0 0 0
739 0 XSRETURN_UNDEF;
740 0 ▶ else if (func == linebreak_sizing_UAX11)
Branch: 1 branch
BranchTrueFalseTotal
else if (func == linebreak_sizing_UAX11) 0 0 0
741 0 RETVAL = newSVpvn("UAX11", 5);
742 0 ▶ else if (func == sizing_func) {
Branch: 1 branch
BranchTrueFalseTotal
else if (func == sizing_func) { 0 0 0
743 0 ▶ if ((val = (SV *)self->sizing_data) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((val = (SV *)self->sizing_data) == NULL) 0 0 0
744 0 XSRETURN_UNDEF;
745 0 ST(0) = val; /* should not be mortal. */
746 0 XSRETURN(1);
747 } else
748 0 croak("_config: internal error");
749 0 ▶ } else if (strcasecmp(key, "Urgent") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Urgent") == 0) { 0 0 0
750 0 func = self->urgent_func;
751 0 ▶ if (func == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (func == NULL) 0 0 0
752 0 XSRETURN_UNDEF;
753 0 ▶ else if (func == linebreak_urgent_ABORT)
Branch: 1 branch
BranchTrueFalseTotal
else if (func == linebreak_urgent_ABORT) 0 0 0
754 0 RETVAL = newSVpvn("CROAK", 5);
755 0 ▶ else if (func == linebreak_urgent_FORCE)
Branch: 1 branch
BranchTrueFalseTotal
else if (func == linebreak_urgent_FORCE) 0 0 0
756 0 RETVAL = newSVpvn("FORCE", 5);
757 0 ▶ else if (func == urgent_func) {
Branch: 1 branch
BranchTrueFalseTotal
else if (func == urgent_func) { 0 0 0
758 0 ▶ if ((val = (SV *)self->urgent_data) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((val = (SV *)self->urgent_data) == NULL) 0 0 0
759 0 XSRETURN_UNDEF;
760 0 ST(0) = val; /* should not be mortal. */
761 0 XSRETURN(1);
762 } else
763 0 croak("_config: internal error");
764 0 ▶ } else if (strcasecmp(key, "ViramaAsJoiner") == 0)
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "ViramaAsJoiner") == 0) 0 0 0
765 0 RETVAL = newSVuv(self->options & LINEBREAK_OPTION_VIRAMA_AS_JOINER);
766 else {
767 0 warn("_config: Getting unknown option %s", key);
768 0 XSRETURN_UNDEF;
769 }
770 991 ▶ } else if (!(items % 2))
Branch: 1 branch
BranchTrueFalseTotal
} else if (!(items % 2)) 0 991 991
771 0 croak("_config: Argument size mismatch");
772 9204 ▶ else for (RETVAL = NULL, i = 1; i < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
else for (RETVAL = NULL, i = 1; i < items; i += 2) { 8213 991 9204
773 8213 ▶ if (!SvPOK(ST(i)))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvPOK(ST(i))) 0 8213 8213
774 0 croak("_config: Illegal argument");
775 8213 key = (char *)SvPV_nolen(ST(i));
776 8213 val = ST(i + 1);
777  
778 8213 ▶ if (strcasecmp(key, "Prep") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (strcasecmp(key, "Prep") == 0) { 494 7719 8213
779 SV *sv, *pattern, *func;
780 AV *av;
781 494 REGEXP *rx = NULL;
782  
783 494 ▶ if (! SvOK(val))
Branch: 1 branch
BranchTrueFalseTotal
if (! SvOK(val)) 482 12 494
784 482 linebreak_add_prep(self, NULL, NULL);
785 12 ▶ else if (SvROK(val) &&
Branch: 1 branch
BranchTrueFalseTotal
else if (SvROK(val) && 10 2 12
786 10 ▶ SvTYPE(av = (AV *)SvRV(val)) == SVt_PVAV &&
Branch: 1 branch
BranchTrueFalseTotal
SvTYPE(av = (AV *)SvRV(val)) == SVt_PVAV && 10 0 10
787 10 ▶ 0 < av_len(av) + 1) {
Branch: 1 branch
BranchTrueFalseTotal
0 < av_len(av) + 1) { 10 0 10
788 10 pattern = *av_fetch(av, 0, 0);
789 #if ((PERL_VERSION >= 10) || (PERL_VERSION >= 9 && PERL_SUBVERSION >= 5))
790 10 ▶ if (SvRXOK(pattern))
Branch: 1 branch
BranchTrueFalseTotal
if (SvRXOK(pattern)) 9 1 10
791 9 rx = SvRX(pattern);
792 #else /* PERL_VERSION */
793 if (SvROK(pattern) && SvMAGICAL(sv = SvRV(pattern))) {
794 MAGIC *mg;
795 if ((mg = mg_find(sv, PERL_MAGIC_qr)) != NULL)
796 rx = (REGEXP *)mg->mg_obj;
797 }
798 #endif
799 10 ▶ if (rx != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (rx != NULL) 9 1 10
800 9 SvREFCNT_inc(pattern); /* FIXME:avoid freed */
801 1 ▶ else if (SvOK(pattern)) {
Branch: 1 branch
BranchTrueFalseTotal
else if (SvOK(pattern)) { 1 0 1
802 #if ((PERL_VERSION >= 10) || (PERL_VERSION == 9 && PERL_SUBVERSION >= 5))
803 1 rx = pregcomp(pattern, 0);
804 #else /* PERL_VERSION */
805 {
806 PMOP *pm;
807 New(1, pm, 1, PMOP);
808 rx = pregcomp(SvPVX(pattern), SvEND(pattern), pm);
809 }
810 #endif
811 1 ▶ if (rx != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (rx != NULL) { 1 0 1
812 #if PERL_VERSION >= 11
813 1 pattern = newRV_noinc((SV *)rx);
814 1 sv_bless(pattern, gv_stashpv("Regexp", 0));
815 #else /* PERL_VERSION */
816 sv = newSV(0);
817 sv_magic(sv, (SV *)rx, PERL_MAGIC_qr, NULL, 0);
818 pattern = newRV_noinc(sv);
819 sv_bless(pattern, gv_stashpv("Regexp", 0));
820 #endif
821 }
822 } else
823 0 rx = NULL;
824  
825 10 ▶ if (rx == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (rx == NULL) 0 10 10
826 0 croak("_config: Not a regex");
827  
828 10 ▶ if (av_fetch(av, 1, 0) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (av_fetch(av, 1, 0) == NULL) 0 10 10
829 0 func = NULL;
830 10 ▶ else if (SvOK(func = *av_fetch(av, 1, 0)))
Branch: 1 branch
BranchTrueFalseTotal
else if (SvOK(func = *av_fetch(av, 1, 0))) 10 0 10
831 10 SvREFCNT_inc(func); /* avoid freed */
832 else
833 0 func = NULL;
834  
835 10 av = newAV();
836 10 av_push(av, pattern);
837 10 ▶ if (func != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (func != NULL) 10 0 10
838 10 av_push(av, func);
839 10 sv = newRV_noinc((SV *)av);
840 10 linebreak_add_prep(self, prep_func, (void *)sv);
841 10 SvREFCNT_dec(sv); /* fixup */
842 } else {
843 2 char *s = SvPV_nolen(val);
844  
845 2 ▶ if (strcasecmp(s, "BREAKURI") == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (strcasecmp(s, "BREAKURI") == 0) 1 1 2
846 1 linebreak_add_prep(self, linebreak_prep_URIBREAK, val);
847 1 ▶ else if (strcasecmp(s, "NONBREAKURI") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(s, "NONBREAKURI") == 0) 1 0 1
848 1 linebreak_add_prep(self, linebreak_prep_URIBREAK,
849 NULL);
850 else
851 0 croak("_config: Unknown preprocess option: %s", s);
852 }
853 7719 ▶ } else if (strcasecmp(key, "Format") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Format") == 0) { 507 7212 7719
854 507 ▶ if (! SvOK(val))
Branch: 1 branch
BranchTrueFalseTotal
if (! SvOK(val)) 1 506 507
855 1 linebreak_set_format(self, NULL, NULL);
856 506 ▶ else if (sv_derived_from(val, "CODE"))
Branch: 1 branch
BranchTrueFalseTotal
else if (sv_derived_from(val, "CODE")) 16 490 506
857 16 linebreak_set_format(self, format_func, (void *)val);
858 else {
859 490 char *s = SvPV_nolen(val);
860  
861 490 ▶ if (strcasecmp(s, "DEFAULT") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (strcasecmp(s, "DEFAULT") == 0) { 0 490 490
862 0 warn("_config: "
863 "Method name \"DEFAULT\" for Format option was "
864 "obsoleted. Use \"SIMPLE\"");
865 0 linebreak_set_format(self, linebreak_format_SIMPLE,
866 NULL);
867 490 ▶ } else if (strcasecmp(s, "SIMPLE") == 0)
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(s, "SIMPLE") == 0) 482 8 490
868 482 linebreak_set_format(self, linebreak_format_SIMPLE,
869 NULL);
870 8 ▶ else if (strcasecmp(s, "NEWLINE") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(s, "NEWLINE") == 0) 4 4 8
871 4 linebreak_set_format(self, linebreak_format_NEWLINE,
872 NULL);
873 4 ▶ else if (strcasecmp(s, "TRIM") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(s, "TRIM") == 0) 4 0 4
874 4 linebreak_set_format(self, linebreak_format_TRIM,
875 NULL);
876 else
877 0 croak("_config: Unknown Format option: %s", s);
878 }
879 7212 ▶ } else if (strcasecmp(key, "Sizing") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Sizing") == 0) { 489 6723 7212
880 489 ▶ if (! SvOK(val))
Branch: 1 branch
BranchTrueFalseTotal
if (! SvOK(val)) 0 489 489
881 0 linebreak_set_sizing(self, NULL, NULL);
882 489 ▶ else if (sv_derived_from(val, "CODE"))
Branch: 1 branch
BranchTrueFalseTotal
else if (sv_derived_from(val, "CODE")) 7 482 489
883 7 linebreak_set_sizing(self, sizing_func, (void *)val);
884 else {
885 482 char *s = SvPV_nolen(val);
886  
887 482 ▶ if (strcasecmp(s, "DEFAULT") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (strcasecmp(s, "DEFAULT") == 0) { 0 482 482
888 0 warn("_config: "
889 "Method name \"DEFAULT\" for Sizing option "
890 "was obsoleted. Use \"UAX11\"");
891 0 linebreak_set_sizing(self, linebreak_sizing_UAX11,
892 NULL);
893 482 ▶ } else if (strcasecmp(s, "UAX11") == 0)
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(s, "UAX11") == 0) 482 0 482
894 482 linebreak_set_sizing(self, linebreak_sizing_UAX11,
895 NULL);
896 else
897 0 croak("_config: Unknown Sizing option: %s", s);
898 }
899 6723 ▶ } else if (strcasecmp(key, "Urgent") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Urgent") == 0) { 488 6235 6723
900 488 ▶ if (! SvOK(val))
Branch: 1 branch
BranchTrueFalseTotal
if (! SvOK(val)) 482 6 488
901 482 linebreak_set_urgent(self, NULL, NULL);
902 6 ▶ else if (sv_derived_from(val, "CODE"))
Branch: 1 branch
BranchTrueFalseTotal
else if (sv_derived_from(val, "CODE")) 0 6 6
903 0 linebreak_set_urgent(self, urgent_func, (void *)val);
904 else {
905 6 char *s = SvPV_nolen(val);
906  
907 6 ▶ if (strcasecmp(s, "NONBREAK") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (strcasecmp(s, "NONBREAK") == 0) { 0 6 6
908 0 warn("_config: "
909 "Method name \"NONBREAK\" for Urgent "
910 "option was obsoleted. Use undef");
911 0 linebreak_set_urgent(self, NULL, NULL);
912 6 ▶ } else if (strcasecmp(s, "CROAK") == 0)
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(s, "CROAK") == 0) 2 4 6
913 2 linebreak_set_urgent(self, linebreak_urgent_ABORT,
914 NULL);
915 4 ▶ else if (strcasecmp(s, "FORCE") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(s, "FORCE") == 0) 4 0 4
916 4 linebreak_set_urgent(self, linebreak_urgent_FORCE,
917 NULL);
918 else
919 0 croak("_config: Unknown Urgent option: %s", s);
920 }
921 6235 ▶ } else if (strcasecmp(key, "BreakIndent") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "BreakIndent") == 0) { 357 5878 6235
922 357 ▶ if (SVtoboolean(val))
Branch: 1 branch
BranchTrueFalseTotal
if (SVtoboolean(val)) 356 1 357
923 356 self->options |= LINEBREAK_OPTION_BREAK_INDENT;
924 else
925 1 self->options &= ~LINEBREAK_OPTION_BREAK_INDENT;
926 5878 ▶ } else if (strcasecmp(key, "CharMax") == 0)
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "CharMax") == 0) 484 5394 5878
927 484 self->charmax = SvUV(val);
928 5394 ▶ else if (strcasecmp(key, "ColMax") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "ColMax") == 0) 535 4859 5394
929 535 self->colmax = (double)SvNV(val);
930 4859 ▶ else if (strcasecmp(key, "ColMin") == 0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "ColMin") == 0) 484 4375 4859
931 484 self->colmin = (double)SvNV(val);
932 4375 ▶ else if (strcasecmp(key, "ComplexBreaking") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
else if (strcasecmp(key, "ComplexBreaking") == 0) { 357 4018 4375
933 357 ▶ if (SVtoboolean(val))
Branch: 1 branch
BranchTrueFalseTotal
if (SVtoboolean(val)) 356 1 357
934 356 self->options |= LINEBREAK_OPTION_COMPLEX_BREAKING;
935 else
936 1 self->options &= ~LINEBREAK_OPTION_COMPLEX_BREAKING;
937 4018 ▶ } else if (strcasecmp(key, "Context") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Context") == 0) { 544 3474 4018
938 544 ▶ if (SvOK(val))
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(val)) 544 0 544
939 544 opt = (char *)SvPV_nolen(val);
940 else
941 0 opt = NULL;
942 544 ▶ if (opt && strcasecmp(opt, "EASTASIAN") == 0)
Branch: 2 branches
BranchTrueFalseTotal
if (opt && strcasecmp(opt, "EASTASIAN") == 0) 544 0 544
if (opt && strcasecmp(opt, "EASTASIAN") == 0) 55 489 544
943 55 self->options |= LINEBREAK_OPTION_EASTASIAN_CONTEXT;
944 else
945 489 self->options &= ~LINEBREAK_OPTION_EASTASIAN_CONTEXT;
946 3474 ▶ } else if (strcasecmp(key, "EAWidth") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "EAWidth") == 0) { 484 2990 3474
947 AV *av, *codes;
948 SV *sv;
949 propval_t p;
950 size_t i;
951  
952 484 ▶ if (! SvOK(val))
Branch: 1 branch
BranchTrueFalseTotal
if (! SvOK(val)) 356 128 484
953 356 linebreak_clear_eawidth(self);
954 128 ▶ else if (SvROK(val) &&
Branch: 1 branch
BranchTrueFalseTotal
else if (SvROK(val) && 128 0 128
955 256 SvTYPE(av = (AV *)SvRV(val)) == SVt_PVAV &&
956 256 ▶ av_len(av) + 1 == 2 &&
Branch: 1 branch
BranchTrueFalseTotal
av_len(av) + 1 == 2 && 128 0 128
957 256 ▶ av_fetch(av, 0, 0) != NULL && av_fetch(av, 1, 0) != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
av_fetch(av, 0, 0) != NULL && av_fetch(av, 1, 0) != NULL) { 128 0 128
958 128 sv = *av_fetch(av, 1, 0);
959 128 ▶ if (SvIOK(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (SvIOK(sv)) 128 0 128
960 128 p = (propval_t) SvIV(sv);
961 else
962 0 croak("_config: Invalid argument");
963  
964 128 sv = *av_fetch(av, 0, 0);
965 128 ▶ if (SvROK(sv) &&
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv) && 128 0 128
966 128 ▶ SvTYPE(codes = (AV *)SvRV(sv)) == SVt_PVAV) {
Branch: 1 branch
BranchTrueFalseTotal
SvTYPE(codes = (AV *)SvRV(sv)) == SVt_PVAV) { 128 0 128
967 66084 ▶ for (i = 0; i < av_len(codes) + 1; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < av_len(codes) + 1; i++) { 65956 128 66084
968 65956 ▶ if (av_fetch(codes, i, 0) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (av_fetch(codes, i, 0) == NULL) 0 65956 65956
969 0 continue;
970 65956 ▶ if (! SvIOK(sv = *av_fetch(codes, i, 0)))
Branch: 1 branch
BranchTrueFalseTotal
if (! SvIOK(sv = *av_fetch(codes, i, 0))) 0 65956 65956
971 0 croak("_config: Invalid argument");
972 65956 linebreak_update_eawidth(self,
973 65956 (unichar_t) SvUV(sv), p);
974 }
975 0 ▶ } else if (SvIOK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvIOK(sv)) { 0 0 0
976 0 linebreak_update_eawidth(self, (unichar_t) SvUV(sv),
977 p);
978 } else
979 0 croak("_config: Invalid argument");
980 } else
981 0 croak("_config: Invalid argument");
982 2990 ▶ } else if (strcasecmp(key, "HangulAsAL") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "HangulAsAL") == 0) { 483 2507 2990
983 483 ▶ if (SVtoboolean(val))
Branch: 1 branch
BranchTrueFalseTotal
if (SVtoboolean(val)) 1 482 483
984 1 self->options |= LINEBREAK_OPTION_HANGUL_AS_AL;
985 else
986 482 self->options &= ~LINEBREAK_OPTION_HANGUL_AS_AL;
987 2507 ▶ } else if (strcasecmp(key, "LBClass") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "LBClass") == 0) { 490 2017 2507
988 AV *av, *codes;
989 SV *sv;
990 propval_t p;
991 size_t i;
992  
993 490 ▶ if (! SvOK(val))
Branch: 1 branch
BranchTrueFalseTotal
if (! SvOK(val)) 482 8 490
994 482 linebreak_clear_lbclass(self);
995 8 ▶ else if (SvROK(val) &&
Branch: 1 branch
BranchTrueFalseTotal
else if (SvROK(val) && 8 0 8
996 16 SvTYPE(av = (AV *)SvRV(val)) == SVt_PVAV &&
997 16 ▶ av_len(av) + 1 == 2 &&
Branch: 1 branch
BranchTrueFalseTotal
av_len(av) + 1 == 2 && 8 0 8
998 16 ▶ av_fetch(av, 0, 0) != NULL && av_fetch(av, 1, 0) != NULL) {
Branch: 1 branch
BranchTrueFalseTotal
av_fetch(av, 0, 0) != NULL && av_fetch(av, 1, 0) != NULL) { 8 0 8
999 8 sv = *av_fetch(av, 1, 0);
1000 8 ▶ if (SvIOK(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (SvIOK(sv)) 8 0 8
1001 8 p = (propval_t) SvIV(sv);
1002 else
1003 0 croak("_config: Invalid argument");
1004  
1005 8 sv = *av_fetch(av, 0, 0);
1006 8 ▶ if (SvROK(sv) &&
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv) && 1 7 8
1007 1 ▶ SvTYPE(codes = (AV *)SvRV(sv)) == SVt_PVAV) {
Branch: 1 branch
BranchTrueFalseTotal
SvTYPE(codes = (AV *)SvRV(sv)) == SVt_PVAV) { 1 0 1
1008 59 ▶ for (i = 0; i < av_len(codes) + 1; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < av_len(codes) + 1; i++) { 58 1 59
1009 58 ▶ if (av_fetch(codes, i, 0) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (av_fetch(codes, i, 0) == NULL) 0 58 58
1010 0 continue;
1011 58 ▶ if (! SvIOK(sv = *av_fetch(codes, i, 0)))
Branch: 1 branch
BranchTrueFalseTotal
if (! SvIOK(sv = *av_fetch(codes, i, 0))) 0 58 58
1012 0 croak("_config: Invalid argument");
1013 58 linebreak_update_lbclass(self,
1014 58 (unichar_t) SvUV(sv), p);
1015 }
1016 7 ▶ } else if (SvIOK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvIOK(sv)) { 7 0 7
1017 7 linebreak_update_lbclass(self, (unichar_t) SvUV(sv),
1018 p);
1019 } else
1020 0 croak("_config: Invalid argument");
1021 } else
1022 0 croak("_config: Invalid argument");
1023 2017 ▶ } else if (strcasecmp(key, "LegacyCM") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "LegacyCM") == 0) { 831 1186 2017
1024 831 ▶ if (SVtoboolean(val))
Branch: 1 branch
BranchTrueFalseTotal
if (SVtoboolean(val)) 830 1 831
1025 830 self->options |= LINEBREAK_OPTION_LEGACY_CM;
1026 else
1027 1 self->options &= ~LINEBREAK_OPTION_LEGACY_CM;
1028 1186 ▶ } else if (strcasecmp(key, "Newline") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "Newline") == 0) { 482 704 1186
1029 482 ▶ if (!sv_isobject(val)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_isobject(val)) { 482 0 482
1030 482 unistr_t unistr = {NULL, 0};
1031 482 SVtounistr(&unistr, val);
1032 482 linebreak_set_newline(self, &unistr);
1033 482 free(unistr.str);
1034 0 ▶ } else if (sv_derived_from(val, "Unicode::GCString"))
Branch: 1 branch
BranchTrueFalseTotal
} else if (sv_derived_from(val, "Unicode::GCString")) 0 0 0
1035 0 linebreak_set_newline(self,
1036 0 (unistr_t *)PerltoC(gcstring_t *,
1037 val));
1038 else
1039 0 ▶ croak("_config: Unknown object %s",
Branch: 6 branches
BranchTrueFalseTotal
croak("_config: Unknown object %s", 0 0 0
croak("_config: Unknown object %s", 0 0 0
croak("_config: Unknown object %s", 0 0 0
croak("_config: Unknown object %s", 0 0 0
croak("_config: Unknown object %s", 0 0 0
croak("_config: Unknown object %s", 0 0 0
1040 HvNAME(SvSTASH(SvRV(val))));
1041 704 ▶ } else if (strcasecmp(key, "ViramaAsJoiner") == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (strcasecmp(key, "ViramaAsJoiner") == 0) { 704 0 704
1042 704 ▶ if (SVtoboolean(val))
Branch: 1 branch
BranchTrueFalseTotal
if (SVtoboolean(val)) 356 348 704
1043 356 self->options |= LINEBREAK_OPTION_VIRAMA_AS_JOINER;
1044 else
1045 348 self->options &= ~LINEBREAK_OPTION_VIRAMA_AS_JOINER;
1046 } else
1047 0 warn("_config: Setting unknown option %s", key);
1048 }
1049 OUTPUT:
1050 RETVAL
1051  
1052 void
1053 as_hashref(self, ...)
1054 linebreak_t *self;
1055 CODE:
1056 2937 ▶ if (self->stash == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (self->stash == NULL) 0 2937 2937
1057 0 XSRETURN_UNDEF;
1058 2937 ST(0) = self->stash; /* should not be mortal */
1059 2937 XSRETURN(1);
1060  
1061 SV*
1062 as_scalarref(self, ...)
1063 linebreak_t *self;
1064 PREINIT:
1065 char buf[64];
1066 CODE:
1067 0 buf[0] = '\0';
1068 0 ▶ snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))),
Branch: 6 branches
BranchTrueFalseTotal
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
1069 (unsigned long)(void *)self);
1070 0 RETVAL = newRV_noinc(newSVpv(buf, 0));
1071 OUTPUT:
1072 RETVAL
1073  
1074 SV *
1075 as_string(self, ...)
1076 linebreak_t *self;
1077 PREINIT:
1078 char buf[64];
1079 CODE:
1080 0 buf[0] = '\0';
1081 0 ▶ snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))),
Branch: 6 branches
BranchTrueFalseTotal
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
1082 (unsigned long)(void *)self);
1083 0 RETVAL = newSVpv(buf, 0);
1084 OUTPUT:
1085 RETVAL
1086  
1087 propval_t
1088 lbrule(self, b_idx, a_idx)
1089 linebreak_t *self;
1090 propval_t b_idx;
1091 propval_t a_idx;
1092 PROTOTYPE: $$$
1093 CODE:
1094 0 warn("lbrule() is obsoleted. Use breakingRule()");
1095 0 ▶ if (!SvOK(ST(1)) || !SvOK(ST(2)))
Branch: 2 branches
BranchTrueFalseTotal
if (!SvOK(ST(1)) || !SvOK(ST(2))) 0 0 0
if (!SvOK(ST(1)) || !SvOK(ST(2))) 0 0 0
1096 0 XSRETURN_UNDEF;
1097 0 ▶ if (self == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (self == NULL) 0 0 0
1098 0 XSRETURN_UNDEF;
1099 0 RETVAL = linebreak_get_lbrule(self, b_idx, a_idx);
1100 0 ▶ if (RETVAL == PROP_UNKNOWN)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == PROP_UNKNOWN) 0 0 0
1101 0 XSRETURN_UNDEF;
1102 OUTPUT:
1103 RETVAL
1104  
1105 propval_t
1106 breakingRule(lbobj, bgcstr, agcstr)
1107 linebreak_t *lbobj;
1108 generic_string bgcstr;
1109 generic_string agcstr;
1110 PROTOTYPE: $$$
1111 PREINIT:
1112 propval_t blbc, albc;
1113 CODE:
1114 18 ▶ if (!SvOK(ST(1)) || !SvOK(ST(2)))
Branch: 2 branches
BranchTrueFalseTotal
if (!SvOK(ST(1)) || !SvOK(ST(2))) 18 0 18
if (!SvOK(ST(1)) || !SvOK(ST(2))) 0 18 18
1115 0 XSRETURN_UNDEF;
1116 18 ▶ if (lbobj == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (lbobj == NULL) 0 18 18
1117 0 XSRETURN_UNDEF;
1118 18 ▶ if ((blbc = gcstring_lbclass_ext(bgcstr, -1)) == PROP_UNKNOWN)
Branch: 1 branch
BranchTrueFalseTotal
if ((blbc = gcstring_lbclass_ext(bgcstr, -1)) == PROP_UNKNOWN) 0 18 18
1119 0 XSRETURN_UNDEF;
1120 18 ▶ if ((albc = gcstring_lbclass(agcstr, 0)) == PROP_UNKNOWN)
Branch: 1 branch
BranchTrueFalseTotal
if ((albc = gcstring_lbclass(agcstr, 0)) == PROP_UNKNOWN) 0 18 18
1121 0 XSRETURN_UNDEF;
1122 18 RETVAL = linebreak_get_lbrule(lbobj, blbc, albc);
1123 18 ▶ if (RETVAL == PROP_UNKNOWN)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == PROP_UNKNOWN) 0 18 18
1124 0 XSRETURN_UNDEF;
1125 OUTPUT:
1126 RETVAL
1127  
1128 void
1129 reset(self)
1130 linebreak_t *self;
1131 PROTOTYPE: $
1132 CODE:
1133 0 linebreak_reset(self);
1134  
1135 double
1136 strsize(lbobj, len, pre, spc, str, ...)
1137 linebreak_t *lbobj;
1138 double len;
1139 SV *pre;
1140 generic_string spc;
1141 generic_string str;
1142 PROTOTYPE: $$$$$;$
1143 CODE:
1144 0 warn("strsize() is obsoleted. Use Unicode::GCString::columns");
1145 0 ▶ if (5 < items)
Branch: 1 branch
BranchTrueFalseTotal
if (5 < items) 0 0 0
1146 0 warn("``max'' argument of strsize was obsoleted");
1147  
1148 0 RETVAL = linebreak_sizing_UAX11(lbobj, len, NULL, spc, str);
1149 0 ▶ if (RETVAL == -1.0)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == -1.0) 0 0 0
1150 0 croak("strsize: %s", strerror(lbobj->errnum));
1151 OUTPUT:
1152 RETVAL
1153  
1154 void
1155 break(self, input)
1156 linebreak_t *self;
1157 unistr_t *input;
1158 PROTOTYPE: $$
1159 PREINIT:
1160 gcstring_t **ret, *r;
1161 size_t i;
1162 PPCODE:
1163 6381 ▶ if (input == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (input == NULL) 0 6381 6381
1164 0 XSRETURN_UNDEF;
1165 6381 ret = linebreak_break(self, input);
1166  
1167 6381 ▶ if (ret == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (ret == NULL) { 2 6379 6381
1168 2 ▶ if (self->errnum == LINEBREAK_EEXTN)
Branch: 1 branch
BranchTrueFalseTotal
if (self->errnum == LINEBREAK_EEXTN) 0 2 2
1169 0 ▶ croak("%s", SvPV_nolen(ERRSV));
Branch: 1 branch
BranchTrueFalseTotal
croak("%s", SvPV_nolen(ERRSV)); 0 0 0
1170 2 ▶ else if (self->errnum == LINEBREAK_ELONG)
Branch: 1 branch
BranchTrueFalseTotal
else if (self->errnum == LINEBREAK_ELONG) 2 0 2
1171 2 croak("%s", "Excessive line was found");
1172 0 ▶ else if (self->errnum)
Branch: 1 branch
BranchTrueFalseTotal
else if (self->errnum) 0 0 0
1173 0 croak("%s", strerror(self->errnum));
1174 else
1175 0 croak("%s", "Unknown error");
1176 }
1177  
1178 6379 switch (GIMME_V) {
1179 50 case G_SCALAR:
1180 50 r = gcstring_new(NULL, self);
1181 1167 ▶ for (i = 0; ret[i] != NULL; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; ret[i] != NULL; i++) 1117 50 1167
1182 1117 gcstring_append(r, ret[i]);
1183 50 linebreak_free_result(ret, 1);
1184 50 ▶ XPUSHs(sv_2mortal(unistrtoSV((unistr_t *)r, 0, r->len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(unistrtoSV((unistr_t *)r, 0, r->len))); 0 50 50
1185 50 gcstring_destroy(r);
1186 50 XSRETURN(1);
1187  
1188 6329 case G_ARRAY:
1189 17128 ▶ for (i = 0; ret[i] != NULL; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; ret[i] != NULL; i++) 10799 6329 17128
1190 10799 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", ret[i])));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", ret[i]))); 0 10799 10799
1191 6329 linebreak_free_result(ret, 0);
1192 6329 XSRETURN(i);
1193  
1194 0 default:
1195 0 linebreak_free_result(ret, 1);
1196 0 XSRETURN_EMPTY;
1197 }
1198  
1199 void
1200 break_partial(self, input)
1201 linebreak_t *self;
1202 unistr_t *input;
1203 PROTOTYPE: $$
1204 PREINIT:
1205 gcstring_t **ret, *r;
1206 size_t i;
1207 PPCODE:
1208 2346 ret = linebreak_break_partial(self, input);
1209  
1210 2346 ▶ if (ret == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (ret == NULL) { 0 2346 2346
1211 0 ▶ if (self->errnum == LINEBREAK_EEXTN)
Branch: 1 branch
BranchTrueFalseTotal
if (self->errnum == LINEBREAK_EEXTN) 0 0 0
1212 0 ▶ croak("%s", SvPV_nolen(ERRSV));
Branch: 1 branch
BranchTrueFalseTotal
croak("%s", SvPV_nolen(ERRSV)); 0 0 0
1213 0 ▶ else if (self->errnum == LINEBREAK_ELONG)
Branch: 1 branch
BranchTrueFalseTotal
else if (self->errnum == LINEBREAK_ELONG) 0 0 0
1214 0 croak("%s", "Excessive line was found");
1215 0 ▶ else if (self->errnum)
Branch: 1 branch
BranchTrueFalseTotal
else if (self->errnum) 0 0 0
1216 0 croak("%s", strerror(self->errnum));
1217 else
1218 0 croak("%s", "Unknown error");
1219 }
1220  
1221 2346 switch (GIMME_V) {
1222 2346 case G_SCALAR:
1223 2346 r = gcstring_new(NULL, self);
1224 2640 ▶ for (i = 0; ret[i] != NULL; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; ret[i] != NULL; i++) 294 2346 2640
1225 294 gcstring_append(r, ret[i]);
1226 2346 linebreak_free_result(ret, 1);
1227 2346 ▶ XPUSHs(sv_2mortal(unistrtoSV((unistr_t *)r, 0, r->len)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(unistrtoSV((unistr_t *)r, 0, r->len))); 0 2346 2346
1228 2346 gcstring_destroy(r);
1229 2346 XSRETURN(1);
1230  
1231 0 case G_ARRAY:
1232 0 ▶ for (i = 0; ret[i] != NULL; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; ret[i] != NULL; i++) 0 0 0
1233 0 ▶ XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", ret[i])));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(CtoPerl("Unicode::GCString", ret[i]))); 0 0 0
1234 0 linebreak_free_result(ret, 0);
1235 0 XSRETURN(i);
1236  
1237 0 default:
1238 0 linebreak_free_result(ret, 1);
1239 0 XSRETURN_EMPTY;
1240 }
1241  
1242 const char *
1243 UNICODE_VERSION()
1244 CODE:
1245 1 RETVAL = linebreak_unicode_version;
1246 OUTPUT:
1247 RETVAL
1248  
1249 const char *
1250 SOMBOK_VERSION()
1251 CODE:
1252 1 RETVAL = SOMBOK_VERSION;
1253 OUTPUT:
1254 RETVAL
1255  
1256  
1257 MODULE = Unicode::LineBreak PACKAGE = Unicode::LineBreak::SouthEastAsian
1258  
1259 const char *
1260 supported()
1261 PROTOTYPE:
1262 CODE:
1263 4 RETVAL = linebreak_southeastasian_supported;
1264 4 ▶ if (RETVAL == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == NULL) 4 0 4
1265 4 XSRETURN_UNDEF;
1266 OUTPUT:
1267 RETVAL
1268  
1269 MODULE = Unicode::LineBreak PACKAGE = Unicode::GCString
1270  
1271 gcstring_t *
1272 _new(klass, str, lbobj=NULL)
1273 char *klass;
1274 unistr_t *str;
1275 linebreak_t *lbobj;
1276 PROTOTYPE: $$;$
1277 CODE:
1278 416 ▶ if (str == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (str == NULL) 0 416 416
1279 0 XSRETURN_UNDEF;
1280 /* FIXME:buffer is copied twice. */
1281 416 ▶ if ((RETVAL = gcstring_newcopy(str, lbobj)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((RETVAL = gcstring_newcopy(str, lbobj)) == NULL) 0 416 416
1282 0 croak("%s->_new: %s", klass, strerror(errno));
1283 OUTPUT:
1284 RETVAL
1285  
1286 void
1287 DESTROY(self)
1288 gcstring_t *self;
1289 PROTOTYPE: $
1290 CODE:
1291 39023 gcstring_destroy(self);
1292  
1293 void
1294 as_array(self)
1295 gcstring_t *self;
1296 PROTOTYPE: $
1297 PREINIT:
1298 size_t i;
1299 PPCODE:
1300 356 ▶ if (self != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (self != NULL) 356 0 356
1301 1045 ▶ for (i = 0; i < self->gclen; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < self->gclen; i++) 689 356 1045
1302 689 ▶ XPUSHs(sv_2mortal(
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal( 0 689 689
1303 CtoPerl("Unicode::GCString",
1304 gcstring_substr(self, i, 1))));
1305  
1306 SV*
1307 as_scalarref(self, ...)
1308 gcstring_t *self;
1309 PREINIT:
1310 char buf[64];
1311 CODE:
1312 0 buf[0] = '\0';
1313 0 ▶ snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))),
Branch: 6 branches
BranchTrueFalseTotal
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
snprintf(buf, 64, "%s(0x%lx)", HvNAME(SvSTASH(SvRV(ST(0)))), 0 0 0
1314 (unsigned long)(void *)self);
1315 0 RETVAL = newRV_noinc(newSVpv(buf, 0));
1316 OUTPUT:
1317 RETVAL
1318  
1319 SV *
1320 as_string(self, ...)
1321 gcstring_t *self;
1322 PROTOTYPE: $;$;$
1323 CODE:
1324 11734 RETVAL = unistrtoSV((unistr_t *)self, 0, self->len);
1325 OUTPUT:
1326 RETVAL
1327  
1328 size_t
1329 chars(self)
1330 gcstring_t *self;
1331 PROTOTYPE: $
1332 CODE:
1333 5 ▶ RETVAL = self->len;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->len; 0 5 5
1334 OUTPUT:
1335 RETVAL
1336  
1337 #define lbobj self->lbobj
1338 int
1339 cmp(self, str, swap=FALSE)
1340 gcstring_t *self;
1341 generic_string str;
1342 swapspec_t swap;
1343 PROTOTYPE: $$;$
1344 CODE:
1345 1033 ▶ if (swap == TRUE)
Branch: 1 branch
BranchTrueFalseTotal
if (swap == TRUE) 0 1033 1033
1346 0 RETVAL = gcstring_cmp(str, self);
1347 else
1348 1033 RETVAL = gcstring_cmp(self, str);
1349 OUTPUT:
1350 RETVAL
1351  
1352 size_t
1353 columns(self)
1354 gcstring_t *self;
1355 CODE:
1356 3385 RETVAL = gcstring_columns(self);
1357 OUTPUT:
1358 RETVAL
1359  
1360 #define lbobj self->lbobj
1361 gcstring_t *
1362 concat(self, str, swap=FALSE)
1363 gcstring_t *self;
1364 generic_string str;
1365 swapspec_t swap;
1366 PROTOTYPE: $$;$
1367 CODE:
1368 2449 ▶ if (swap == TRUE)
Branch: 1 branch
BranchTrueFalseTotal
if (swap == TRUE) 106 2343 2449
1369 106 RETVAL = gcstring_concat(str, self);
1370 2343 ▶ else if (swap == -1) {
Branch: 1 branch
BranchTrueFalseTotal
else if (swap == -1) { 9 2334 2343
1371 9 gcstring_append(self, str);
1372 9 XSRETURN(1);
1373 } else
1374 2334 RETVAL = gcstring_concat(self, str);
1375 OUTPUT:
1376 RETVAL
1377  
1378 gcstring_t *
1379 copy(self)
1380 gcstring_t *self;
1381 PROTOTYPE: $
1382 CODE:
1383 1 RETVAL = gcstring_copy(self);
1384 OUTPUT:
1385 RETVAL
1386  
1387 int
1388 eos(self)
1389 gcstring_t *self;
1390 CODE:
1391 3334 ▶ RETVAL = gcstring_eos(self);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = gcstring_eos(self); 3328 6 3334
1392 OUTPUT:
1393 RETVAL
1394  
1395 unsigned int
1396 flag(self, ...)
1397 gcstring_t *self;
1398 PROTOTYPE: $;$;$
1399 PREINIT:
1400 int i;
1401 unsigned int flag;
1402 CODE:
1403 0 warn("flag() will be deprecated in near future");
1404 0 ▶ if (1 < items)
Branch: 1 branch
BranchTrueFalseTotal
if (1 < items) 0 0 0
1405 0 i = SvIV(ST(1));
1406 else
1407 0 i = self->pos;
1408 0 ▶ if (i < 0 || self == NULL || self->gclen <= i)
Branch: 3 branches
BranchTrueFalseTotal
if (i < 0 || self == NULL || self->gclen <= i) 0 0 0
if (i < 0 || self == NULL || self->gclen <= i) 0 0 0
if (i < 0 || self == NULL || self->gclen <= i) 0 0 0
1409 0 XSRETURN_UNDEF;
1410 0 ▶ if (2 < items) {
Branch: 1 branch
BranchTrueFalseTotal
if (2 < items) { 0 0 0
1411 0 flag = SvUV(ST(2));
1412 0 ▶ if (flag == (flag & 255))
Branch: 1 branch
BranchTrueFalseTotal
if (flag == (flag & 255)) 0 0 0
1413 0 self->gcstr[i].flag = (unsigned char)flag;
1414 else
1415 0 warn("flag: unknown flag(s)");
1416 }
1417 0 ▶ RETVAL = (unsigned int)self->gcstr[i].flag;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (unsigned int)self->gcstr[i].flag; 0 0 0
1418 OUTPUT:
1419 RETVAL
1420  
1421 gcstring_t *
1422 item(self, ...)
1423 gcstring_t *self;
1424 PROTOTYPE: $;$
1425 PREINIT:
1426 int i;
1427 CODE:
1428 3301 ▶ if (1 < items)
Branch: 1 branch
BranchTrueFalseTotal
if (1 < items) 0 3301 3301
1429 0 i = SvIV(ST(1));
1430 else
1431 3301 i = self->pos;
1432 3301 ▶ if (i < 0 || self == NULL || self->gclen <= i)
Branch: 3 branches
BranchTrueFalseTotal
if (i < 0 || self == NULL || self->gclen <= i) 3301 0 3301
if (i < 0 || self == NULL || self->gclen <= i) 3301 0 3301
if (i < 0 || self == NULL || self->gclen <= i) 0 3301 3301
1433 0 XSRETURN_UNDEF;
1434  
1435 3301 RETVAL = gcstring_substr(self, i, 1);
1436 OUTPUT:
1437 RETVAL
1438  
1439 gcstring_t *
1440 join(self, ...)
1441 gcstring_t *self;
1442 PREINIT:
1443 size_t i;
1444 gcstring_t *str;
1445 CODE:
1446 0 switch (items) {
1447 0 case 0:
1448 0 croak("join: Too few arguments");
1449 0 case 1:
1450 0 RETVAL = gcstring_new(NULL, self->lbobj);
1451 0 break;
1452 0 case 2:
1453 0 RETVAL = SVtogcstring(ST(1), self->lbobj);
1454 0 ▶ if (sv_isobject(ST(1)))
Branch: 1 branch
BranchTrueFalseTotal
if (sv_isobject(ST(1))) 0 0 0
1455 0 RETVAL = gcstring_copy(RETVAL);
1456 0 break;
1457 0 default:
1458 0 RETVAL = SVtogcstring(ST(1), self->lbobj);
1459 0 ▶ if (sv_isobject(ST(1)))
Branch: 1 branch
BranchTrueFalseTotal
if (sv_isobject(ST(1))) 0 0 0
1460 0 RETVAL = gcstring_copy(RETVAL);
1461 0 ▶ for (i = 2; i < items; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 2; i < items; i++) { 0 0 0
1462 0 gcstring_append(RETVAL, self);
1463 0 str = SVtogcstring(ST(i), self->lbobj);
1464 0 gcstring_append(RETVAL, str);
1465 0 ▶ if (!sv_isobject(ST(i)))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_isobject(ST(i))) 0 0 0
1466 0 gcstring_destroy(str);
1467 }
1468 0 break;
1469 }
1470 OUTPUT:
1471 RETVAL
1472  
1473 propval_t
1474 lbc(self)
1475 gcstring_t *self;
1476 PROTOTYPE: $
1477 CODE:
1478 3355 ▶ if ((RETVAL = gcstring_lbclass(self, 0)) == PROP_UNKNOWN)
Branch: 1 branch
BranchTrueFalseTotal
if ((RETVAL = gcstring_lbclass(self, 0)) == PROP_UNKNOWN) 0 3355 3355
1479 0 XSRETURN_UNDEF;
1480 OUTPUT:
1481 RETVAL
1482  
1483 propval_t
1484 lbcext(self)
1485 gcstring_t *self;
1486 PROTOTYPE: $
1487 CODE:
1488 0 ▶ if ((RETVAL = gcstring_lbclass_ext(self, -1)) == PROP_UNKNOWN)
Branch: 1 branch
BranchTrueFalseTotal
if ((RETVAL = gcstring_lbclass_ext(self, -1)) == PROP_UNKNOWN) 0 0 0
1489 0 XSRETURN_UNDEF;
1490 OUTPUT:
1491 RETVAL
1492  
1493 propval_t
1494 lbclass(self, ...)
1495 gcstring_t *self;
1496 PROTOTYPE: $;$
1497 PREINIT:
1498 int i;
1499 CODE:
1500 0 warn("lbclass() is obsoleted. Use lbc()");
1501 0 ▶ if (1 < items)
Branch: 1 branch
BranchTrueFalseTotal
if (1 < items) 0 0 0
1502 0 i = SvIV(ST(1));
1503 else
1504 0 i = self->pos;
1505 0 RETVAL = gcstring_lbclass(self, i);
1506 0 ▶ if (RETVAL == PROP_UNKNOWN)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == PROP_UNKNOWN) 0 0 0
1507 0 XSRETURN_UNDEF;
1508 OUTPUT:
1509 RETVAL
1510  
1511 propval_t
1512 lbclass_ext(self, ...)
1513 gcstring_t *self;
1514 PROTOTYPE: $;$
1515 PREINIT:
1516 int i;
1517 CODE:
1518 0 warn("lbclass_ext() is obsoleted. Use lbcext()");
1519 0 ▶ if (1 < items)
Branch: 1 branch
BranchTrueFalseTotal
if (1 < items) 0 0 0
1520 0 i = SvIV(ST(1));
1521 else
1522 0 i = self->pos;
1523 0 RETVAL = gcstring_lbclass_ext(self, i);
1524 0 ▶ if (RETVAL == PROP_UNKNOWN)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == PROP_UNKNOWN) 0 0 0
1525 0 XSRETURN_UNDEF;
1526 OUTPUT:
1527 RETVAL
1528  
1529 size_t
1530 length(self)
1531 gcstring_t *self;
1532 PROTOTYPE: $
1533 CODE:
1534 5 ▶ RETVAL = self->gclen;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->gclen; 0 5 5
1535 OUTPUT:
1536 RETVAL
1537  
1538 gcstring_t *
1539 next(self, ...)
1540 gcstring_t *self;
1541 PROTOTYPE: $;$;$
1542 PREINIT:
1543 gcchar_t *gc;
1544 CODE:
1545 1022 ▶ if (gcstring_eos(self))
Branch: 1 branch
BranchTrueFalseTotal
if (gcstring_eos(self)) 1 1021 1022
1546 1 XSRETURN_UNDEF;
1547 1021 gc = gcstring_next(self);
1548 1021 RETVAL = gcstring_substr(self, gc - self->gcstr, 1);
1549 OUTPUT:
1550 RETVAL
1551  
1552 size_t
1553 pos(self, ...)
1554 gcstring_t *self;
1555 PROTOTYPE: $;$
1556 CODE:
1557 4640 ▶ if (1 < items)
Branch: 1 branch
BranchTrueFalseTotal
if (1 < items) 2320 2320 4640
1558 2320 gcstring_setpos(self, SvIV(ST(1)));
1559 4640 ▶ RETVAL = self->pos;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->pos; 4628 12 4640
1560 OUTPUT:
1561 RETVAL
1562  
1563 #define lbobj self->lbobj
1564 gcstring_t *
1565 substr(self, offset, length=self->gclen, replacement=NULL)
1566 gcstring_t *self;
1567 int offset;
1568 int length;
1569 generic_string replacement;
1570 PROTOTYPE: $$;$;$
1571 CODE:
1572 2326 RETVAL = gcstring_substr(self, offset, length);
1573 2326 ▶ if (replacement != NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (replacement != NULL) 3 2323 2326
1574 3 ▶ if (gcstring_replace(self, offset, length, replacement) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (gcstring_replace(self, offset, length, replacement) == NULL) 0 3 3
1575 0 croak("substr: %s", strerror(errno));
1576 2326 ▶ if (RETVAL == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == NULL) 0 2326 2326
1577 0 croak("substr: %s", strerror(errno));
1578 OUTPUT:
1579 RETVAL
1580  
« blib/lib/Unicode/GCString.pm ↑ Summary blib/lib/Unicode/LineBreak/Constants.pm »