diff -C2 -N patch-2.0.12u6/ChangeLog patch-2.0.12u7/ChangeLog *** patch-2.0.12u6/ChangeLog Mon Mar 16 14:10:54 1992 --- patch-2.0.12u7/ChangeLog Mon Jul 6 15:42:24 1992 *************** *** 1,2 **** --- 1,46 ---- + Mon Jul 6 13:01:52 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * patchlevel.h: PATCHLEVEL 12u7. + + * Makefile.SH (dist): New target. + Makedist: File removed. + + * inp.c (plan_a): Check whether the user can write to the + file, not whether anyone can write to the file. + + Sat Jul 4 00:06:58 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * inp.c (plan_a): Try to check out read-only files from RCS or SCCS. + + * util.c (move_file): If backing up by linking fails, try copying. + From cek@sdc.boeing.com (Conrad Kimball). + + * patch.c (get_some_switches): Eliminate -E option; always + remove empty output files. + + * util.c (fetchname): Only undo slash removal for relative + paths if -p was not given. + + * Makefile.sh: Add mostlyclean target. + + Fri Jul 3 23:48:14 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * util.c (fetchname): Accept whitespace between `Index:' and filename. + Also plug a small memory leak for diffs against /dev/null. + From eggert@twinsun.com (Paul Eggert). + + * common.h: Don't define TRUE and FALSE if already defined. + From phk@data.fls.dk (Poul-Henning Kamp). + + Wed Apr 29 10:19:33 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu) + + * backupfile.c (get_version): Exit if given a bad backup type. + + Fri Mar 27 09:57:14 1992 Karl Berry (karl at hayley) + + * common.h (S_ISDIR, S_ISREG): define these. + * inp.c (plan_a): use S_ISREG, not S_IFREG. + * util.c (fetchname): use S_ISDIR, not S_IFDIR. + Mon Mar 16 14:10:42 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) *************** *** 130,133 **** --- 174,179 ---- Local Variables: + mode: indented-text + left-margin: 8 version-control: never end: diff -C2 -N patch-2.0.12u6/Makedist patch-2.0.12u7/Makedist *** patch-2.0.12u6/Makedist Sat Mar 14 15:35:05 1992 --- patch-2.0.12u7/Makedist *************** *** 1,11 **** - #!/bin/sh - # Make distribution tar file for patch with unified diff changes. - - files='ChangeLog Configure EXTERN.h INTERN.h MANIFEST Makedist Makefile.SH README common.h config.H config.h.SH inp.c inp.h malloc.c patch.c patch.man patchlevel.h pch.c pch.h util.c util.h version.c version.h backupfile.c backupfile.h' - - distdir=patch-2.0.12u6 - - mkdir $distdir && - ln $files $distdir && - tar -cvz -f $distdir.tar.Z $distdir - rm -rf $distdir --- 0 ---- diff -C2 -N patch-2.0.12u6/Makefile.SH patch-2.0.12u7/Makefile.SH *** patch-2.0.12u6/Makefile.SH Sat Mar 14 13:25:55 1992 --- patch-2.0.12u7/Makefile.SH Mon Jul 6 14:28:10 1992 *************** *** 79,82 **** --- 79,84 ---- rm -f patch *.o core + mostlyclean: clean + distclean: clean rm -f $(addedbyconf) *************** *** 84,87 **** --- 86,102 ---- realclean: distclean rm -f *.orig *~ + + DISTFILES=ChangeLog Configure EXTERN.h INTERN.h MANIFEST Makefile.SH \ + README common.h config.H config.h.SH inp.c inp.h malloc.c patch.c patch.man \ + patchlevel.h pch.c pch.h util.c util.h version.c version.h backupfile.c \ + backupfile.h + + dist: $(DISTFILES) + echo patch-2.0.`sed -e '/PATCHLEVEL/!d' -e 's/[^0-9u.]*\([0-9u.]*\).*/\1/' -e q patchlevel.h` > .fname + rm -rf `cat .fname` + mkdir `cat .fname` + ln $(DISTFILES) `cat .fname` + tar chZf `cat .fname`.tar.Z `cat .fname` + rm -rf `cat .fname` .fname # The following lint has practically everything turned on. Unfortunately, diff -C2 -N patch-2.0.12u6/README patch-2.0.12u7/README *** patch-2.0.12u6/README Mon Mar 16 14:17:40 1992 --- patch-2.0.12u7/README Sat Jul 4 08:54:17 1992 *************** *** 1,13 **** This version of patch contains modifications made by the Free Software Foundation, summarized in the file ChangeLog. Primarily they are to ! support the unified context diff format that GNU diff can produce, but ! they also include some fixes for other bugs. The FSF is distributing ! this version of patch itself because, as of this writing, Larry has ! not released a new version of patch since mid-1988. I have heard that ! he has been too busy working on other things, like Perl. ! The FSF changes to patch are not covered by the GNU General Public ! License; they are distributed on the same terms as the rest of patch ! (actually, on somewhat less restrictive terms). Please send bug reports for this version of patch to --- 1,25 ---- This version of patch contains modifications made by the Free Software Foundation, summarized in the file ChangeLog. Primarily they are to ! support the unified context diff format that GNU diff can produce, and ! to support making GNU Emacs-style backup files. They also include ! fixes for some bugs. The FSF is distributing this version of patch ! independently because as of this writing, Larry Wall has not released ! a new version of patch since mid-1988. I have heard that he has been ! too busy working on other things, like Perl. ! Here is a wish list of some projects to improve patch: ! ! 1. Correctly handle files and patchfiles that contain NUL characters. ! This is hard to do straightforwardly; it would be less work to ! adopt a kind of escape encoding internally. ! Let ESC be a "control prefix". ESC @ stands for NUL. ESC [ stands for ESC. ! You need to crunch this when reading input (replace fgets), ! and when writing the output file (replace fputs), ! but otherwise everything can go along as it does now. ! Be careful to handle reject files correctly; ! I think they are currently created using `write', not `fputs'. ! ! 2. Correctly handle patches produced by GNU diff for files that do ! not end with a newline. Please send bug reports for this version of patch to diff -C2 -N patch-2.0.12u6/backupfile.c patch-2.0.12u7/backupfile.c *** patch-2.0.12u6/backupfile.c Sat Mar 14 21:52:41 1992 --- patch-2.0.12u7/backupfile.c Wed Apr 29 10:19:40 1992 *************** *** 335,339 **** return backup_types[i]; invalid_arg ("version control type", version, i); ! return numbered_existing; } #endif /* NODIR */ --- 335,339 ---- return backup_types[i]; invalid_arg ("version control type", version, i); ! exit (1); } #endif /* NODIR */ diff -C2 -N patch-2.0.12u6/common.h patch-2.0.12u7/common.h *** patch-2.0.12u6/common.h Sat Mar 14 15:20:22 1992 --- patch-2.0.12u7/common.h Fri Jul 3 23:48:36 1992 *************** *** 49,54 **** --- 49,59 ---- /* constants */ + /* AIX predefines these. */ + #ifndef TRUE #define TRUE (1) + #endif + #ifndef FALSE #define FALSE (0) + #endif #define MAXHUNKSIZE 100000 /* is this enough lines? */ *************** *** 167,168 **** --- 172,180 ---- #endif char *getenv(); + + #if !defined(S_ISDIR) && defined(S_IFDIR) + #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) + #endif + #if !defined(S_ISREG) && defined(S_IFREG) + #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) + #endif diff -C2 -N patch-2.0.12u6/inp.c patch-2.0.12u7/inp.c *** patch-2.0.12u6/inp.c Sun Jan 20 20:12:22 1991 --- patch-2.0.12u7/inp.c Mon Jul 6 13:05:31 1992 *************** *** 87,91 **** close(creat(filename, 0666)); } ! if (stat(filename, &filestat) < 0) { Sprintf(buf, "RCS/%s%s", filename, RCSSUFFIX); if (stat(buf, &filestat) >= 0 || stat(buf+4, &filestat) >= 0) { --- 87,93 ---- close(creat(filename, 0666)); } ! /* For read-only files, look for RCS or SCCS copies to check out. ! co or get will fail if someone else has already locked the file. */ ! if (stat(filename, &filestat) < 0 || access(filename, 2) < 0) { Sprintf(buf, "RCS/%s%s", filename, RCSSUFFIX); if (stat(buf, &filestat) >= 0 || stat(buf+4, &filestat) >= 0) { *************** *** 92,97 **** Sprintf(buf, CHECKOUT, filename); if (verbose) ! say2("Can't find %s--attempting to check it out from RCS.\n", ! filename); if (system(buf) || stat(filename, &filestat)) fatal2("Can't check out %s.\n", filename); --- 94,98 ---- Sprintf(buf, CHECKOUT, filename); if (verbose) ! say2("Attempting to check out %s from RCS.\n", filename); if (system(buf) || stat(filename, &filestat)) fatal2("Can't check out %s.\n", filename); *************** *** 103,112 **** Sprintf(buf, GET, s); if (verbose) ! say2("Can't find %s--attempting to get it from SCCS.\n", ! filename); if (system(buf) || stat(filename, &filestat)) fatal2("Can't get %s.\n", filename); } ! else fatal2("Can't find %s.\n", filename); } --- 104,112 ---- Sprintf(buf, GET, s); if (verbose) ! say2("Attempting to get %s from SCCS.\n", filename); if (system(buf) || stat(filename, &filestat)) fatal2("Can't get %s.\n", filename); } ! else if (stat(filename, &filestat) < 0) fatal2("Can't find %s.\n", filename); } *************** *** 113,117 **** } filemode = filestat.st_mode; ! if ((filemode & S_IFMT) & ~S_IFREG) fatal2("%s is not a normal file--can't patch.\n", filename); i_size = filestat.st_size; --- 113,117 ---- } filemode = filestat.st_mode; ! if (!S_ISREG(filemode)) fatal2("%s is not a normal file--can't patch.\n", filename); i_size = filestat.st_size; diff -C2 -N patch-2.0.12u6/patch.c patch-2.0.12u7/patch.c *** patch-2.0.12u6/patch.c Sat Mar 14 21:52:45 1992 --- patch-2.0.12u7/patch.c Sat Jul 4 02:33:40 1992 *************** *** 117,123 **** void my_exit(); - /* TRUE if -E was specified on command line. */ - static int remove_empty_files = FALSE; - /* TRUE if -R was specified on command line. */ static int reverse_flag_specified = FALSE; --- 117,120 ---- *************** *** 340,345 **** chmod(outname, filemode); ! if (remove_empty_files && stat(realout, &statbuf) == 0 ! && statbuf.st_size == 0) { if (verbose) say2("Removing %s (empty after patching).\n", realout); --- 337,341 ---- chmod(outname, filemode); ! if (stat(realout, &statbuf) >= 0 && statbuf.st_size == 0) { if (verbose) say2("Removing %s (empty after patching).\n", realout); *************** *** 484,490 **** diff_type = ED_DIFF; break; - case 'E': - remove_empty_files = TRUE; - break; case 'f': force = TRUE; --- 480,483 ---- *************** *** 544,548 **** fprintf(stderr, "patch: unrecognized option `%s'\n", Argv[0]); fprintf(stderr, "\ ! Usage: patch [-ceEflnNRsSuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\ [-D symbol] [-Fmax-fuzz] [-o out-file] [-p[strip-count]]\n\ [-r rej-name] [-V {numbered,existing,simple}] [origfile] [patchfile]\n\ --- 537,541 ---- fprintf(stderr, "patch: unrecognized option `%s'\n", Argv[0]); fprintf(stderr, "\ ! Usage: patch [-ceflnNRsSuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\ [-D symbol] [-Fmax-fuzz] [-o out-file] [-p[strip-count]]\n\ [-r rej-name] [-V {numbered,existing,simple}] [origfile] [patchfile]\n\ diff -C2 -N patch-2.0.12u6/patch.man patch-2.0.12u7/patch.man *** patch-2.0.12u6/patch.man Mon Mar 16 14:07:41 1992 --- patch-2.0.12u7/patch.man Sat Jul 4 04:47:57 1992 *************** *** 1,2 **** --- 1,3 ---- + .\" -*- nroff -*- .rn '' }` ''' $Header: patch.man,v 2.0.1.2 88/06/22 20:47:18 lwall Locked $ *************** *** 107,113 **** --- 108,118 ---- backup file that does not already exist. .PP + .I patch + removes output files that are empty after being patched. + .PP You may also specify where you want the output to go with a .B -o switch; if that file already exists, it is backed up first. + .PP If .I patchfile *************** *** 198,205 **** for the name of the file to patch. .PP ! (If the original file cannot be found, but a suitable SCCS or RCS file is ! handy, .I patch ! will attempt to get or check out the file.) .PP Additionally, if the leading garbage contains a \*(L"Prereq: \*(R" line, --- 203,210 ---- for the name of the file to patch. .PP ! If the original file cannot be found or is read-only, but a suitable ! SCCS or RCS file is handy, .I patch ! will attempt to get or check out the file. .PP Additionally, if the leading garbage contains a \*(L"Prereq: \*(R" line, *************** *** 269,277 **** to interpret the patch file as an ed script. .TP 5 - .B \-E - causes - .I patch - to remove output files that are empty after the patches have been applied. - .TP 5 .B \-f forces --- 274,277 ---- *************** *** 346,350 **** and not specifying .B \-p ! at all just gives you "blurfl.c". Whatever you end up with is looked for either in the current directory, or the directory specified by the --- 346,352 ---- and not specifying .B \-p ! at all just gives you "blurfl.c", unless all of the directories in the ! leading path (u/howard/src/blurfl) exist and that path is relative, ! in which case you get the entire pathname unmodified. Whatever you end up with is looked for either in the current directory, or the directory specified by the diff -C2 -N patch-2.0.12u6/patchlevel.h patch-2.0.12u7/patchlevel.h *** patch-2.0.12u6/patchlevel.h Sat Mar 14 15:30:53 1992 --- patch-2.0.12u7/patchlevel.h Mon Jul 6 15:42:09 1992 *************** *** 1 **** ! #define PATCHLEVEL "12u6" --- 1 ---- ! #define PATCHLEVEL "12u7" diff -C2 -N patch-2.0.12u6/util.c patch-2.0.12u7/util.c *** patch-2.0.12u6/util.c Sat Mar 14 21:52:43 1992 --- patch-2.0.12u7/util.c Mon Jul 6 15:25:27 1992 *************** *** 76,82 **** #endif if (link(to, bakname) < 0) { ! say3("patch: can't backup %s, output is in %s\n", ! to, from); ! return -1; } while (unlink(to) >= 0) ; --- 76,98 ---- #endif if (link(to, bakname) < 0) { ! /* Maybe `to' is a symlink into a different file system. ! Copying replaces the symlink with a file; using rename ! would be better. */ ! Reg4 int tofd; ! Reg5 int bakfd; ! ! bakfd = creat(bakname, 0666); ! if (bakfd < 0) { ! say3("patch: can't backup %s, output is in %s.\n", to, from); ! return -1; ! } ! tofd = open(to, 0); ! if (tofd < 0) ! fatal2("patch: internal error, can't open %s\n", to); ! while ((i=read(tofd, buf, sizeof buf)) > 0) ! if (write(bakfd, buf, i) != i) ! fatal1("patch: write failed\n"); ! Close(tofd); ! Close(bakfd); } while (unlink(to) >= 0) ; *************** *** 333,369 **** int assume_exists; { ! char *s; char *name; Reg1 char *t; char tmpbuf[200]; if (!at) return Nullch; ! s = savestr(at); ! for (t=s; isspace(*t); t++) ; ! name = t; #ifdef DEBUGGING if (debug & 128) ! say4("fetchname %s %d %d\n",name,strip_leading,assume_exists); #endif ! if (strnEQ(name, "/dev/null", 9)) /* so files can be created by diffing */ return Nullch; /* against /dev/null. */ for (; *t && !isspace(*t); t++) if (*t == '/') ! if (--strip_leading >= 0) name = t+1; *t = '\0'; ! if (name != s && *s != '/') { name[-1] = '\0'; ! if (stat(s, &filestat) == 0 && (filestat.st_mode & S_IFDIR)) { name[-1] = '/'; ! name=s; } } name = savestr(name); ! Sprintf(tmpbuf, "RCS/%s", name); ! free(s); if (stat(name, &filestat) < 0 && !assume_exists) { ! Strcat(tmpbuf, RCSSUFFIX); if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+4, &filestat) < 0) { Sprintf(tmpbuf, "SCCS/%s%s", SCCSPREFIX, name); --- 349,394 ---- int assume_exists; { ! char *fullname; char *name; Reg1 char *t; char tmpbuf[200]; + int sleading = strip_leading; if (!at) return Nullch; ! while (isspace(*at)) ! at++; #ifdef DEBUGGING if (debug & 128) ! say4("fetchname %s %d %d\n",at,strip_leading,assume_exists); #endif ! if (strnEQ(at, "/dev/null", 9)) /* so files can be created by diffing */ return Nullch; /* against /dev/null. */ + name = fullname = t = savestr(at); + + /* Strip off up to `sleading' leading slashes and null terminate. */ for (; *t && !isspace(*t); t++) if (*t == '/') ! if (--sleading >= 0) name = t+1; *t = '\0'; ! ! /* If no -p option was given (957 is the default value!), ! we were given a relative pathname, ! and the leading directories that we just stripped off all exist, ! put them back on. */ ! if (strip_leading == 957 && name != fullname && *fullname != '/') { name[-1] = '\0'; ! if (stat(fullname, &filestat) >= 0 && S_ISDIR (filestat.st_mode)) { name[-1] = '/'; ! name=fullname; } } + name = savestr(name); ! free(fullname); ! if (stat(name, &filestat) < 0 && !assume_exists) { ! Sprintf(tmpbuf, "RCS/%s%s", name, RCSSUFFIX); if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+4, &filestat) < 0) { Sprintf(tmpbuf, "SCCS/%s%s", SCCSPREFIX, name);