This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid AV and HV in perlio.c by inventing PerlIO_list_t which is AV-ish
[perl5.git] / ext / Encode / Encode.xs
index 13ba704..f3e8738 100644 (file)
@@ -1,3 +1,5 @@
+#define PERL_NO_GET_CONTEXT
+
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
@@ -7,7 +9,8 @@
 #include "EBCDIC.h"
 #include "Symbols.h"
 
-#define UNIMPLEMENTED(x,y) y x (SV *sv, char *encoding) {   \
+
+#define UNIMPLEMENTED(x,y) y x (SV *sv, char *encoding) {dTHX;   \
                          Perl_croak(aTHX_ "panic_unimplemented"); \
                         return (y)0; /* fool picky compilers */ \
                          }
@@ -51,6 +54,7 @@ typedef struct
 SV *
 PerlIOEncode_getarg(PerlIO *f)
 {
+ dTHX;
  PerlIOEncode *e = PerlIOSelf(f,PerlIOEncode);
  SV *sv = &PL_sv_undef;
  if (e->enc)
@@ -97,7 +101,7 @@ PerlIOEncode_pushed(PerlIO *f, const char *mode, SV *arg)
   {
    e->enc = Nullsv;
    errno  = EINVAL;
-   Perl_warner(aTHX_ WARN_IO, "Cannot find encoding \"%_\"", arg);
+   Perl_warner(aTHX_ WARN_IO, "Cannot find encoding \"%"SVf"\"", arg);
    return -1;
   }
  SvREFCNT_inc(e->enc);
@@ -467,10 +471,10 @@ MODULE = Encode           PACKAGE = Encode::XS    PREFIX = Method_
 PROTOTYPES: ENABLE
 
 void
-Method_decode(obj,src,check = 0)
+Method_decode(obj,src,check = FALSE)
 SV *   obj
 SV *   src
-int    check
+bool   check
 CODE:
  {
   encode_t *enc = INT2PTR(encode_t *, SvIV(SvRV(obj)));
@@ -480,10 +484,10 @@ CODE:
  }
 
 void
-Method_encode(obj,src,check = 0)
+Method_encode(obj,src,check = FALSE)
 SV *   obj
 SV *   src
-int    check
+bool   check
 CODE:
  {
   encode_t *enc = INT2PTR(encode_t *, SvIV(SvRV(obj)));
@@ -534,6 +538,7 @@ _utf8_to_bytes(sv, ...)
             STRLEN len;
             U8 *s = (U8*)SvPV(sv, len);
 
+           RETVAL = 0;
             if (SvTRUE(check)) {
               /* Must do things the slow way */
               U8 *dest;