From: Gisle Aas Date: Tue, 1 Jul 1997 22:20:33 +0000 (+1200) Subject: stringify looses integerness X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=64f14228217abb04a437553319642d6e7a82a3e8;p=p5sagit%2Fp5-mst-13.2.git stringify looses integerness Gurusamy Sarathy 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 --- diff --git a/sv.c b/sv.c index 53499fd..ce85a4b 100644 --- a/sv.c +++ b/sv.c @@ -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))