home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume7 / patch2 / patch8 < prev    next >
Text File  |  1987-02-16  |  5KB  |  164 lines

  1. /* Written  5:19 pm  Feb 16, 1987 by lwall@sdcrdcf.UUCP in mirror:net.sources.bugs */
  2. /* ---------- "patch 2.0 patch #8" ---------- */
  3. System: patch version 2.0
  4. Patch #: 8
  5. Priority: LOW
  6. Subject: Short replacement part causes spurious "Out of sync" message.
  7. From: hpl-opus!jewett (Bob Jewett)
  8.  
  9. Description:
  10.     In a context diff, if the next-to-last hunk has a short replacement
  11.     section (missing the last line or two of context) because the last
  12.     hunk deletes everything from there to the end, patch reports that
  13.     the lines of the pattern and replacement sections don't match up
  14.     properly.  This doesn't happen very often, since few patches do
  15.     deletions.  In fact, you're more likely to run across this bug when
  16.     trying to apply a patch in reverse, when additions look like deletions.
  17.  
  18.     The problem was that the loop applying the patch needed two
  19.     terminating conditions instead of one, since either the pattern
  20.     part or the replacement part can run out first.  So much for
  21.     structured programming.
  22.  
  23. Fix:    From rn, say "| patch -d DIR", where DIR is your patch source
  24.     directory.  Outside of rn, say "cd DIR; patch <thisarticle".
  25.     If you don't have the patch program, apply the following by hand,
  26.     or get patch.
  27.  
  28.     If patch indicates that patchlevel is the wrong version, you may need
  29.     to apply one or more previous patches, or the patch may already
  30.     have been applied.  See the patchlevel.h file to find out what has or
  31.     has not been applied.  In any event, don't continue with the patch.
  32.  
  33.     If you are missing previous patches they can be obtained from me:
  34.  
  35.     Larry Wall
  36.     {allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
  37.  
  38.     If you send a mail message of the following form it will greatly speed
  39.     processing:
  40.  
  41.     Subject: Command
  42.     @SH mailpatch PATH patch 2.0 LIST
  43.  
  44.     where PATH is a return path FROM ME TO YOU in bang notation, and LIST
  45.     is the number of one or more patches you need, separated by spaces,
  46.     commas, and/or hyphens.  Saying 35- says everything from 35 to the end.
  47.  
  48. Index: patchlevel.h
  49. Prereq: 7
  50. 1c1
  51. < #define PATCHLEVEL 7
  52. ---
  53. > #define PATCHLEVEL 8
  54.  
  55. Index: patch.c
  56. Prereq: 2.0.1.3
  57. *** patch.c.old    Mon Feb 16 14:02:12 1987
  58. *** patch.c    Mon Feb 16 14:02:18 1987
  59. ***************
  60. *** 1,5
  61.   char rcsid[] =
  62. !     "$Header: patch.c,v 2.0.1.3 87/01/30 22:45:50 lwall Exp $";
  63.   
  64.   /* patch - a program to apply diffs to original files
  65.    *
  66.  
  67. --- 1,5 -----
  68.   char rcsid[] =
  69. !     "$Header: patch.c,v 2.0.1.4 87/02/16 14:00:04 lwall Exp $";
  70.   
  71.   /* patch - a program to apply diffs to original files
  72.    *
  73. ***************
  74. *** 9,14
  75.    * money off of it, or pretend that you wrote it.
  76.    *
  77.    * $Log:    patch.c,v $
  78.    * Revision 2.0.1.3  87/01/30  22:45:50  lwall
  79.    * Improved diagnostic on sync error.
  80.    * Moved do_ed_script() to pch.c.
  81.  
  82. --- 9,17 -----
  83.    * money off of it, or pretend that you wrote it.
  84.    *
  85.    * $Log:    patch.c,v $
  86. +  * Revision 2.0.1.4  87/02/16  14:00:04  lwall
  87. +  * Short replacement caused spurious "Out of sync" message.
  88. +  * 
  89.    * Revision 2.0.1.3  87/01/30  22:45:50  lwall
  90.    * Improved diagnostic on sync error.
  91.    * Moved do_ed_script() to pch.c.
  92. ***************
  93. *** 548,553
  94.   #define IN_ELSE 3
  95.       Reg4 int def_state = OUTSIDE;
  96.       Reg5 bool R_do_defines = do_defines;
  97.   
  98.       where--;
  99.       while (pch_char(new) == '=' || pch_char(new) == '\n')
  100.  
  101. --- 551,557 -----
  102.   #define IN_ELSE 3
  103.       Reg4 int def_state = OUTSIDE;
  104.       Reg5 bool R_do_defines = do_defines;
  105. +     Reg6 LINENUM pat_end = pch_end();
  106.   
  107.       where--;
  108.       while (pch_char(new) == '=' || pch_char(new) == '\n')
  109. ***************
  110. *** 570,575
  111.           last_frozen_line++;
  112.           old++;
  113.       }
  114.       else if (pch_char(new) == '+') {
  115.           copy_till(where + old - 1);
  116.           if (R_do_defines) {
  117.  
  118. --- 574,581 -----
  119.           last_frozen_line++;
  120.           old++;
  121.       }
  122. +     else if (new > pat_end)
  123. +         break;
  124.       else if (pch_char(new) == '+') {
  125.           copy_till(where + old - 1);
  126.           if (R_do_defines) {
  127. ***************
  128. *** 629,635
  129.           }
  130.       }
  131.       }
  132. !     if (new <= pch_end() && pch_char(new) == '+') {
  133.       copy_till(where + old - 1);
  134.       if (R_do_defines) {
  135.           if (def_state == OUTSIDE) {
  136.  
  137. --- 635,641 -----
  138.           }
  139.       }
  140.       }
  141. !     if (new <= pat_end && pch_char(new) == '+') {
  142.       copy_till(where + old - 1);
  143.       if (R_do_defines) {
  144.           if (def_state == OUTSIDE) {
  145. ***************
  146. *** 641,647
  147.           def_state = IN_ELSE;
  148.           }
  149.       }
  150. !     while (new <= pch_end() && pch_char(new) == '+') {
  151.           fputs(pfetch(new), ofp);
  152.           new++;
  153.       }
  154.  
  155. --- 647,653 -----
  156.           def_state = IN_ELSE;
  157.           }
  158.       }
  159. !     while (new <= pat_end && pch_char(new) == '+') {
  160.           fputs(pfetch(new), ofp);
  161.           new++;
  162.       }
  163. /* End of text from mirror:net.sources.bugs */
  164.