This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
refactor and regularise label/statement grammar
[perl5.git] / perlio.c
index 5df704e..1440048 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -1211,13 +1211,18 @@ PerlIO *
 PerlIO_push(pTHX_ PerlIO *f, PERLIO_FUNCS_DECL(*tab), const char *mode, SV *arg)
 {
     if (tab->fsize != sizeof(PerlIO_funcs)) {
-      mismatch:
-       Perl_croak(aTHX_ "Layer does not match this perl");
+       Perl_croak( aTHX_
+           "%s (%d) does not match %s (%d)",
+           "PerlIO layer function table size", tab->fsize,
+           "size expected by this perl", sizeof(PerlIO_funcs) );
     }
     if (tab->size) {
        PerlIOl *l;
        if (tab->size < sizeof(PerlIOl)) {
-           goto mismatch;
+           Perl_croak( aTHX_
+               "%s (%d) smaller than %s (%d)",
+               "PerlIO layer instance size", tab->size,
+               "size expected by this perl", sizeof(PerlIOl) );
        }
        /* Real layer with a data area */
        if (f) {
@@ -1449,7 +1454,7 @@ PerlIO_layer_from_ref(pTHX_ SV *sv)
     /*
      * For any scalar type load the handler which is bundled with perl
      */
-    if (SvTYPE(sv) < SVt_PVAV) {
+    if (SvTYPE(sv) < SVt_PVAV && (!isGV_with_GP(sv) || SvFAKE(sv))) {
        PerlIO_funcs *f = PerlIO_find_layer(aTHX_ STR_WITH_LEN("scalar"), 1);
        /* This isn't supposed to happen, since PerlIO::scalar is core,
         * but could happen anyway in smaller installs or with PAR */
@@ -5227,8 +5232,7 @@ Perl_PerlIO_context_layers(pTHX_ const char *mode)
     if (!direction)
        return NULL;
 
-    layers = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
-                                     0, direction, 5, 0, 0);
+    layers = cop_hints_fetch_pvn(PL_curcop, direction, 5, 0, 0);
 
     assert(layers);
     return SvOK(layers) ? SvPV_nolen_const(layers) : NULL;