Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ucbvax!hplabs!sdcrdcf!lwall From: lwall@sdcrdcf.UUCP Newsgroups: net.sources.bugs Subject: patch 2.0 patch #8 Message-ID: <4160@sdcrdcf.UUCP> Date: Mon, 16-Feb-87 17:19:25 EST Article-I.D.: sdcrdcf.4160 Posted: Mon Feb 16 17:19:25 1987 Date-Received: Tue, 17-Feb-87 23:27:18 EST Organization: System Development Corporation, Santa Monica Lines: 160 Summary: This is an official patch for patch 2.0. Please apply it. System: patch version 2.0 Patch #: 8 Priority: LOW Subject: Short replacement part causes spurious "Out of sync" message. From: hpl-opus!jewett (Bob Jewett) Description: In a context diff, if the next-to-last hunk has a short replacement section (missing the last line or two of context) because the last hunk deletes everything from there to the end, patch reports that the lines of the pattern and replacement sections don't match up properly. This doesn't happen very often, since few patches do deletions. In fact, you're more likely to run across this bug when trying to apply a patch in reverse, when additions look like deletions. The problem was that the loop applying the patch needed two terminating conditions instead of one, since either the pattern part or the replacement part can run out first. So much for structured programming. Fix: From rn, say "| patch -d DIR", where DIR is your patch source directory. Outside of rn, say "cd DIR; patch #define PATCHLEVEL 8 Index: patch.c Prereq: 2.0.1.3 *** patch.c.old Mon Feb 16 14:02:12 1987 *** patch.c Mon Feb 16 14:02:18 1987 *************** *** 1,5 char rcsid[] = ! "$Header: patch.c,v 2.0.1.3 87/01/30 22:45:50 lwall Exp $"; /* patch - a program to apply diffs to original files * --- 1,5 ----- char rcsid[] = ! "$Header: patch.c,v 2.0.1.4 87/02/16 14:00:04 lwall Exp $"; /* patch - a program to apply diffs to original files * *************** *** 9,14 * money off of it, or pretend that you wrote it. * * $Log: patch.c,v $ * Revision 2.0.1.3 87/01/30 22:45:50 lwall * Improved diagnostic on sync error. * Moved do_ed_script() to pch.c. --- 9,17 ----- * money off of it, or pretend that you wrote it. * * $Log: patch.c,v $ + * Revision 2.0.1.4 87/02/16 14:00:04 lwall + * Short replacement caused spurious "Out of sync" message. + * * Revision 2.0.1.3 87/01/30 22:45:50 lwall * Improved diagnostic on sync error. * Moved do_ed_script() to pch.c. *************** *** 548,553 #define IN_ELSE 3 Reg4 int def_state = OUTSIDE; Reg5 bool R_do_defines = do_defines; where--; while (pch_char(new) == '=' || pch_char(new) == '\n') --- 551,557 ----- #define IN_ELSE 3 Reg4 int def_state = OUTSIDE; Reg5 bool R_do_defines = do_defines; + Reg6 LINENUM pat_end = pch_end(); where--; while (pch_char(new) == '=' || pch_char(new) == '\n') *************** *** 570,575 last_frozen_line++; old++; } else if (pch_char(new) == '+') { copy_till(where + old - 1); if (R_do_defines) { --- 574,581 ----- last_frozen_line++; old++; } + else if (new > pat_end) + break; else if (pch_char(new) == '+') { copy_till(where + old - 1); if (R_do_defines) { *************** *** 629,635 } } } ! if (new <= pch_end() && pch_char(new) == '+') { copy_till(where + old - 1); if (R_do_defines) { if (def_state == OUTSIDE) { --- 635,641 ----- } } } ! if (new <= pat_end && pch_char(new) == '+') { copy_till(where + old - 1); if (R_do_defines) { if (def_state == OUTSIDE) { *************** *** 641,647 def_state = IN_ELSE; } } ! while (new <= pch_end() && pch_char(new) == '+') { fputs(pfetch(new), ofp); new++; } --- 647,653 ----- def_state = IN_ELSE; } } ! while (new <= pat_end && pch_char(new) == '+') { fputs(pfetch(new), ofp); new++; }