diff -C2 -N patch-2.0.12u5/ChangeLog patch-2.0.12u6/ChangeLog *** patch-2.0.12u5/ChangeLog Tue Dec 3 12:09:49 1991 --- patch-2.0.12u6/ChangeLog Mon Mar 16 14:10:54 1992 *************** *** 1,2 **** --- 1,37 ---- + Mon Mar 16 14:10:42 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) + + * patchlevel.h: PATCHLEVEL 12u6. + + Sat Mar 14 13:13:29 1992 David J. MacKenzie (djm at frob.eng.umd.edu) + + * Configure, config.h.SH: Check for directory header and unistd.h. + + * patch.c (main): If -E was given and output file is empty after + patching, remove it. + (get_some_switches): Recognize -E option. + + * patch.c (copy_till): Make garbled output an error, not a warning + that doesn't change the exit status. + + * common.h: Protect against system declarations of malloc and realloc. + + * Makedist: Add backupfile.[ch]. + + * Configure: Look for C library where NeXT and SVR4 put it. + Look in /usr/ucb after /bin and /usr/bin for utilities, + and look in /usr/ccs/bin, to make SVR4 happier. + Recognize m68k predefine. + + * util.c (fetchname): Test of stat return value was backward. + From csss@scheme.cs.ubc.ca. + + * version.c (version): Exit with status 0, not 1. + + * Makefile.SH: Add backupfile.[cho]. + * patch.c (main): Initialize backup file generation. + (get_some_switches): Add -V option. + * common.h, util,c, patch.c: Replace origext with simple_backup_suffix. + * util.c (move_file): Use find_backup_file_name. + Tue Dec 3 11:27:16 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) *************** *** 91,98 **** Sun Dec 17 17:29:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) ! # patch.c (reverse_flag_specified): New variable. (get_some_switches, reinitialize_almost_everything): Use it. - - # in place of * means change has been sent to Wall. Local Variables: --- 126,131 ---- Sun Dec 17 17:29:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) ! * patch.c (reverse_flag_specified): New variable. (get_some_switches, reinitialize_almost_everything): Use it. Local Variables: diff -C2 -N patch-2.0.12u5/Configure patch-2.0.12u6/Configure *** patch-2.0.12u5/Configure Tue Dec 3 11:32:58 1991 --- patch-2.0.12u6/Configure Sat Mar 14 22:05:34 1992 *************** *** 78,81 **** --- 78,83 ---- d_index='' d_voidsig='' + d_dirheader='' + d_unistd='' libc='' mansrc='' *************** *** 126,130 **** define='define' undef='/*undef' ! libpth='/usr/lib /usr/local/lib /lib' smallmach='pdp11 i8086 z8000 i80286 iAPX286' rmlist='kit[1-9]isdone kit[1-9][0-9]isdone' --- 128,132 ---- define='define' undef='/*undef' ! libpth='/usr/lib /usr/local/lib /lib /usr/ccs/lib' smallmach='pdp11 i8086 z8000 i80286 iAPX286' rmlist='kit[1-9]isdone kit[1-9][0-9]isdone' *************** *** 144,149 **** attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc" attrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX" ! attrlist="$attrlist $mc68k __STDC__" ! pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /lib" d_newshome="../../NeWS" defvoidused=7 --- 146,151 ---- attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc" attrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX" ! attrlist="$attrlist mc68k m68k __STDC__" ! pth="/bin /usr/bin /usr/ccs/bin /usr/ucb /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /lib" d_newshome="../../NeWS" defvoidused=7 *************** *** 238,242 **** Much effort has been expended to ensure that this shell script will run on any Unix system. If despite that it blows up on you, your best bet is ! to edit Configure and run it again. Also, let me (lwall@jpl-devvax.jpl.nasa.gov) know how I blew it. If you can't run Configure for some reason, you'll have to generate a config.sh file by hand. --- 240,244 ---- Much effort has been expended to ensure that this shell script will run on any Unix system. If despite that it blows up on you, your best bet is ! to edit Configure and run it again. Also, let me (lwall@netlabs.com) know how I blew it. If you can't run Configure for some reason, you'll have to generate a config.sh file by hand. *************** *** 425,428 **** --- 427,433 ---- echo "Your standard C library is in /lib/libc. Must be Domain/OS." libc=/lib/libc + elif test -f /lib/libsys_s.a; then + echo "Your C library is in /lib/libsys_s.a. Must be a NeXT." + libc=/lib/libsys_s.a else ans=`loc libc.a blurfl/dyick $libpth` *************** *** 673,676 **** --- 678,712 ---- fi + : check for directory library + echo " " + if test -f /usr/include/dirent.h; then + echo "You have dirent.h." + d_dirheader="#define DIRENT" + elif test -f /usr/include/ndir.h; then + echo "You have ndir.h." + d_dirheader="#define USG" + elif test -f /usr/include/sys/ndir.h; then + echo "You have sys/ndir.h." + d_dirheader="#define SYSNDIR + #define USG" + elif test -f /usr/include/sys/dir.h; then + echo "You have sys/dir.h; I hope that's the BSD version." + d_dirheader="#define SYSDIR" + else + echo "I can't find a directory library header file. + That means you won't have numbered backups available." + d_dirheader="#define NODIR" + fi + + : check for unistd.h + echo " " + if test -f /usr/include/unistd.h; then + echo "You have unistd.h." + d_unistd="$define" + else + echo "I don't see unistd.h, but that's OK." + d_unistd="$undef" + fi + : check for void type echo " " *************** *** 889,893 **** if Cppsym vax; then dflt=6 ! elif Cppsym sun mc68000; then dflt=10 elif Cppsym pyr; then --- 925,929 ---- if Cppsym vax; then dflt=6 ! elif Cppsym sun mc68000 mc68k m68k; then dflt=10 elif Cppsym pyr; then *************** *** 1197,1200 **** --- 1233,1242 ---- '') if venix; then dflt='-i -z' + elif xenix; then + if test -f /usr/include/dirent.h; then + dflt='-ldir -lx' + else + dflt='-lx' + fi else dflt='none' *************** *** 1309,1312 **** --- 1351,1356 ---- d_index='$d_index' d_voidsig='$d_voidsig' + d_dirheader='$d_dirheader' + d_unistd='$d_unistd' libc='$libc' mansrc='$mansrc' diff -C2 -N patch-2.0.12u5/MANIFEST patch-2.0.12u6/MANIFEST *** patch-2.0.12u5/MANIFEST Wed Aug 15 01:13:36 1990 --- patch-2.0.12u6/MANIFEST Sat Mar 14 15:37:49 1992 *************** *** 9,12 **** --- 9,14 ---- Makefile.SH 2 The makefile. README 1 Installation instructions. + backupfile.c 4 Make Emacs style backup file names. + backupfile.h 4 Declarations to make Emacs style backup file names. common.h 3 Common definitions. config.H 4 Sample config.h, in case Configure won't run. diff -C2 -N patch-2.0.12u5/Makedist patch-2.0.12u6/Makedist *** patch-2.0.12u5/Makedist Tue Dec 3 12:04:10 1991 --- patch-2.0.12u6/Makedist Sat Mar 14 15:35:05 1992 *************** *** 2,8 **** # 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' ! distdir=patch-2.0.12u5 mkdir $distdir && --- 2,8 ---- # 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 && diff -C2 -N patch-2.0.12u5/Makefile.SH patch-2.0.12u6/Makefile.SH *** patch-2.0.12u5/Makefile.SH Tue Dec 3 12:09:24 1991 --- patch-2.0.12u6/Makefile.SH Sat Mar 14 13:25:55 1992 *************** *** 40,46 **** util = Makefile ! c = patch.c pch.c inp.c version.c util.c ! obj = patch.o pch.o inp.o util.o version.o lintflags = -phbvxac --- 40,46 ---- util = Makefile ! c = patch.c pch.c inp.c util.c version.c backupfile.c ! obj = patch.o pch.o inp.o util.o version.o backupfile.o lintflags = -phbvxac *************** *** 93,101 **** lint $(lintflags) $(defs) $(c) > patch.fuzz ! patch.o: config.h common.h patch.c inp.h pch.h util.h version.h pch.o: config.h common.h pch.c pch.h util.h inp.o: config.h common.h inp.c inp.h util.h ! util.o: config.h common.h util.c util.h version.o: config.h common.h version.c version.h patchlevel.h util.h !NO!SUBS! --- 93,102 ---- lint $(lintflags) $(defs) $(c) > patch.fuzz ! patch.o: config.h common.h patch.c inp.h pch.h util.h version.h backupfile.h pch.o: config.h common.h pch.c pch.h util.h inp.o: config.h common.h inp.c inp.h util.h ! util.o: config.h common.h util.c util.h backupfile.h version.o: config.h common.h version.c version.h patchlevel.h util.h + backupfile.o: config.h backupfile.c backupfile.h !NO!SUBS! diff -C2 -N patch-2.0.12u5/README patch-2.0.12u6/README *** patch-2.0.12u5/README Tue Dec 3 11:48:43 1991 --- patch-2.0.12u6/README Mon Mar 16 14:17:40 1992 *************** *** 1,11 **** ! Note: 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. Please send bug reports for this version of patch to ! bug-gnu-utils@prep.ai.mit.edu as well as to Larry. --djm@gnu.ai.mit.edu (David MacKenzie) --- 1,16 ---- ! 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 ! bug-gnu-utils@prep.ai.mit.edu as well as to Larry Wall (lwall@netlabs.com). --djm@gnu.ai.mit.edu (David MacKenzie) diff -C2 -N patch-2.0.12u5/backupfile.c patch-2.0.12u6/backupfile.c *** patch-2.0.12u5/backupfile.c --- patch-2.0.12u6/backupfile.c Sat Mar 14 21:52:41 1992 *************** *** 0 **** --- 1,339 ---- + /* backupfile.c -- make Emacs style backup file names + Copyright (C) 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it without restriction. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + + /* David MacKenzie . + Some algorithms adapted from GNU Emacs. */ + + #include + #include + #include + #include "backupfile.h" + #include "config.h" + char *index (); + char *rindex (); + + #ifdef DIRENT + #include + #ifdef direct + #undef direct + #endif + #define direct dirent + #define NLENGTH(direct) (strlen((direct)->d_name)) + #else /* !DIRENT */ + #define NLENGTH(direct) ((direct)->d_namlen) + #ifdef USG + #ifdef SYSNDIR + #include + #else /* !SYSNDIR */ + #include + #endif /* !SYSNDIR */ + #else /* !USG */ + #ifdef SYSDIR + #include + #endif /* SYSDIR */ + #endif /* !USG */ + #endif /* !DIRENT */ + + char *malloc (); + + #ifndef isascii + #define ISDIGIT(c) (isdigit ((unsigned char) (c))) + #else + #define ISDIGIT(c) (isascii (c) && isdigit (c)) + #endif + + #if defined (HAVE_UNISTD_H) + #include + #endif + + #if defined (_POSIX_VERSION) + /* POSIX does not require that the d_ino field be present, and some + systems do not provide it. */ + #define REAL_DIR_ENTRY(dp) 1 + #else + #define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0) + #endif + + /* Which type of backup file names are generated. */ + enum backup_type backup_type = none; + + /* The extension added to file names to produce a simple (as opposed + to numbered) backup file name. */ + char *simple_backup_suffix = "~"; + + char *basename (); + char *dirname (); + static char *concat (); + char *find_backup_file_name (); + static char *make_version_name (); + static int max_backup_version (); + static int version_number (); + + #ifndef NODIR + /* Return the name of the new backup file for file FILE, + allocated with malloc. Return 0 if out of memory. + FILE must not end with a '/' unless it is the root directory. + Do not call this function if backup_type == none. */ + + char * + find_backup_file_name (file) + char *file; + { + char *dir; + char *base_versions; + int highest_backup; + + if (backup_type == simple) + return concat (file, simple_backup_suffix); + base_versions = concat (basename (file), ".~"); + if (base_versions == 0) + return 0; + dir = dirname (file); + if (dir == 0) + { + free (base_versions); + return 0; + } + highest_backup = max_backup_version (base_versions, dir); + free (base_versions); + free (dir); + if (backup_type == numbered_existing && highest_backup == 0) + return concat (file, simple_backup_suffix); + return make_version_name (file, highest_backup + 1); + } + + /* Return the number of the highest-numbered backup file for file + FILE in directory DIR. If there are no numbered backups + of FILE in DIR, or an error occurs reading DIR, return 0. + FILE should already have ".~" appended to it. */ + + static int + max_backup_version (file, dir) + char *file, *dir; + { + DIR *dirp; + struct direct *dp; + int highest_version; + int this_version; + int file_name_length; + + dirp = opendir (dir); + if (!dirp) + return 0; + + highest_version = 0; + file_name_length = strlen (file); + + while ((dp = readdir (dirp)) != 0) + { + if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) <= file_name_length) + continue; + + this_version = version_number (file, dp->d_name, file_name_length); + if (this_version > highest_version) + highest_version = this_version; + } + closedir (dirp); + return highest_version; + } + + /* Return a string, allocated with malloc, containing + "FILE.~VERSION~". Return 0 if out of memory. */ + + static char * + make_version_name (file, version) + char *file; + int version; + { + char *backup_name; + + backup_name = malloc (strlen (file) + 16); + if (backup_name == 0) + return 0; + sprintf (backup_name, "%s.~%d~", file, version); + return backup_name; + } + + /* If BACKUP is a numbered backup of BASE, return its version number; + otherwise return 0. BASE_LENGTH is the length of BASE. + BASE should already have ".~" appended to it. */ + + static int + version_number (base, backup, base_length) + char *base; + char *backup; + int base_length; + { + int version; + char *p; + + version = 0; + if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length])) + { + for (p = &backup[base_length]; ISDIGIT (*p); ++p) + version = version * 10 + *p - '0'; + if (p[0] != '~' || p[1]) + version = 0; + } + return version; + } + + /* Return the newly-allocated concatenation of STR1 and STR2. + If out of memory, return 0. */ + + static char * + concat (str1, str2) + char *str1, *str2; + { + char *newstr; + char str1_length = strlen (str1); + + newstr = malloc (str1_length + strlen (str2) + 1); + if (newstr == 0) + return 0; + strcpy (newstr, str1); + strcpy (newstr + str1_length, str2); + return newstr; + } + + /* Return NAME with any leading path stripped off. */ + + char * + basename (name) + char *name; + { + char *base; + + base = rindex (name, '/'); + return base ? base + 1 : name; + } + + /* Return the leading directories part of PATH, + allocated with malloc. If out of memory, return 0. + Assumes that trailing slashes have already been + removed. */ + + char * + dirname (path) + char *path; + { + char *newpath; + char *slash; + int length; /* Length of result, not including NUL. */ + + slash = rindex (path, '/'); + if (slash == 0) + { + /* File is in the current directory. */ + path = "."; + length = 1; + } + else + { + /* Remove any trailing slashes from result. */ + while (slash > path && *slash == '/') + --slash; + + length = slash - path + 1; + } + newpath = malloc (length + 1); + if (newpath == 0) + return 0; + strncpy (newpath, path, length); + newpath[length] = 0; + return newpath; + } + + /* If ARG is an unambiguous match for an element of the + null-terminated array OPTLIST, return the index in OPTLIST + of the matched element, else -1 if it does not match any element + or -2 if it is ambiguous (is a prefix of more than one element). */ + + int + argmatch (arg, optlist) + char *arg; + char **optlist; + { + int i; /* Temporary index in OPTLIST. */ + int arglen; /* Length of ARG. */ + int matchind = -1; /* Index of first nonexact match. */ + int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */ + + arglen = strlen (arg); + + /* Test all elements for either exact match or abbreviated matches. */ + for (i = 0; optlist[i]; i++) + { + if (!strncmp (optlist[i], arg, arglen)) + { + if (strlen (optlist[i]) == arglen) + /* Exact match found. */ + return i; + else if (matchind == -1) + /* First nonexact match found. */ + matchind = i; + else + /* Second nonexact match found. */ + ambiguous = 1; + } + } + if (ambiguous) + return -2; + else + return matchind; + } + + /* Error reporting for argmatch. + KIND is a description of the type of entity that was being matched. + VALUE is the invalid value that was given. + PROBLEM is the return value from argmatch. */ + + void + invalid_arg (kind, value, problem) + char *kind; + char *value; + int problem; + { + fprintf (stderr, "patch: "); + if (problem == -1) + fprintf (stderr, "invalid"); + else /* Assume -2. */ + fprintf (stderr, "ambiguous"); + fprintf (stderr, " %s `%s'\n", kind, value); + } + + static char *backup_args[] = + { + "never", "simple", "nil", "existing", "t", "numbered", 0 + }; + + static enum backup_type backup_types[] = + { + simple, simple, numbered_existing, numbered_existing, numbered, numbered + }; + + /* Return the type of backup indicated by VERSION. + Unique abbreviations are accepted. */ + + enum backup_type + get_version (version) + char *version; + { + int i; + + if (version == 0 || *version == 0) + return numbered_existing; + i = argmatch (version, backup_args); + if (i >= 0) + return backup_types[i]; + invalid_arg ("version control type", version, i); + return numbered_existing; + } + #endif /* NODIR */ diff -C2 -N patch-2.0.12u5/backupfile.h patch-2.0.12u6/backupfile.h *** patch-2.0.12u5/backupfile.h --- patch-2.0.12u6/backupfile.h Sat Mar 14 12:31:52 1992 *************** *** 0 **** --- 1,35 ---- + /* backupfile.h -- declarations for making Emacs style backup file names + Copyright (C) 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it without restriction. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ + + /* When to make backup files. */ + enum backup_type + { + /* Never make backups. */ + none, + + /* Make simple backups of every file. */ + simple, + + /* Make numbered backups of files that already have numbered backups, + and simple backups of the others. */ + numbered_existing, + + /* Make numbered backups of every file. */ + numbered + }; + + extern enum backup_type backup_type; + extern char *simple_backup_suffix; + + #ifdef __STDC__ + char *find_backup_file_name (char *file); + #else + char *find_backup_file_name (); + #endif diff -C2 -N patch-2.0.12u5/common.h patch-2.0.12u6/common.h *** patch-2.0.12u5/common.h Tue Jul 2 03:24:49 1991 --- patch-2.0.12u6/common.h Sat Mar 14 15:20:22 1992 *************** *** 34,37 **** --- 34,41 ---- #define Strcat (void)strcat + /* NeXT declares malloc and realloc incompatibly from us in some of + these files. Temporarily redefine them to prevent errors. */ + #define malloc system_malloc + #define realloc system_realloc #include #include *************** *** 40,43 **** --- 44,49 ---- #include #include + #undef malloc + #undef realloc /* constants */ *************** *** 109,113 **** EXT char rejname[128]; - EXT char *origext INIT(Nullch); EXT char *origprae INIT(Nullch); --- 115,118 ---- diff -C2 -N patch-2.0.12u5/config.h.SH patch-2.0.12u6/config.h.SH *** patch-2.0.12u5/config.h.SH Tue Jul 2 03:25:48 1991 --- patch-2.0.12u6/config.h.SH Sat Mar 14 21:52:36 1992 *************** *** 85,88 **** --- 85,98 ---- #$d_voidsig VOIDSIG /**/ + /* DIRHEADER: + * This definition indicates which directory library header to use. + */ + $d_dirheader + + /* HAVE_UNISTD_H: + * This is defined if the system has unistd.h. + */ + #$d_unistd HAVE_UNISTD_H /**/ + /* Reg1: * This symbol, along with Reg2, Reg3, etc. is either the word "register" diff -C2 -N patch-2.0.12u5/patch.c patch-2.0.12u6/patch.c *** patch-2.0.12u5/patch.c Sun Jan 20 20:35:19 1991 --- patch-2.0.12u6/patch.c Sat Mar 14 21:52:45 1992 *************** *** 98,101 **** --- 98,102 ---- #include "pch.h" #include "inp.h" + #include "backupfile.h" /* procedures */ *************** *** 116,120 **** void my_exit(); ! /* Nonzero if -R was specified on command line. */ static int reverse_flag_specified = FALSE; --- 117,124 ---- 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; *************** *** 174,177 **** --- 178,194 ---- Argc = argc; Argv = argv; + { + char *v; + + v = getenv ("SIMPLE_BACKUP_SUFFIX"); + if (v) + simple_backup_suffix = v; + else + simple_backup_suffix = ORIGEXT; + #ifndef NODIR + v = getenv ("VERSION_CONTROL"); + backup_type = get_version (v); /* OK to pass NULL. */ + #endif + } get_some_switches(); *************** *** 312,317 **** --- 329,338 ---- ignore_signals(); if (!skip_rest_of_patch) { + struct stat statbuf; + char *realout = outname; + if (move_file(TMPOUTNAME, outname) < 0) { toutkeep = TRUE; + realout = TMPOUTNAME; chmod(TMPOUTNAME, filemode); } *************** *** 318,321 **** --- 339,349 ---- else 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); + while (unlink(realout) >= 0) ; /* while is for Eunice. */ + } } Fclose(rejfp); *************** *** 429,433 **** switch (*++s) { case 'b': ! origext = savestr(nextarg()); break; case 'B': --- 457,461 ---- switch (*++s) { case 'b': ! simple_backup_suffix = savestr(nextarg()); break; case 'B': *************** *** 456,459 **** --- 484,490 ---- diff_type = ED_DIFF; break; + case 'E': + remove_empty_files = TRUE; + break; case 'f': force = TRUE; *************** *** 500,503 **** --- 531,539 ---- version(); break; + case 'V': + #ifndef NODIR + backup_type = get_version (nextarg ()); + #endif + break; #ifdef DEBUGGING case 'x': *************** *** 508,515 **** 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] [origfile] [patchfile] [[+] [options] [origfile]...]\n\ ! "); my_exit(1); } --- 544,551 ---- 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\ ! [[+] [options] [origfile]...]\n"); my_exit(1); } *************** *** 761,765 **** if (R_last_frozen_line > lastline) ! say1("patch: misordered hunks! output will be garbled.\n"); while (R_last_frozen_line < lastline) { dump_line(++R_last_frozen_line); --- 797,801 ---- if (R_last_frozen_line > lastline) ! fatal1("patch: misordered hunks! output will be garbled.\n"); while (R_last_frozen_line < lastline) { dump_line(++R_last_frozen_line); diff -C2 -N patch-2.0.12u5/patch.man patch-2.0.12u6/patch.man *** patch-2.0.12u5/patch.man Sun Dec 2 23:18:13 1990 --- patch-2.0.12u6/patch.man Mon Mar 16 14:07:41 1992 *************** *** 88,97 **** By default, the patched version is put in place of the original, with the original file backed up to the same name with the ! extension \*(L".orig\*(R" or \*(L"~\*(R" , or as specified by the ! .B -b ! switch. You may also specify where you want the output to go with a .B -o ! switch. If .I patchfile --- 88,113 ---- By default, the patched version is put in place of the original, with the original file backed up to the same name with the ! extension \*(L".orig\*(R" (\*(L"~\*(R" on systems that do not ! support long filenames), or as specified by the ! .BR -b , ! .BR -B , ! or ! .B -V ! switches. ! The extension used for making backup files may also be specified in the ! .B SIMPLE_BACKUP_SUFFIX ! environment variable, which is overridden by above switches. ! .PP ! If the backup file already exists, ! .B patch ! creates a new backup file name by changing the first lowercase letter ! in the last component of the file's name into uppercase. If there are ! no more lowercase letters in the name, it removes the first character ! from the name. It repeats this process until it comes up with a ! backup file that does not already exist. ! .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. If .I patchfile *************** *** 147,151 **** cannot find a place to install that hunk of the patch, it will put the hunk out to a reject file, which normally is the name of the output file ! plus \*(L".rej\*(R" or \*(L"#\*(R" . (Note that the rejected hunk will come out in context diff form whether the input patch was a context diff or a normal diff. --- 163,168 ---- cannot find a place to install that hunk of the patch, it will put the hunk out to a reject file, which normally is the name of the output file ! plus \*(L".rej\*(R" (\*(L"#\*(R" on systems that do not support ! long filenames). (Note that the rejected hunk will come out in context diff form whether the input patch was a context diff or a normal diff. *************** *** 226,231 **** causes the next argument to be interpreted as a prefix to the backup file name. If this argument is specified any argument from -b will be ignored. - This argument is an extension to Larry Wall's patch v2.0.1.4, patchlevel 8, - made by M. Greim (greim@sbsvax.uucp). .TP 5 .B \-c --- 243,246 ---- *************** *** 254,257 **** --- 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 *************** *** 388,392 **** causes .I patch ! to print out it's revision header and patch level. .TP 5 .B \-x --- 408,443 ---- causes .I patch ! to print out its revision header and patch level. ! .TP 5 ! .B \-V ! causes the next argument to be interpreted as a method for creating ! backup file names. The type of backups made can also be given in the ! .B VERSION_CONTROL ! environment variable, which is overridden by this option. ! The ! .B -B ! option overrides this option, causing the prefix to always be used for ! making backup file names. ! The value of the ! .B VERSION_CONTROL ! environment variable and the argument to the ! .B -V ! option are like the GNU ! Emacs `version-control' variable; they also recognize synonyms that ! are more descriptive. The valid values are (unique abbreviations are ! accepted): ! .RS ! .TP ! `t' or `numbered' ! Always make numbered backups. ! .TP ! `nil' or `existing' ! Make numbered backups of files that already ! have them, simple backups of the others. ! This is the default. ! .TP ! `never' or `simple' ! Always make simple backups. ! .RE .TP 5 .B \-x *************** *** 395,404 **** patchers. .SH AUTHOR ! Larry Wall .SH ENVIRONMENT ! No environment variables are used by ! .IR patch . .SH FILES ! /tmp/patch* .SH SEE ALSO diff(1) --- 446,465 ---- patchers. .SH AUTHOR ! Larry Wall ! .br ! with many other contributors. .SH ENVIRONMENT ! .TP ! .B TMPDIR ! Directory to put temporary files in; default is /tmp. ! .TP ! .B SIMPLE_BACKUP_SUFFIX ! Extension to use for backup file names instead of \*(L".orig\*(R" or ! \*(L"~\*(R". ! .TP ! .B VERSION_CONTROL ! Selects when numbered backup files are made. .SH FILES ! $TMPDIR/patch* .SH SEE ALSO diff(1) diff -C2 -N patch-2.0.12u5/patchlevel.h patch-2.0.12u6/patchlevel.h *** patch-2.0.12u5/patchlevel.h Tue Dec 3 12:04:00 1991 --- patch-2.0.12u6/patchlevel.h Sat Mar 14 15:30:53 1992 *************** *** 1 **** ! #define PATCHLEVEL "12u5" --- 1 ---- ! #define PATCHLEVEL "12u6" diff -C2 -N patch-2.0.12u5/util.c patch-2.0.12u6/util.c *** patch-2.0.12u5/util.c Wed Aug 15 01:13:38 1990 --- patch-2.0.12u6/util.c Sat Mar 14 21:52:43 1992 *************** *** 3,6 **** --- 3,7 ---- #include "INTERN.h" #include "util.h" + #include "backupfile.h" /* Rename a file, copying it if necessary. */ *************** *** 32,42 **** } ! if (origprae) { ! Strcpy (bakname, origprae); ! Strcat(bakname, to); ! } else { ! Strcpy(bakname, to); ! Strcat(bakname, origext?origext:ORIGEXT); ! } if (stat(to, &filestat) >= 0) { /* output file exists */ dev_t to_device = filestat.st_dev; --- 33,52 ---- } ! if (origprae) { ! Strcpy(bakname, origprae); ! Strcat(bakname, to); ! } else { ! #ifndef NODIR ! char *backupname = find_backup_file_name(to); ! if (backupname == (char *) 0) ! fatal1("Can't seem to get enough memory.\n"); ! Strcpy(bakname, backupname); ! free(backupname); ! #else /* NODIR */ ! Strcpy(bakname, to); ! Strcat(bakname, simple_backup_suffix); ! #endif /* NODIR */ ! } ! if (stat(to, &filestat) >= 0) { /* output file exists */ dev_t to_device = filestat.st_dev; *************** *** 48,54 **** simplename = s+1; } ! /* find a backup name that is not the same file */ while (stat(bakname, &filestat) >= 0 && to_device == filestat.st_dev && to_inode == filestat.st_ino) { for (s=simplename; *s && !islower(*s); s++) ; if (*s) --- 58,67 ---- simplename = s+1; } ! /* Find a backup name that is not the same file. ! Change the first lowercase char into uppercase; ! if that isn't sufficient, chop off the first char and try again. */ while (stat(bakname, &filestat) >= 0 && to_device == filestat.st_dev && to_inode == filestat.st_ino) { + /* Skip initial non-lowercase chars. */ for (s=simplename; *s && !islower(*s); s++) ; if (*s) *************** *** 343,347 **** if (name != s && *s != '/') { name[-1] = '\0'; ! if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) { name[-1] = '/'; name=s; --- 356,360 ---- if (name != s && *s != '/') { name[-1] = '\0'; ! if (stat(s, &filestat) == 0 && (filestat.st_mode & S_IFDIR)) { name[-1] = '/'; name=s; diff -C2 -N patch-2.0.12u5/version.c patch-2.0.12u6/version.c *** patch-2.0.12u5/version.c Sun Dec 2 23:18:15 1990 --- patch-2.0.12u6/version.c Sat Mar 14 14:44:29 1992 *************** *** 19,22 **** --- 19,23 ---- version() { + void my_exit(); extern char rcsid[]; *************** *** 24,28 **** rcsid[0] = rcsid[0]; #else ! fatal3("%s\nPatch level: %s\n", rcsid, PATCHLEVEL); #endif } --- 25,30 ---- rcsid[0] = rcsid[0]; #else ! fprintf(stderr, "%s\nPatch level: %s\n", rcsid, PATCHLEVEL); ! my_exit(0); #endif }