From: Rafael Garcia-Suarez Date: Mon, 2 Feb 2009 14:56:13 +0000 (+0100) Subject: When loading a PerlIO::via layer, first look in the PerlIO::via namespace X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a681c2f1432a6f96869c4afb372e4fe094213ee1;p=p5sagit%2Fp5-mst-13.2.git When loading a PerlIO::via layer, first look in the PerlIO::via namespace Previously an open "via(Foo)" was first looking for the Foo namespace, then for PerlIO::via::Foo. That could cause loading problems if both Foo and PerlIO::via::Foo namespaces existed, and when the latter was required. The workaround of loading "via(PerlIO::via::Foo)" being rather ugly, it's preferable to look first for the fully qualified namespace in order to avoid side-effects depending of what namespaces are instanciated in the interpreter. --- diff --git a/ext/PerlIO/via/via.xs b/ext/PerlIO/via/via.xs index e50052c..fd5234a 100644 --- a/ext/PerlIO/via/via.xs +++ b/ext/PerlIO/via/via.xs @@ -138,14 +138,14 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, else { STRLEN pkglen = 0; const char *pkg = SvPV(arg, pkglen); - s->obj = SvREFCNT_inc(arg); - s->stash = gv_stashpvn(pkg, pkglen, 0); + s->obj = + newSVpvn(Perl_form(aTHX_ "PerlIO::via::%s", pkg), + pkglen + 13); + s->stash = gv_stashpvn(SvPVX_const(s->obj), pkglen + 13, 0); if (!s->stash) { SvREFCNT_dec(s->obj); - s->obj = - newSVpvn(Perl_form(aTHX_ "PerlIO::via::%s", pkg), - pkglen + 13); - s->stash = gv_stashpvn(SvPVX_const(s->obj), pkglen + 13, 0); + s->obj = SvREFCNT_inc(arg); + s->stash = gv_stashpvn(pkg, pkglen, 0); } if (s->stash) { char lmode[8];