home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume7 / patch2 / patch4 < prev    next >
Internet Message Format  |  1986-11-30  |  6KB

  1. From cbosgd!sdcrdcf!daemon Sat Nov 29 21:36:19 1986
  2. Received: by mirror.TMC.COM (4.12/UUCP-Project/rel-1.0/08-20-86)
  3.     id AA12721; Sat, 29 Nov 86 21:36:13 est
  4. Received: by cbosgd.ATT.COM (smail2.1)
  5.     id AA20978; 29 Nov 86 21:08:49 EST (Sat)
  6. Received: by sdc.uucp (4.12/sdcrdcf)
  7.     id AA25502; Sat, 29 Nov 86 17:50:35 pst
  8. Date: Sat, 29 Nov 86 17:50:35 pst
  9. From: sdcrdcf!daemon (The Devil Himself)
  10. Message-Id: <8611300150.AA25502@sdc.uucp>
  11. Subject: patch version 2.0 patch #4
  12. Apparently-To: cbosgd!mirror!rs
  13. Status: R
  14.  
  15. [The latest patch for patch version 2.0 is #5.]
  16.  
  17. mailpatch speaking for lwall
  18.  
  19. System: patch version 2.0
  20. Patch #: 4
  21. Priority: HIGH
  22. Subject: Certain long hunks are not dynamically allocated correctly
  23. From: Herb Chong and Hokey
  24.  
  25. Description:
  26.     If the pattern portion of a hunk is longer than the initially
  27.     allocated maximum hunk size, the hunk is not grown larger in time.
  28.     The malloc arena gets stomped on non-4bsd sites.  4bsd sites
  29.     generally survive this because more memory is generally allocated
  30.     than you asked for.
  31.  
  32.     There was also a minor difficulty with error numbers on new-style
  33.     context diffs that require backtracking to parse correctly because
  34.     the input line number was not reset along with the file position.
  35.     Note that backtracking is VERY rare--you have to have a patch
  36.     that ends with a deletion, so that the replacement text is missing,
  37.     and at least one line at the place where the replacement text WOULD
  38.     have been must look like a replacement line.  Only then does
  39.     backtracking occur.  (Backtracking would be entirely unnecessary
  40.     if patches were unambiguously terminated, but they aren't.  Note
  41.     that the version of patch that comes with 4.3bsd doesn't backtrack
  42.     at all.)
  43.  
  44. Repeat-By:
  45.     Compile up patch with a version of malloc that doesn't round up
  46.     to a power of two.  Apply a patch with more than 125 lines in
  47.     the pattern (not the replacement) part of the hunk.  Run patch
  48.     and watch the fireworks.  Delete the core dump.
  49.  
  50. Fix:    From rn, say "| patch -d DIR", where DIR is your patch source
  51.     directory.  Outside of rn, say "cd DIR; patch <thisarticle".
  52.     If you don't have the patch program, apply the following by hand,
  53.     or get patch.
  54.  
  55.     If patch indicates that patchlevel is the wrong version, you may need
  56.     to apply one or more previous patches, or the patch may already
  57.     have been applied.  See the patchlevel.h file to find out what has or
  58.     has not been applied.  In any event, don't continue with the patch.
  59.  
  60.     If you are missing previous patches they can be obtained from me:
  61.  
  62.     Larry Wall
  63.     {allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
  64.  
  65.     If you send a mail message of the following form it will greatly speed
  66.     processing:
  67.  
  68.     Subject: Command
  69.     @SH mailpatch PATH patch 2.0 NUM ...
  70.  
  71.     where PATH is a return path FROM ME TO YOU in bang notation, and NUM
  72.     is the number of one or more patches you need, separated by spaces.
  73.     You can also get them by anonymous FTP from sdc-camarillo.arpa.
  74.  
  75. Index: patchlevel.h
  76. Prereq: 3
  77. 1c1
  78. < #define PATCHLEVEL 3
  79. ---
  80. > #define PATCHLEVEL 4
  81.  
  82. Index: pch.c
  83. Prereq: 2.0.1.2
  84. *** pch.c.old    Fri Nov 14 10:11:00 1986
  85. *** pch.c    Fri Nov 14 10:11:14 1986
  86. ***************
  87. *** 1,4
  88. ! /* $Header: pch.c,v 2.0.1.2 86/11/03 17:49:52 lwall Exp $
  89.    *
  90.    * $Log:    pch.c,v $
  91.    * Revision 2.0.1.2  86/11/03  17:49:52  lwall
  92.  
  93. --- 1,4 -----
  94. ! /* $Header: pch.c,v 2.0.1.3 86/11/14 10:08:33 lwall Exp $
  95.    *
  96.    * $Log:    pch.c,v $
  97.    * Revision 2.0.1.3  86/11/14  10:08:33  lwall
  98. ***************
  99. *** 1,6
  100.   /* $Header: pch.c,v 2.0.1.2 86/11/03 17:49:52 lwall Exp $
  101.    *
  102.    * $Log:    pch.c,v $
  103.    * Revision 2.0.1.2  86/11/03  17:49:52  lwall
  104.    * New-style delete triggers spurious assertion error.
  105.    * 
  106.  
  107. --- 1,10 -----
  108.   /* $Header: pch.c,v 2.0.1.3 86/11/14 10:08:33 lwall Exp $
  109.    *
  110.    * $Log:    pch.c,v $
  111. +  * Revision 2.0.1.3  86/11/14  10:08:33  lwall
  112. +  * Fixed problem where a long pattern wouldn't grow the hunk.
  113. +  * Also restored p_input_line when backtracking so error messages are right.
  114. +  * 
  115.    * Revision 2.0.1.2  86/11/03  17:49:52  lwall
  116.    * New-style delete triggers spurious assertion error.
  117.    * 
  118. ***************
  119. *** 401,406
  120.       bool repl_missing = FALSE;    /* we are now backtracking */
  121.       long repl_backtrack_position = 0;
  122.                       /* file pos of first repl line */
  123.       Reg7 LINENUM ptrn_copiable = 0;
  124.                       /* # of copiable lines in ptrn */
  125.   
  126.  
  127. --- 405,411 -----
  128.       bool repl_missing = FALSE;    /* we are now backtracking */
  129.       long repl_backtrack_position = 0;
  130.                       /* file pos of first repl line */
  131. +     LINENUM repl_patch_line;    /* input line number for same */
  132.       Reg7 LINENUM ptrn_copiable = 0;
  133.                       /* # of copiable lines in ptrn */
  134.   
  135. ***************
  136. *** 425,431
  137.           }
  138.           }
  139.           p_input_line++;
  140. !         p_char[++p_end] = *buf;
  141.           p_line[p_end] = Nullch;
  142.           switch (*buf) {
  143.           case '*':
  144.  
  145. --- 430,438 -----
  146.           }
  147.           }
  148.           p_input_line++;
  149. !         p_end++;
  150. !         assert(p_end < hunkmax);
  151. !         p_char[p_end] = *buf;
  152.           p_line[p_end] = Nullch;
  153.           switch (*buf) {
  154.           case '*':
  155. ***************
  156. *** 468,473
  157.               p_ptrn_lines = 0;
  158.               p_first = 1;
  159.           }
  160.           break;
  161.           case '-':
  162.           if (buf[1] == '-') {
  163.  
  164. --- 475,484 -----
  165.               p_ptrn_lines = 0;
  166.               p_first = 1;
  167.           }
  168. +         p_max = p_ptrn_lines + 6;    /* we need this much at least */
  169. +         while (p_max >= hunkmax)
  170. +             grow_hunkmax();
  171. +         p_max = hunkmax;
  172.           break;
  173.           case '-':
  174.           if (buf[1] == '-') {
  175. ***************
  176. *** 492,497
  177.               }
  178.               repl_beginning = p_end;
  179.               repl_backtrack_position = ftell(pfp);
  180.               p_line[p_end] = savestr(buf);
  181.               if (out_of_mem) {
  182.               p_end--;
  183.  
  184. --- 503,509 -----
  185.               }
  186.               repl_beginning = p_end;
  187.               repl_backtrack_position = ftell(pfp);
  188. +             repl_patch_line = p_input_line;
  189.               p_line[p_end] = savestr(buf);
  190.               if (out_of_mem) {
  191.               p_end--;
  192. ***************
  193. *** 601,606
  194.       if (repl_missing) {
  195.           
  196.           /* reset state back to just after --- */
  197.           for (p_end--; p_end > repl_beginning; p_end--)
  198.           free(p_line[p_end]);
  199.           Fseek(pfp, repl_backtrack_position, 0);
  200.  
  201. --- 613,619 -----
  202.       if (repl_missing) {
  203.           
  204.           /* reset state back to just after --- */
  205. +         p_input_line = repl_patch_line;
  206.           for (p_end--; p_end > repl_beginning; p_end--)
  207.           free(p_line[p_end]);
  208.           Fseek(pfp, repl_backtrack_position, 0);
  209.  
  210.