diff options
author | Father Chrysostomos <sprout@cpan.org> | 2010-09-13 09:57:15 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-09-13 09:57:58 +0200 |
commit | 526fd1b4d7270fff44588238f2411032c109da6e (patch) | |
tree | 0bcb1eeef2931a321b0a5c150e44f0fd71ff45dd /ext/PerlIO-scalar | |
parent | 25222ff958727e01a3a480924b65ba188c7c3ea2 (diff) | |
download | perl-526fd1b4d7270fff44588238f2411032c109da6e.tar.gz |
[perl #77684] Restore the 5.10/12 behaviour of open $fh, ">", \$glob_copy
This restores the perl 5.10/12 behaviour, making open treat \$foo as a
scalar reference if it is a glob copy (SvFAKE).
It also fixes an existing assertion failure that the test now trig-
gers. PerlIOScalar_pushed was not downgrading the sv before set-
ting SvCUR.
Diffstat (limited to 'ext/PerlIO-scalar')
-rw-r--r-- | ext/PerlIO-scalar/scalar.xs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/PerlIO-scalar/scalar.xs b/ext/PerlIO-scalar/scalar.xs index f2481f4197..b93b9e9257 100644 --- a/ext/PerlIO-scalar/scalar.xs +++ b/ext/PerlIO-scalar/scalar.xs @@ -47,9 +47,15 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, SvUPGRADE(s->var, SVt_PV); code = PerlIOBase_pushed(aTHX_ f, mode, Nullsv, tab); if (!SvOK(s->var) || (PerlIOBase(f)->flags) & PERLIO_F_TRUNCATE) + { + sv_force_normal(s->var); SvCUR_set(s->var, 0); + } if ((PerlIOBase(f)->flags) & PERLIO_F_APPEND) + { + sv_force_normal(s->var); s->posn = SvCUR(s->var); + } else s->posn = 0; SvSETMAGIC(s->var); @@ -166,6 +172,7 @@ PerlIOScalar_write(pTHX_ PerlIO * f, const void *vbuf, Size_t count) SV *sv = s->var; char *dst; SvGETMAGIC(sv); + sv_force_normal(sv); if ((PerlIOBase(f)->flags) & PERLIO_F_APPEND) { dst = SvGROW(sv, SvCUR(sv) + count); offset = SvCUR(sv); |