patches for patch

Dorab Patel dorab at neptune.cs.ucla.edu
Thu May 15 11:09:23 AEST 1986


here are context diffs to Larry Wall's "patch" program to fix some
minor bugs. the version that i applied these fixes to was obtained
from the UCI MH distribution which already had been modified for the
new "diff -c" that comes with 4.3bsd. thus, your line numbers may
vary. the change from (long) to (off_t) for the lseeks is not
critical ... in fact, may be undesirable if off_t is not defined on
your system.

'dorab


*** /tmp/,RCSt1016181   Wed May 14 18:01:10 1986
--- /tmp/,RCSt2016181   Wed May 14 18:01:14 1986
***************
*** 1,10 ****
  #ifndef lint
! static char RCSid[] = "@(#)patch.c    $Revision: 1.4 $";
  #endif not lint
     
  /* patch - a program to apply diffs to original files
   *
!  * $Header: patch.c,v 1.4 85/08/15 15:00:00 van Exp $
   *
   * Copyright 1984, Larry Wall
   *
--- 1,10 ----
  #ifndef lint
! static char RCSid[] = "@(#)patch.c    $Revision: 1.5 $";
  #endif not lint
     
  /* patch - a program to apply diffs to original files
   *
!  * $Header: patch.c,v 1.5 86/05/12 22:56:00 dorab Exp $
   *
   * Copyright 1984, Larry Wall
   *
***************
*** 12,17 ****
--- 12,24 ----
   * money off of it, or pretend that you wrote it.
   *
   * $Log:      patch.c,v $
+  * Revision 1.5  86/05/12  22:56:00  dorab
+  * changed (long) to (off_t) for lseeks.
+  * check_before was using max_pos_offset rather than max_neg_offset so
+  * changed that.
+  * the calculation of max_neg_offset should use ... + pch_context()
+  * rather than ... - pch_context().
+  *
   * Revision 1.4  85/08/15  15:00:00  van
   * initial revision as modified at berkeley
   *
***************
*** 186,192 ****
  bool rev_in_string();
  char *fetchname();
  long atol();
! long lseek();
  char *mktemp();
     
  /* patch type */
--- 193,199 ----
  bool rev_in_string();
  char *fetchname();
  long atol();
! off_t lseek();
  char *mktemp();
     
  /* patch type */
***************
*** 447,453 ****
      register LINENUM max_pos_offset = input_lines - first_guess
                                - pat_lines + 1;
      register LINENUM max_neg_offset = first_guess - last_frozen_line - 1
!                               - pch_context();
     
      if (!pat_lines)                   /* null range matches always */
        return first_guess;
--- 454,460 ----
      register LINENUM max_pos_offset = input_lines - first_guess
                                - pat_lines + 1;
      register LINENUM max_neg_offset = first_guess - last_frozen_line - 1
!                               + pch_context();
     
      if (!pat_lines)                   /* null range matches always */
        return first_guess;
***************
*** 457,463 ****
        return first_guess;
      for (offset = 1; ; offset++) {
        bool check_after = (offset <= max_pos_offset);
!       bool check_before = (offset <= max_pos_offset);
     
        if (check_after && patch_match(first_guess,offset)) {
  #ifdef DEBUGGING
--- 464,470 ----
        return first_guess;
      for (offset = 1; ; offset++) {
        bool check_after = (offset <= max_pos_offset);
!       bool check_before = (offset <= max_neg_offset);
     
        if (check_after && patch_match(first_guess,offset)) {
  #ifdef DEBUGGING
***************
*** 1088,1094 ****
            whichbuf = 1;
        else {
            tiline[whichbuf] = baseline;
!           Lseek(tifd,(long)baseline / lines_per_buf * BUFFERSIZE,0);
            if (read(tifd,tibuf[whichbuf],BUFFERSIZE) < 0)
                fatal("Error reading tmp file %s.\n",TMPINNAME);
        }
--- 1095,1101 ----
            whichbuf = 1;
        else {
            tiline[whichbuf] = baseline;
!           Lseek(tifd,(off_t)(baseline / lines_per_buf * BUFFERSIZE),0);
            if (read(tifd,tibuf[whichbuf],BUFFERSIZE) < 0)
                fatal("Error reading tmp file %s.\n",TMPINNAME);
        }



More information about the Comp.sources.bugs mailing list