home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl501m.zip / patches / patch.1a next >
Text File  |  1995-04-20  |  8KB  |  294 lines

  1. # This is my patch  patch.1a for perl5.001.  See description below.
  2. #    Andy Dougherty        doughera@lafcol.lafayette.edu
  3. exit 0           # Just in case
  4.  
  5. This is my patch  patch.1a  for perl5.001.  
  6.  
  7. [Actually, that's a lie.  This is just Larry's four posted patches
  8. bundled together.  I've just usurped the letter 'a' to start my 
  9. patch sequence.  You probably have already applied these, but now you
  10. have a label for them, and we all know where we stand. ]
  11.  
  12. To apply, change to your perl directory,
  13. and apply with 
  14.     patch -p < thispatch.
  15.  
  16.     Patch and enjoy,
  17.  
  18.     Andy Dougherty            doughera@lafcol.lafayette.edu
  19.     Dept. of Physics
  20.     Lafayette College, Easton PA
  21.  
  22. From lwall@scalpel.netlabs.com Wed Mar 15 09:01:46 1995
  23. Date: Tue, 14 Mar 95 15:25:31 -0800
  24. From: Larry Wall <lwall@scalpel.netlabs.com>
  25. To: Carl Witty <cwitty@ai.mit.edu>
  26. Cc: perl5-porters@africa.nicoh.com
  27. Subject: Re: memory leaks in closures 
  28.  
  29.  
  30. Okay, here's your official unofficial closure leak patch.
  31.  
  32. *** op.c    Mon Mar 13 15:03:34 1995
  33. --- work/op.c    Tue Mar 14 15:03:36 1995
  34. ***************
  35. *** 2683,2689 ****
  36.       comppadlist = newAV();
  37.       AvREAL_off(comppadlist);
  38.       av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name));
  39. !     av_store(comppadlist, 1, SvREFCNT_inc((SV*)comppad));
  40.       CvPADLIST(cv) = comppadlist;
  41.       av_extend(comppad, AvFILL(protopad));
  42.       curpad = AvARRAY(comppad);
  43. --- 2683,2689 ----
  44.       comppadlist = newAV();
  45.       AvREAL_off(comppadlist);
  46.       av_store(comppadlist, 0, SvREFCNT_inc((SV*)protopad_name));
  47. !     av_store(comppadlist, 1, (SV*)comppad);
  48.       CvPADLIST(cv) = comppadlist;
  49.       av_extend(comppad, AvFILL(protopad));
  50.       curpad = AvARRAY(comppad);
  51. *** pp.c    Fri Mar 10 21:34:06 1995
  52. --- work/pp.c    Tue Mar 14 09:38:16 1995
  53. ***************
  54. *** 270,276 ****
  55.       EXTEND(SP,1);
  56.   
  57.       if (SvFLAGS(cv) & SVpcv_CLONE) {
  58. !     cv = cv_clone(cv);
  59.       }
  60.   
  61.       PUSHs((SV*)cv);
  62. --- 270,276 ----
  63.       EXTEND(SP,1);
  64.   
  65.       if (SvFLAGS(cv) & SVpcv_CLONE) {
  66. !     cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
  67.       }
  68.   
  69.       PUSHs((SV*)cv);
  70.  
  71. Larry
  72.  
  73. >From lwall@scalpel.netlabs.com Tue Mar 14 10:45:48 1995
  74. Date: Mon, 13 Mar 95 15:55:18 -0800
  75. From: Larry Wall <lwall@scalpel.netlabs.com>
  76. To: "Stephen O. Lidie" <lusol@turkey.cc.lehigh.edu>
  77. Cc: perl5-porters@africa.nicoh.com
  78. Subject: Re: 5.001, findlex patch 
  79.  
  80. : There were some warnings (AIX, xlc compiler):
  81.  
  82. Here's a cleaner version of the official unofficial patch, based on 5.001.
  83.  
  84. *** op.c@@/V5.001    Sun Mar 12 18:37:21 1995
  85. --- op.c    Mon Mar 13 15:03:34 1995
  86. ***************
  87. *** 118,123 ****
  88. --- 118,124 ----
  89.   }
  90.   
  91.   static PADOFFSET
  92. + #ifndef CAN_PROTOTYPE
  93.   pad_findlex(name, newoff, seq, startcv, cx_ix)
  94.   char *name;
  95.   PADOFFSET newoff;
  96. ***************
  97. *** 124,129 ****
  98. --- 125,133 ----
  99.   I32 seq;
  100.   CV* startcv;
  101.   I32 cx_ix;
  102. + #else
  103. + pad_findlex(char *name, PADOFFSET newoff, I32 seq, CV* startcv, I32 cx_ix)
  104. + #endif
  105.   {
  106.       CV *cv;
  107.       I32 off;
  108. ***************
  109. *** 2638,2643 ****
  110. --- 2642,2649 ----
  111.       }
  112.       SvREFCNT_dec(CvGV(cv));
  113.       CvGV(cv) = Nullgv;
  114. +     SvREFCNT_dec(CvOUTSIDE(cv));
  115. +     CvOUTSIDE(cv) = Nullcv;
  116.       LEAVE;
  117.       }
  118.   }
  119. ***************
  120. *** 2669,2675 ****
  121.       CvSTASH(cv)        = CvSTASH(proto);
  122.       CvROOT(cv)        = CvROOT(proto);
  123.       CvSTART(cv)        = CvSTART(proto);
  124. !     CvOUTSIDE(cv)    = CvOUTSIDE(proto);
  125.   
  126.       comppad = newAV();
  127.   
  128. --- 2675,2682 ----
  129.       CvSTASH(cv)        = CvSTASH(proto);
  130.       CvROOT(cv)        = CvROOT(proto);
  131.       CvSTART(cv)        = CvSTART(proto);
  132. !     if (CvOUTSIDE(proto))
  133. !     CvOUTSIDE(cv)    = (CV*)SvREFCNT_inc((SV*)CvOUTSIDE(proto));
  134.   
  135.       comppad = newAV();
  136.   
  137. ***************
  138. *** 2752,2757 ****
  139. --- 2759,2765 ----
  140.           SvREFCNT_dec(CvGV(cv));
  141.       }
  142.       CvOUTSIDE(cv) = CvOUTSIDE(compcv);
  143. +     CvOUTSIDE(compcv) = 0;
  144.       CvPADLIST(cv) = CvPADLIST(compcv);
  145.       SvREFCNT_dec(compcv);
  146.       }
  147.  
  148. *** sv.c@@/V5.001    Sun Mar 12 19:31:18 1995
  149. --- sv.c    Mon Mar 13 15:04:13 1995
  150. ***************
  151. *** 3358,3363 ****
  152. --- 3358,3364 ----
  153.       fprintf(stderr, "  FILEGV = 0x%lx\n", (long)CvFILEGV(sv));
  154.       fprintf(stderr, "  DEPTH = %ld\n", (long)CvDEPTH(sv));
  155.       fprintf(stderr, "  PADLIST = 0x%lx\n", (long)CvPADLIST(sv));
  156. +     fprintf(stderr, "  OUTSIDE = 0x%lx\n", (long)CvOUTSIDE(sv));
  157.       if (type == SVt_PVFM)
  158.           fprintf(stderr, "  LINES = %ld\n", (long)FmLINES(sv));
  159.       break;
  160.  
  161. *** toke.c@@/V5.001    Sun Mar 12 17:26:48 1995
  162. --- toke.c    Mon Mar 13 15:52:31 1995
  163. ***************
  164. *** 4633,4638 ****
  165. --- 4633,4641 ----
  166.       CV* outsidecv = compcv;
  167.       AV* comppadlist;
  168.   
  169. +     if (compcv) {
  170. +     assert(SvTYPE(compcv) == SVt_PVCV);
  171. +     }
  172.       save_I32(&subline);
  173.       save_item(subname);
  174.       SAVEINT(padix);
  175. ***************
  176. *** 4665,4671 ****
  177.       av_store(comppadlist, 1, SvREFCNT_inc((SV*)comppad));
  178.   
  179.       CvPADLIST(compcv) = comppadlist;
  180. !     CvOUTSIDE(compcv) = outsidecv;
  181.   
  182.       return oldsavestack_ix;
  183.   }
  184. --- 4668,4674 ----
  185.       av_store(comppadlist, 1, SvREFCNT_inc((SV*)comppad));
  186.   
  187.       CvPADLIST(compcv) = comppadlist;
  188. !     CvOUTSIDE(compcv) = (CV*)SvREFCNT_inc((SV*)outsidecv);
  189.   
  190.       return oldsavestack_ix;
  191.   }
  192.  
  193. >From lwall@scalpel.netlabs.com Tue Mar 14 10:51:24 1995
  194. Date: Mon, 13 Mar 95 16:43:53 -0800
  195. From: Larry Wall <lwall@scalpel.netlabs.com>
  196. To: perl5@scalpel.netlabs.com
  197. Subject: s/// memory leak in 5.001
  198.  
  199. In fixing another bug I installed a nasty memory leak in s///.  Here's the fix.
  200.  
  201. Larry
  202.  
  203. *** pp_hot.c    Mon Mar  6 20:55:34 1995
  204. --- work/pp_hot.c    Mon Mar 13 16:21:54 1995
  205. ***************
  206. *** 1451,1456 ****
  207. --- 1451,1457 ----
  208.           safebase));
  209.       sv_catpvn(dstr, s, strend - s);
  210.   
  211. +     Safefree(SvPVX(TARG));
  212.       SvPVX(TARG) = SvPVX(dstr);
  213.       SvCUR_set(TARG, SvCUR(dstr));
  214.       SvLEN_set(TARG, SvLEN(dstr));
  215. *** pp_ctl.c    Mon Mar  6 20:42:19 1995
  216. --- work/pp_ctl.c    Mon Mar 13 16:22:12 1995
  217. ***************
  218. *** 114,119 ****
  219. --- 114,120 ----
  220.           SV *targ = cx->sb_targ;
  221.           sv_catpvn(dstr, s, cx->sb_strend - s);
  222.   
  223. +         Safefree(SvPVX(targ));
  224.           SvPVX(targ) = SvPVX(dstr);
  225.           SvCUR_set(targ, SvCUR(dstr));
  226.           SvLEN_set(targ, SvLEN(dstr));
  227.  
  228.  
  229. >From lwall@scalpel.netlabs.com Wed Mar 15 14:04:32 1995
  230. Date: Wed, 15 Mar 95 08:34:28 -0800
  231. From: Larry Wall <lwall@scalpel.netlabs.com>
  232. To: "Jack R. Lawler" <lawler@acsu.buffalo.edu>
  233. Cc: perl5-porters@africa.nicoh.com
  234. Subject: Re: 5.001 bug in print 
  235.  
  236. : In perl 5.001 the print function now only outputs one significant digit for the
  237. : the results of some mathematical functions.
  238. : $ cat mine
  239. : #!/usr/bin/perl
  240. : print sqrt(2), "\n";
  241. : print 4 * atan2(1,1), "\n";
  242. : print log(2), "\n";
  243. : $ ./mine
  244. : 1
  245. : 3
  246. : 0
  247.  
  248. Okay, I understand how this one happened.  This is a case where a
  249. beneficial fix uncovered a bug elsewhere.  I changed the constant
  250. folder to prefer integer results over double if the numbers are the
  251. same.  In this case, they aren't, but it leaves the integer value there
  252. anyway because the storage is already allocated for it, and it *might*
  253. be used in an integer context.  And since it's producing a constant, it
  254. sets READONLY.  Unfortunately, sv_2pv() bogusly preferred the integer
  255. value to the double when READONLY was set.  This never showed up if you
  256. just said
  257.  
  258.     print 1.4142135623731;
  259.  
  260. because in that case, there was already a string value.  Here's the patch:
  261.  
  262. *** sv.c    Mon Mar 13 15:04:13 1995
  263. --- work/sv.c    Wed Mar 15 08:27:16 1995
  264. ***************
  265. *** 1246,1257 ****
  266.           return s;
  267.       }
  268.       if (SvREADONLY(sv)) {
  269. -         if (SvIOKp(sv)) {
  270. -         (void)sprintf(tokenbuf,"%ld",(long)SvIVX(sv));
  271. -         goto tokensave;
  272. -         }
  273.           if (SvNOKp(sv)) {
  274.           Gconvert(SvNVX(sv), DBL_DIG, 0, tokenbuf);
  275.           goto tokensave;
  276.           }
  277.           if (dowarn)
  278. --- 1246,1257 ----
  279.           return s;
  280.       }
  281.       if (SvREADONLY(sv)) {
  282.           if (SvNOKp(sv)) {
  283.           Gconvert(SvNVX(sv), DBL_DIG, 0, tokenbuf);
  284. +         goto tokensave;
  285. +         }
  286. +         if (SvIOKp(sv)) {
  287. +         (void)sprintf(tokenbuf,"%ld",(long)SvIVX(sv));
  288.           goto tokensave;
  289.           }
  290.           if (dowarn)
  291.  
  292. Larry
  293.