diff options
author | Gisle Aas <aas@bergen.sn.no> | 1997-07-02 10:20:33 +1200 |
---|---|---|
committer | Tim Bunce <Tim.Bunce@ig.co.uk> | 1997-08-07 00:00:00 +1200 |
commit | 64f14228217abb04a437553319642d6e7a82a3e8 (patch) | |
tree | 07c20ebf0a987f01ac2534771e1e4ef3feae0f7a /sv.c | |
parent | b8a4b1bed690d5e67ab7dfcb2ddfb2aa59ccefd7 (diff) | |
download | perl-64f14228217abb04a437553319642d6e7a82a3e8.tar.gz |
stringify looses integerness
Gurusamy Sarathy <gsar@engin.umich.edu> writes:
> On 01 Jul 1997 20:49:15 +0200, Gisle Aas wrote:
> >The following patch (relative to perl5.004) makes this bug go away.
> >Perl still passes all it's tests and the original example works as it
> >did in perl5.003.
> >
> >--- sv.c.orig Tue Jul 1 20:26:40 1997
> >+++ sv.c Tue Jul 1 20:38:13 1997
> >@@ -1713,6 +1713,7 @@
> > sv_upgrade(sv, SVt_PVIV);
> > olderrno = errno; /* some Xenix systems wipe out errno here */
> > sv_setpvf(sv, "%Vd", SvIVX(sv));
> >+ SvIOK_on(sv); /* it is still valid */
> > errno = olderrno;
> > s = SvEND(sv);
> > }
>
> That should restore precisely those flags that were active
> before sv_setpvf() was called. eg: the case where {pIOK,NOK,pNOK}
> are set, the resulting SV should have {pPOK,POK,pIOK,NOK,pNOK}
> set.
NOK or pNOK can't be set at this point. The only possibility is that
pIOK is set and not IOK (but I don't know how can I trigger this
condition?)
This patch should then be safer (it also passes all tests):
p5p-msgid: hbu4l96z2.fsf@bergen.sn.no
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -1710,12 +1710,17 @@ STRLEN *lp; #endif } else if (SvIOKp(sv)) { + U32 oldIOK = SvIOK(sv); if (SvTYPE(sv) < SVt_PVIV) sv_upgrade(sv, SVt_PVIV); olderrno = errno; /* some Xenix systems wipe out errno here */ sv_setpvf(sv, "%Vd", SvIVX(sv)); errno = olderrno; s = SvEND(sv); + if (oldIOK) + SvIOK_on(sv); + else + SvIOKp_on(sv); } else { if (dowarn && !localizing && !(SvFLAGS(sv) & SVs_PADTMP)) |