greim@sbsvax.UUCP (Michael Greim) (06/22/88)
Hello,
I have made a change to my copy of PATCH recently. I am posting
it as it might be interesting to other people as well.
This is *not* a bug fix, but rather an enhancement.
Reason:
I am running PATCH on a SYS3 based machine. The filesystem
allows filenames up to 14 characters long.
When I apply patches, the old file will be moved to fileExt, where
Ext is either '.orig' or a user supplied extension. If file had
a long name some file might get overwritten. PATCH uses a clever
routine to produce unique orig-file-names, but it can be confusing to
figure out later, which is the orig-file of which file.
I added an option '-B prefix' with which the user can specify
a prefix to be added to the orig-file. A sideeffect is that
you can specify '-B bak01/' and the orig-file will be put in
the (existing) directory bak01.
Context Diff:
apply the following context diff to patch 2.0.1.4, patchlevel 8
*** common.h.old Tue May 31 13:19:52 1988
--- common.h Tue May 31 13:18:06 1988
***************
*** 95,100 ****
--- 95,101 ----
EXT char rejname[128];
EXT char *origext INIT(Nullch);
+ EXT char *origprae INIT(Nullch);
EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */
*** patch.c.old Tue May 31 13:20:15 1988
--- patch.c Tue May 31 13:18:09 1988
***************
*** 366,371 ****
--- 366,375 ----
origext = savestr(Argv[1]);
Argc--,Argv++;
break;
+ case 'B':
+ origprae = savestr(Argv[1]);
+ Argc--,Argv++;
+ break;
case 'c':
diff_type = CONTEXT_DIFF;
break;
*** patch.man.old Tue May 31 13:23:24 1988
--- patch.man Mon May 2 11:57:13 1988
***************
*** 213,218 ****
--- 213,224 ----
causes the next argument to be interpreted as the backup extension, to be
used in place of \*(L".orig\*(R".
.TP 5
+ .B \-B
+ 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
forces
.I patch
*** util.c.old Tue May 31 13:20:31 1988
--- util.c Tue May 31 13:18:11 1988
***************
*** 31,38 ****
return 0;
}
! Strcpy(bakname, to);
! Strcat(bakname, origext?origext:ORIGEXT);
if (stat(to, &filestat) >= 0) { /* output file exists */
dev_t to_device = filestat.st_dev;
ino_t to_inode = filestat.st_ino;
--- 31,43 ----
return 0;
}
! 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;
ino_t to_inode = filestat.st_ino;
Absorb, apply and enjoy,
Michael
--
+------------------------------------------------------------------------------+
| UUCP: ...!uunet!unido!sbsvax!greim | Michael T. Greim |
| or greim@sbsvax.UUCP | Universitaet des Saarlandes |
| CSNET: greim%sbsvax.uucp@Germany.CSnet| FB 10 - Informatik (Dept. of CS) |
| ARPA: greim%sbsvax.uucp@uunet.UU.NET | Bau 36, Im Stadtwald 15 |
| Phone: +49 681 302 2434 | D-6600 Saarbruecken 11, West Germany |
+------------------------------------------------------------------------------+
| # include <disclaimers/std.h> |
+------------------------------------------------------------------------------+