Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: unknown; site unknown Path: utzoo!watmath!clyde!cbosgd!ukma!psuvm.bitnet!psuvax1!burdvax!sdcrdcf!ucla-cs!dorab From: dorab@neptune.cs.ucla.edu (Dorab Patel) Newsgroups: net.sources.bugs Subject: patches for patch Message-ID: <13434@ucla-cs.ARPA> Date: Wed, 14-May-86 21:09:23 EDT Article-I.D.: ucla-cs.13434 Posted: Wed May 14 21:09:23 1986 Date-Received: Mon, 19-May-86 05:29:50 EDT Organization: UCLA Computer Science Dept. Lines: 120 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); }