| 1 |
|
| #define PERL_NO_GET_CONTEXT |
| 2 |
|
| #include "EXTERN.h" |
| 3 |
|
| #include "perl.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| |
| 6 |
|
| MODULE = String::CP1251 PACKAGE = String::CP1251 |
| 7 |
|
| |
| 8 |
|
| void |
| 9 |
|
| lc(source) |
| 10 |
|
| SV * source; |
| 11 |
|
| PROTOTYPE: $ |
| 12 |
|
| CODE: |
| 13 |
|
| { |
| 14 |
1 |
▶ | dXSTARG; |
Branch: 1 branch
| Branch | True | False | Total |
| dXSTARG; |
1 |
0 |
1 |
|
| 15 |
|
| STRLEN len; |
| 16 |
|
| U8 *d; |
| 17 |
|
| const U8 *end; |
| 18 |
|
| |
| 19 |
1 |
▶ | if(!SvPOK(source) || !(len=SvCUR(source))){ // TODO: add unicode check |
Branch: 2 branches
| Branch | True | False | Total |
| if(!SvPOK(source) || !(len=SvCUR(source))){ // TODO: add unicode check |
1 |
0 |
1 |
| if(!SvPOK(source) || !(len=SvCUR(source))){ // TODO: add unicode check |
0 |
1 |
1 |
|
| 20 |
|
| // TODO: return something instead data itself? |
| 21 |
0 |
| XSRETURN(1); |
| 22 |
|
| } |
| 23 |
|
| |
| 24 |
1 |
▶ | SvUPGRADE(TARG, SVt_PV); |
Branch: 1 branch
| Branch | True | False | Total |
| SvUPGRADE(TARG, SVt_PV); |
1 |
0 |
1 |
|
| 25 |
1 |
▶ | d=SvGROW(TARG, len+1); |
Branch: 2 branches
| Branch | True | False | Total |
| d=SvGROW(TARG, len+1); |
1 |
0 |
1 |
| d=SvGROW(TARG, len+1); |
1 |
0 |
1 |
|
| 26 |
1 |
| Copy(SvPV_nolen(source), d, len, U8); |
| 27 |
1 |
| d[len]='\0'; |
| 28 |
1 |
| SvCUR_set(TARG, len); |
| 29 |
1 |
| SvPOK_on(TARG); |
| 30 |
1 |
| ST(0)=TARG; |
| 31 |
|
| |
| 32 |
1 |
| end = d + len; |
| 33 |
2 |
▶ | for (; d < end; d++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for (; d < end; d++){ |
1 |
1 |
2 |
|
| 34 |
1 |
▶ | if((*d>=65 && *d<=90) || (*d>=192 && *d<=223)) /* Latin letters + 32 Cyrillic from A to YA */ |
Branch: 4 branches
| Branch | True | False | Total |
| if((*d>=65 && *d<=90) || (*d>=192 && *d<=223)) /* Latin letters + 32 Cyrillic from A to YA */ |
1 |
0 |
1 |
| if((*d>=65 && *d<=90) || (*d>=192 && *d<=223)) /* Latin letters + 32 Cyrillic from A to YA */ |
1 |
0 |
1 |
| if((*d>=65 && *d<=90) || (*d>=192 && *d<=223)) /* Latin letters + 32 Cyrillic from A to YA */ |
1 |
0 |
1 |
| if((*d>=65 && *d<=90) || (*d>=192 && *d<=223)) /* Latin letters + 32 Cyrillic from A to YA */ |
1 |
0 |
1 |
|
| 35 |
1 |
| *d+=32; |
| 36 |
0 |
▶ | else if(*d==168) *d=184; /* Cyrillic YO */ |
Branch: 1 branch
| Branch | True | False | Total |
| else if(*d==168) *d=184; /* Cyrillic YO */ |
0 |
0 |
0 |
|
| 37 |
|
| } |
| 38 |
|
| |
| 39 |
1 |
| XSRETURN(1); |
| 40 |
|
| } |
| 41 |
|
| |
| 42 |
|
| void |
| 43 |
|
| uc(source) |
| 44 |
|
| SV * source; |
| 45 |
|
| PROTOTYPE: $ |
| 46 |
|
| CODE: |
| 47 |
|
| { |
| 48 |
0 |
▶ | dXSTARG; |
Branch: 1 branch
| Branch | True | False | Total |
| dXSTARG; |
0 |
0 |
0 |
|
| 49 |
|
| STRLEN len; |
| 50 |
|
| U8 *d; |
| 51 |
|
| const U8 *end; |
| 52 |
|
| |
| 53 |
0 |
▶ | if(!SvPOK(source) || !(len=SvCUR(source))){ // TODO: add unicode check |
Branch: 2 branches
| Branch | True | False | Total |
| if(!SvPOK(source) || !(len=SvCUR(source))){ // TODO: add unicode check |
0 |
0 |
0 |
| if(!SvPOK(source) || !(len=SvCUR(source))){ // TODO: add unicode check |
0 |
0 |
0 |
|
| 54 |
|
| // TODO: return something instead data itself? |
| 55 |
0 |
| XSRETURN(1); |
| 56 |
|
| } |
| 57 |
|
| |
| 58 |
0 |
▶ | SvUPGRADE(TARG, SVt_PV); |
Branch: 1 branch
| Branch | True | False | Total |
| SvUPGRADE(TARG, SVt_PV); |
0 |
0 |
0 |
|
| 59 |
0 |
▶ | d=SvGROW(TARG, len+1); |
Branch: 2 branches
| Branch | True | False | Total |
| d=SvGROW(TARG, len+1); |
0 |
0 |
0 |
| d=SvGROW(TARG, len+1); |
0 |
0 |
0 |
|
| 60 |
0 |
| Copy(SvPV_nolen(source), d, len, U8); |
| 61 |
0 |
| d[len]='\0'; |
| 62 |
0 |
| SvCUR_set(TARG, len); |
| 63 |
0 |
| SvPOK_on(TARG); |
| 64 |
0 |
| ST(0)=TARG; |
| 65 |
|
| |
| 66 |
0 |
| end = d + len; |
| 67 |
0 |
▶ | for (; d < end; d++){ |
Branch: 1 branch
| Branch | True | False | Total |
| for (; d < end; d++){ |
0 |
0 |
0 |
|
| 68 |
0 |
▶ | if((*d>=97 && *d<=122) || (*d>=224 /*&& *d<=255*/)) /* Latin letters + 32 Cyrillic from a to ya, last comparsion is always true for U8 */ |
Branch: 3 branches
| Branch | True | False | Total |
| if((*d>=97 && *d<=122) || (*d>=224 /*&& *d<=255*/)) /* Latin letters + 32 Cyrillic from a to ya, last comparsion is always true for U8 */ |
0 |
0 |
0 |
| if((*d>=97 && *d<=122) || (*d>=224 /*&& *d<=255*/)) /* Latin letters + 32 Cyrillic from a to ya, last comparsion is always true for U8 */ |
0 |
0 |
0 |
| if((*d>=97 && *d<=122) || (*d>=224 /*&& *d<=255*/)) /* Latin letters + 32 Cyrillic from a to ya, last comparsion is always true for U8 */ |
0 |
0 |
0 |
|
| 69 |
0 |
| *d-=32; |
| 70 |
0 |
▶ | else if(*d==184) *d=168; /* Cyrillic yo */ |
Branch: 1 branch
| Branch | True | False | Total |
| else if(*d==184) *d=168; /* Cyrillic yo */ |
0 |
0 |
0 |
|
| 71 |
|
| } |
| 72 |
|
| |
| 73 |
0 |
| XSRETURN(1); |
| 74 |
|
| } |