{
if (PerlIOBase(f)->flags & PERLIO_F_CANREAD) {
PerlIOScalar *s = PerlIOSelf(f, PerlIOScalar);
+ STRLEN len;
SvGETMAGIC(s->var);
- if (SvCUR(s->var) > (STRLEN) s->posn)
- return SvCUR(s->var) - (STRLEN)s->posn;
+ if (isGV_with_GP(s->var))
+ (void)SvPV(s->var,len);
+ else len = SvCUR(s->var);
+ if (len > (STRLEN) s->posn)
+ return len - (STRLEN)s->posn;
else
return 0;
}
PerlIOScalar_set_ptrcnt(pTHX_ PerlIO * f, STDCHAR * ptr, SSize_t cnt)
{
PerlIOScalar *s = PerlIOSelf(f, PerlIOScalar);
+ STRLEN len;
PERL_UNUSED_ARG(ptr);
SvGETMAGIC(s->var);
- s->posn = SvCUR(s->var) - cnt;
+ if (isGV_with_GP(s->var)) (void)SvPV(s->var,len);
+ else len = SvCUR(s->var);
+ s->posn = len - cnt;
}
PerlIO *
skip_all_without_perlio();
}
-plan tests => 42;
+plan tests => 44;
use_ok('PerlIO');
close ($no_perlio);
}
+{ # [perl #92258]
+ open my $fh, "<", \(my $f = *f);
+ is join("", <$fh>), '*main::f', 'reading from a glob copy';
+ is ref \$f, 'GLOB', 'the glob copy is unaffected';
+}
+
}