Category : C Source Code
Archive   : PATCH12.ZIP
Filename : TCPATCH6.DIF

 
Output of file : TCPATCH6.DIF contained in archive : PATCH12.ZIP
TurboC2.0 Patches to fix backup name generation
Prereq: 5
*** tcpatlev.h Tue Aug 07 08:31:10 1990
--- tcpatlev.new Tue Aug 07 12:09:15 1990
***************
*** 1,1 ****
! #define TCPATCHLEVEL 5
--- 1,1 ----
! #define TCPATCHLEVEL 6
*** readme Tue Aug 07 08:31:10 1990
--- readme.new Tue Aug 07 12:13:20 1990
***************
*** 198,200 ****
--- 198,221 ----
was snarfed from an old edition of lharc and is more limited than the fancy
one I posted but it works just fine with patch (it does stdin redirection
from the invocation of the spawned COMMAND.COM - quite foolproof).
+
+
+ *** OFFICIAL PATCHLEVEL 12, TurboC2.0 PATCHLEVEL 6
+
+ From: [email protected] (Mike Ward)
+ Date: Tue, 07 Aug 90 12:13:00 EST
+
+ The problem is that to generate a backup name the program simply appends
+ the suffix (or prepends the prefix). This doesn't go over too well under
+ MSDOS.
+
+ I modified this procedure to know about file name/extension limits for the
+ append case (prepend still messed up). The code now appends only the first
+ char of the suffix (hopefully this will be the whole suffix), and if the
+ file name is still no good, it starts appending version digits/letters.
+ For example:
+
+ filexyz.sou -> filexyzs.ou~ -> ilexyzso.u~0 -> ilexyzso.u~1 ->
+ ilexyzso.u~2 -> ... -> ilexyzso.u~9 -> ilexyzso.u~A ->
+ ilexyzso.u~B -> ... -> ilexyzso.u~Z -> lexyzsou.~0A -> ...
+
*** util.c Tue Aug 07 10:46:34 1990
--- util.new Tue Aug 07 13:15:38 1990
***************
*** 15,20 ****
--- 15,117 ----
#include "INTERN.h"
#include "util.h"

+ #ifdef TURBOC20
+ #include
+ /* fnappend : Append first char of bext to a MSDOS file name.
+ * bext should not start with a letter or digit.
+ */
+
+ void
+ fnappend(fspec,bext)
+ char *fspec, *bext;
+ {
+ char *fnmex;
+ char fname[MAXFILE];
+ char fext[MAXEXT];
+ int i,j;
+ int fnlen;
+ int felen;
+
+ /* fnmex should point to first char of file name/extension
+ * (not path or drive)
+ */
+ fnmex = fspec + strlen(fspec);
+ while ((fnmex!=fspec) && (strchr("/\\:",*(fnmex-1))==NULL)) {
+ fnmex--;
+ }
+
+ /* get file name and length */
+ for (fnlen=i=0; fnmex[i] && fnmex[i]!= '.' && i + fname[i] = fnmex[i];
+ fnlen++;
+ }
+ fname[fnlen] = '\0';
+
+ /* get file ext and len */
+ while (fnmex[i] && fnmex[i]!='.') {
+ i++;
+ }
+ if (fnmex[i] == '.')
+ i++;
+ for (felen=j=0; fnmex[j+i] && j + fext[j] = fnmex[j+i];
+ felen++;
+ }
+ fext[felen] = '\0';
+
+ /* Three cases:
+ * full filename/ext: 12345678.ABC -> 2345678A.BCX
+ * full file ext: 1234567.ABC -> 1234567A.BCX
+ * other: 12345678.AB -> 12345678.ABX
+ */
+ if ((fnlen == MAXFILE-1) && (felen == MAXEXT-2)) {
+ sprintf(fnmex,"%s%c.%s%c",fname+1,fext[0],fext+1,*bext);
+ } else if (felen == MAXEXT-2) {
+ sprintf(fnmex,"%s%c.%s%c",fname,fext[0],fext+1,*bext);
+ } else {
+ sprintf(fnmex,"%s.%s%c",fname,fext,*bext);
+ }
+ }
+
+
+ /* fninc : increment/add last char of/to fspec.
+ * used with fappend (call fnappend once, then fninc many times
+ */
+
+ void
+ fninc(fspec)
+ char *fspec;
+ {
+ char *cp;
+ int lastp,lastc;
+
+ lastc = fspec[lastp = strlen(fspec)-1];
+ if (strchr("012345678ABCDEFGHIJKLMNOPQRSTUVWXY",lastc) != NULL) {
+ fspec[lastp]++;
+ } else if (lastc == '9') {
+ fspec[lastp] = 'A';
+ } else if (lastc == 'Z') {
+ for (cp=&fspec[lastp]; *cp=='Z' || *cp=='.'; cp--) {
+ if (*cp == 'Z') {
+ *cp = '0';
+ }
+ }
+ if (strchr("012345678ABCDEFGHIJKLMNOPQRSTUVWXY",*cp) != NULL) {
+ (*cp)++;
+ } else if (*cp == '9') {
+ *cp = 'A';
+ } else {
+ if (*(cp+1) == '.') cp++;
+ *(cp+1) = '1';
+ fnappend(fspec,"0");
+ }
+ } else {
+ fnappend(fspec,"0");
+ }
+ }
+ #endif
+
+
/* Rename a file, copying it if necessary. */

int
***************
*** 44,65 ****
}

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 */
- #ifdef TURBOC20
short to_device = filestat.st_dev;
short to_mode = filestat.st_mode;
long to_size = filestat.st_size;
long to_time = filestat.st_mtime;
#else
dev_t to_device = filestat.st_dev;
ino_t to_inode = filestat.st_ino;
- #endif
char *simplename = bakname;

for (s=bakname; *s; s++) {
--- 141,175 ----
}

if (origprae) {
! Strcpy (bakname, origprae);
! Strcat(bakname, to);
} else {
! Strcpy(bakname, to);
! #ifdef TURBOC20
! fnappend(bakname, origext?origext:ORIGEXT);
}
+
if (stat(to, &filestat) >= 0) { /* output file exists */
short to_device = filestat.st_dev;
short to_mode = filestat.st_mode;
long to_size = filestat.st_size;
long to_time = filestat.st_mtime;
+
+ /* find a backup name that is not the same file */
+ while (stat(bakname, &filestat) >= 0 &&
+ to_device == filestat.st_dev &&
+ to_mode == filestat.st_mode &&
+ to_size == filestat.st_size &&
+ to_time == filestat.st_mtime
+ ) {
+ fninc(bakname);
+ }
#else
+ 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;
char *simplename = bakname;

for (s=bakname; *s; s++) {
***************
*** 69,81 ****
/* find a backup name that is not the same file */
while (stat(bakname, &filestat) >= 0 &&
to_device == filestat.st_dev &&
- #ifdef TURBOC20
- to_mode == filestat.st_mode &&
- to_size == filestat.st_size &&
- to_time == filestat.st_mtime
- #else
to_inode == filestat.st_ino
- #endif
) {
for (s=simplename; *s && !islower(*s); s++) ;
if (*s)
--- 179,185 ----
***************
*** 83,88 ****
--- 187,193 ----
else
Strcpy(simplename, simplename+1);
}
+ #endif
while (unlink(bakname) >= 0) ; /* while() is for benefit of Eunice */
#ifdef DEBUGGING
if (debug & 4)


  3 Responses to “Category : C Source Code
Archive   : PATCH12.ZIP
Filename : TCPATCH6.DIF

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/