| 1 |
|
| #ifndef WIN32 |
| 2 |
|
| #include <langinfo.h> |
| 3 |
|
| #endif |
| 4 |
|
| #include "EXTERN.h" |
| 5 |
|
| #include "perl.h" |
| 6 |
|
| #include "XSUB.h" |
| 7 |
|
| #include "perliol.h" |
| 8 |
|
| |
| 9 |
|
| #ifdef WIN32 |
| 10 |
|
| #define get_locale_encoding() newSVpvf("cp%lu", GetACP()) |
| 11 |
|
| #else |
| 12 |
|
| #define get_locale_encoding() newSVpv(nl_langinfo(CODESET), 0) |
| 13 |
|
| #endif |
| 14 |
|
| |
| 15 |
|
| IV |
| 16 |
0 |
| PerlIOLocale_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab) |
| 17 |
|
| { |
| 18 |
0 |
| PerlIO_funcs* encoding = PerlIO_find_layer(aTHX_ "encoding", 8, 1); |
| 19 |
0 |
| SV* locale_encoding = sv_2mortal(get_locale_encoding()); |
| 20 |
0 |
▶ | return PerlIO_push(aTHX_ f, encoding, mode, locale_encoding) == f ? 0 : -1; |
Branch: 1 branch
| Branch | True | False | Total |
| return PerlIO_push(aTHX_ f, encoding, mode, locale_encoding) == f ? 0 : -1; |
0 |
0 |
0 |
|
| 21 |
|
| } |
| 22 |
|
| |
| 23 |
|
| PerlIO_funcs PerlIO_locale = { |
| 24 |
|
| sizeof(PerlIO_funcs), |
| 25 |
|
| "locale", |
| 26 |
|
| 0, |
| 27 |
|
| 0, |
| 28 |
|
| PerlIOLocale_pushed, |
| 29 |
|
| NULL, |
| 30 |
|
| #if PERL_VERSION >= 14 |
| 31 |
|
| PerlIOBase_open, |
| 32 |
|
| #else |
| 33 |
|
| PerlIOBuf_open, |
| 34 |
|
| #endif |
| 35 |
|
| }; |
| 36 |
|
| |
| 37 |
|
| MODULE = PerlIO::locale PACKAGE = PerlIO::locale |
| 38 |
|
| |
| 39 |
|
| BOOT: |
| 40 |
4 |
| PerlIO_define_layer(aTHX_ &PerlIO_locale); |