This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The last parameter to gv_stashpv/gv_stashpvn/gv_stashsv is a bitmask
[perl5.git] / ext / PerlIO / via / via.xs
index 36394dd..5670887 100644 (file)
@@ -45,7 +45,7 @@ PerlIOVia_fetchmethod(pTHX_ PerlIOVia * s, char *method, CV ** save)
 {
     GV *gv = gv_fetchmeth(s->stash, method, strlen(method), 0);
 #if 0
-    Perl_warn(aTHX_ "Lookup %s::%s => %p", HvNAME(s->stash), method, gv);
+    Perl_warn(aTHX_ "Lookup %s::%s => %p", HvNAME_get(s->stash), method, gv);
 #endif
     if (gv) {
        return *save = GvCV(gv);
@@ -87,7 +87,7 @@ PerlIOVia_method(pTHX_ PerlIO * f, char *method, CV ** save, int flags,
        }
        if (*PerlIONext(f)) {
            if (!s->fh) {
-               GV *gv = newGVgen(HvNAME(s->stash));
+               GV *gv = newGVgen(HvNAME_get(s->stash));
                GvIOp(gv) = newIO();
                s->fh = newRV_noinc((SV *) gv);
                s->io = GvIOp(gv);
@@ -135,13 +135,13 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
            STRLEN pkglen = 0;
            const char *pkg = SvPV(arg, pkglen);
            s->obj = SvREFCNT_inc(arg);
-           s->stash = gv_stashpvn(pkg, pkglen, FALSE);
+           s->stash = gv_stashpvn(pkg, pkglen, 0);
            if (!s->stash) {
+               SvREFCNT_dec(s->obj);
                s->obj =
                    newSVpvn(Perl_form(aTHX_ "PerlIO::via::%s", pkg),
                             pkglen + 13);
-               SvREFCNT_dec(arg);
-               s->stash = gv_stashpvn(SvPVX(s->obj), pkglen + 13, FALSE);
+               s->stash = gv_stashpvn(SvPVX_const(s->obj), pkglen + 13, 0);
            }
            if (s->stash) {
                char lmode[8];
@@ -156,8 +156,8 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
                                     modesv, Nullsv);
                if (result) {
                    if (sv_isobject(result)) {
+                       SvREFCNT_dec(s->obj);
                        s->obj = SvREFCNT_inc(result);
-                       SvREFCNT_dec(arg);
                    }
                    else if (SvIV(result) != 0)
                        return SvIV(result);