(Message inbox:82) Received: from ddi2.digital.net by cis.ufl.edu (8.6.10/cis.ufl.edu) id MAA04300; Fri, 24 Mar 1995 12:32:21 -0500 Received: from vx.com (uucp@localhost) by ddi2.digital.net (8.6.9/8.6.9) with UUCP id MAA08981 for spp@cis.ufl.edu; Fri, 24 Mar 1995 12:31:19 -0500 Received: from squid by vx.com (4.1/SMI-4.1) id AA27283; Fri, 24 Mar 95 12:27:03 EST Received: by squid (931110.SGI/930416.SGI.AUTO) for spp@cis.ufl.edu id AA20843; Fri, 24 Mar 95 12:27:16 -0500 From: spp@vx.com (Stephen Potter) Message-Id: <9503241227.ZM20841@squid> Date: Fri, 24 Mar 1995 12:27:12 -0500 X-Mailer: Z-Mail (3.1.0 22feb94 MediaMail) To: spp@cis.ufl.edu Subject: perl5.001 patches Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Here's a cleaner version of the official unofficial patch, based on 5.001. *** op.c@@/V5.001 Sun Mar 12 18:37:21 1995 --- op.c Mon Mar 13 15:03:34 1995 *************** *** 118,123 **** --- 118,124 ---- } static PADOFFSET + #ifndef CAN_PROTOTYPE pad_findlex(name, newoff, seq, startcv, cx_ix) char *name; PADOFFSET newoff; *************** *** 124,129 **** --- 125,133 ---- I32 seq; CV* startcv; I32 cx_ix; + #else + pad_findlex(char *name, PADOFFSET newoff, I32 seq, CV* startcv, I32 cx_ix) + #endif { CV *cv; I32 off; *************** *** 2638,2643 **** --- 2642,2649 ---- } SvREFCNT_dec(CvGV(cv)); CvGV(cv) = Nullgv; + SvREFCNT_dec(CvOUTSIDE(cv)); + CvOUTSIDE(cv) = Nullcv; LEAVE; } } *************** *** 2669,2675 **** CvSTASH(cv) = CvSTASH(proto); CvROOT(cv) = CvROOT(proto); CvSTART(cv) = CvSTART(proto); ! CvOUTSIDE(cv) = CvOUTSIDE(proto); comppad = newAV(); --- 2675,2682 ---- CvSTASH(cv) = CvSTASH(proto); CvROOT(cv) = CvROOT(proto); CvSTART(cv) = CvSTART(proto); ! if (CvOUTSIDE(proto)) ! CvOUTSIDE(cv) = (CV*)SvREFCNT_inc((SV*)CvOUTSIDE(proto)); comppad = newAV(); *************** *** 2752,2757 **** --- 2759,2765 ---- SvREFCNT_dec(CvGV(cv)); } CvOUTSIDE(cv) = CvOUTSIDE(compcv); + CvOUTSIDE(compcv) = 0; CvPADLIST(cv) = CvPADLIST(compcv); SvREFCNT_dec(compcv); } *** sv.c@@/V5.001 Sun Mar 12 19:31:18 1995 --- sv.c Mon Mar 13 15:04:13 1995 *************** *** 3358,3363 **** --- 3358,3364 ---- fprintf(stderr, " FILEGV = 0x%lx\n", (long)CvFILEGV(sv)); fprintf(stderr, " DEPTH = %ld\n", (long)CvDEPTH(sv)); fprintf(stderr, " PADLIST = 0x%lx\n", (long)CvPADLIST(sv)); + fprintf(stderr, " OUTSIDE = 0x%lx\n", (long)CvOUTSIDE(sv)); if (type == SVt_PVFM) fprintf(stderr, " LINES = %ld\n", (long)FmLINES(sv)); break; *** toke.c@@/V5.001 Sun Mar 12 17:26:48 1995 --- toke.c Mon Mar 13 15:52:31 1995 *************** *** 4633,4638 **** --- 4633,4641 ---- CV* outsidecv = compcv; AV* comppadlist; + if (compcv) { + assert(SvTYPE(compcv) == SVt_PVCV); + } save_I32(&subline); save_item(subname); SAVEINT(padix); *************** *** 4665,4671 **** av_store(comppadlist, 1, SvREFCNT_inc((SV*)comppad)); CvPADLIST(compcv) = comppadlist; ! CvOUTSIDE(compcv) = outsidecv; return oldsavestack_ix; } --- 4668,4674 ---- av_store(comppadlist, 1, SvREFCNT_inc((SV*)comppad)); CvPADLIST(compcv) = comppadlist; ! CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)outsidecv); return oldsavestack_ix; } In fixing another bug I installed a nasty memory leak in s///. Here's the fix. Larry *** pp_hot.c Mon Mar 6 20:55:34 1995 --- work/pp_hot.c Mon Mar 13 16:21:54 1995 *************** *** 1451,1456 **** --- 1451,1457 ---- safebase)); sv_catpvn(dstr, s, strend - s); + Safefree(SvPVX(TARG)); SvPVX(TARG) = SvPVX(dstr); SvCUR_set(TARG, SvCUR(dstr)); SvLEN_set(TARG, SvLEN(dstr)); *** pp_ctl.c Mon Mar 6 20:42:19 1995 --- work/pp_ctl.c Mon Mar 13 16:22:12 1995 *************** *** 114,119 **** --- 114,120 ---- SV *targ = cx->sb_targ; sv_catpvn(dstr, s, cx->sb_strend - s); + Safefree(SvPVX(targ)); SvPVX(targ) = SvPVX(dstr); SvCUR_set(targ, SvCUR(dstr)); SvLEN_set(targ, SvLEN(dstr)); Okay, here's your official unofficial closure leak patch. *** op.c Mon Mar 13 15:03:34 1995 --- work/op.c Tue Mar 14 15:03:36 1995 *************** *** 2683,2689 **** comppadlist = newAV(); AvREAL_off(comppadlist); av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name)); ! av_store(comppadlist, 1, SvREFCNT_inc((SV*)comppad)); CvPADLIST(cv) = comppadlist; av_extend(comppad, AvFILL(protopad)); curpad = AvARRAY(comppad); --- 2683,2689 ---- comppadlist = newAV(); AvREAL_off(comppadlist); av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name)); ! av_store(comppadlist, 1, (SV*)comppad); CvPADLIST(cv) = comppadlist; av_extend(comppad, AvFILL(protopad)); curpad = AvARRAY(comppad); *** pp.c Fri Mar 10 21:34:06 1995 --- work/pp.c Tue Mar 14 09:38:16 1995 *************** *** 270,276 **** EXTEND(SP,1); if (SvFLAGS(cv) & SVpcv_CLONE) { ! cv = cv_clone(cv); } PUSHs((SV*)cv); --- 270,276 ---- EXTEND(SP,1); if (SvFLAGS(cv) & SVpcv_CLONE) { ! cv = (CV*)sv_2mortal((SV*)cv_clone(cv)); } PUSHs((SV*)cv); : In perl 5.001 the print function now only outputs one significant digit for the : the results of some mathematical functions. : : $ cat mine : #!/usr/bin/perl : print sqrt(2), "\n"; : print 4 * atan2(1,1), "\n"; : print log(2), "\n"; : $ ./mine : 1 : 3 : 0 Okay, I understand how this one happened. This is a case where a beneficial fix uncovered a bug elsewhere. I changed the constant folder to prefer integer results over double if the numbers are the same. In this case, they aren't, but it leaves the integer value there anyway because the storage is already allocated for it, and it *might* be used in an integer context. And since it's producing a constant, it sets READONLY. Unfortunately, sv_2pv() bogusly preferred the integer value to the double when READONLY was set. This never showed up if you just said print 1.4142135623731; because in that case, there was already a string value. Here's the patch: *** sv.c Mon Mar 13 15:04:13 1995 --- work/sv.c Wed Mar 15 08:27:16 1995 *************** *** 1246,1257 **** return s; } if (SvREADONLY(sv)) { - if (SvIOKp(sv)) { - (void)sprintf(tokenbuf,"%ld",(long)SvIVX(sv)); - goto tokensave; - } if (SvNOKp(sv)) { Gconvert(SvNVX(sv), DBL_DIG, 0, tokenbuf); goto tokensave; } if (dowarn) --- 1246,1257 ---- return s; } if (SvREADONLY(sv)) { if (SvNOKp(sv)) { Gconvert(SvNVX(sv), DBL_DIG, 0, tokenbuf); + goto tokensave; + } + if (SvIOKp(sv)) { + (void)sprintf(tokenbuf,"%ld",(long)SvIVX(sv)); goto tokensave; } if (dowarn) -- Stephen P Potter spp@vx.com Varimetrix Corporation 2350 Commerce Park Drive, Suite 4 Palm Bay, FL 32905 (407) 676-3222 CAD/CAM/CAE/Software