home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / FILE / PATCH12.ZIP / TCPATCH.DIF < prev    next >
Encoding:
Text File  |  1990-05-31  |  15.6 KB  |  566 lines

  1. *** ../patch/common.h    Thu May 24 14:21:46 1990
  2. --- common.h    Thu May 31 10:28:21 1990
  3. ***************
  4. *** 1,6 ****
  5. ! /* $Header: common.h,v 2.0.1.2 88/06/22 20:44:53 lwall Locked $
  6.    *
  7.    * $Log:    common.h,v $
  8.    * Revision 2.0.1.2  88/06/22  20:44:53  lwall
  9.    * patch12: sprintf was declared wrong
  10.    * 
  11. --- 1,9 ----
  12. ! /* $Header: common.h,v 2.0.1.3 90/05/30 11:30:00 mward $
  13.    *
  14.    * $Log:    common.h,v $
  15. +  * Revision 2.0.1.3  90/05/30  11:30:00  mward
  16. +  * added TURBOC stuff
  17. +  * 
  18.    * Revision 2.0.1.2  88/06/22  20:44:53  lwall
  19.    * patch12: sprintf was declared wrong
  20.    * 
  21. ***************
  22. *** 40,51 ****
  23. --- 43,68 ----
  24.   #include <ctype.h>
  25.   #include <signal.h>
  26.   
  27. + #ifdef TURBOC20
  28. + #include <stdlib.h>
  29. + #include <string.h>
  30. + #include <io.h>
  31. + #include <fcntl.h>
  32. + #endif
  33.   /* constants */
  34.   
  35.   #define TRUE (1)
  36.   #define FALSE (0)
  37.   
  38. + #ifdef TURBOC20
  39. + #define MAXPATH 80                /* max path spec size */
  40. + #define MAXMEMBLK 65534L            /* biggest block of mem */
  41. + #define MAXHUNKSIZE (MAXMEMBLK/sizeof(char *))    /* is this enough lines? */
  42. + #else
  43.   #define MAXHUNKSIZE 100000        /* is this enough lines? */
  44. + #endif
  45.   #define INITHUNKMAX 125            /* initial dynamic allocation size */
  46.   #define MAXLINELEN 1024
  47.   #define BUFFERSIZE 1024
  48. ***************
  49. *** 145,150 ****
  50. --- 162,168 ----
  51.   
  52.   EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  53.   
  54. + #ifndef TURBOC20
  55.   char *malloc();
  56.   char *realloc();
  57.   char *strcpy();
  58. ***************
  59. *** 156,159 ****
  60. --- 174,178 ----
  61.   char *sprintf();
  62.   #else
  63.   int sprintf();
  64. + #endif
  65.   #endif
  66. *** ../patch/config.h    Thu May 24 14:21:52 1990
  67. --- config.h    Thu May 31 10:36:24 1990
  68. ***************
  69. *** 1,25 ****
  70.   /* config.h
  71. !  * This file was produced by running the Configure script.
  72.    * Feel free to modify any of this as the need arises.
  73.    */
  74.   
  75.   
  76. ! #/*undef    EUNICE        /* no file linking? */
  77. ! #/*undef    VMS
  78.   
  79. ! #/*undef    index strchr    /* cultural */
  80. ! #/*undef    rindex strrchr    /*  differences? */
  81.   
  82. - #/*undef    void int    /* is void to be avoided? */
  83.   /* How many register declarations are paid attention to? */
  84.   
  85.   #define Reg1 register
  86.   #define Reg2 register
  87.   #define Reg3 register
  88. ! #define Reg4 register
  89. ! #define Reg5 register
  90. ! #define Reg6 register
  91.   #define Reg7 
  92.   #define Reg8 
  93.   #define Reg9 
  94. --- 1,36 ----
  95. + /* $Header: cofig.h,v 2.0.1 90/05/30 11:30:00 mward $
  96. +  *
  97. +  * $Log:    config.h,v $
  98. +  * Revision 2.0.1  90/05/30  11:30:00  mward
  99. +  * set up for MSDOS TURBOC v2.0
  100. +  */
  101. +  
  102.   /* config.h
  103. !  * This file was produced by hand for MSDOS TURBOC V2.0.
  104.    * Feel free to modify any of this as the need arises.
  105.    */
  106.   
  107.   
  108. ! #undef    EUNICE        /* no file linking? */
  109. ! #undef    VMS
  110. ! #undef    CHARSPRINTF     /* sprintf does NOT return pointer to char */
  111. ! #undef    FLEXFILENAMES    /* file names must be 14 chars or less */
  112.   
  113. ! #ifdef TURBOC20
  114. ! #define    index strchr    /* cultural */
  115. ! #define    rindex strrchr    /*  differences? */
  116. ! #define    VOIDSIG     /* signal returns ptr to function returning void*/
  117. ! #define    VOIDFLAGS 7    /* full void support */
  118. ! #endif
  119.   
  120.   /* How many register declarations are paid attention to? */
  121.   
  122.   #define Reg1 register
  123.   #define Reg2 register
  124.   #define Reg3 register
  125. ! #define Reg4
  126. ! #define Reg5
  127. ! #define Reg6
  128.   #define Reg7 
  129.   #define Reg8 
  130.   #define Reg9 
  131. *** ../patch/inp.c    Thu May 24 14:21:46 1990
  132. --- inp.c    Thu May 31 10:37:49 1990
  133. ***************
  134. *** 1,6 ****
  135. ! /* $Header: inp.c,v 2.0.1.1 88/06/03 15:06:13 lwall Locked $
  136.    *
  137.    * $Log:    inp.c,v $
  138.    * Revision 2.0.1.1  88/06/03  15:06:13  lwall
  139.    * patch10: made a little smarter about sccs files
  140.    * 
  141. --- 1,12 ----
  142. ! /* $Header: inp.c,v 2.0.1.2 90/05/30 11:30:00 mward $
  143.    *
  144.    * $Log:    inp.c,v $
  145. +  * Revision 2.0.1.2  90/05/30  11:30:00 mward
  146. +  * if TURBOC20 have plan_a check against MAXMEMBLK before mallocs
  147. +  * if TURBOC20 have plan_b use binary mode io for tmp file
  148. +  * modified plan_a to allow for translation shrinkage on text reads
  149. +  * modify calls to read, write to detect error on return value of -1
  150. +  * 
  151.    * Revision 2.0.1.1  88/06/03  15:06:13  lwall
  152.    * patch10: made a little smarter about sccs files
  153.    * 
  154. ***************
  155. *** 120,128 ****
  156.       out_of_mem = FALSE;
  157.       return FALSE;            /* force plan b because plan a bombed */
  158.       }
  159. - #ifdef lint
  160.       i_womp = Nullch;
  161. ! #else
  162.       i_womp = malloc((MEM)(i_size+2));    /* lint says this may alloc less than */
  163.                       /* i_size, but that's okay, I think. */
  164.   #endif
  165. --- 126,136 ----
  166.       out_of_mem = FALSE;
  167.       return FALSE;            /* force plan b because plan a bombed */
  168.       }
  169.       i_womp = Nullch;
  170. ! #ifndef lint
  171. ! #ifdef TURBOC20
  172. !     if (i_size < MAXMEMBLK)
  173. ! #endif
  174.       i_womp = malloc((MEM)(i_size+2));    /* lint says this may alloc less than */
  175.                       /* i_size, but that's okay, I think. */
  176.   #endif
  177. ***************
  178. *** 131,137 ****
  179.       if ((ifd = open(filename, 0)) < 0)
  180.       fatal2("Can't open file %s\n", filename);
  181.   #ifndef lint
  182. !     if (read(ifd, i_womp, (int)i_size) != i_size) {
  183.       Close(ifd);    /* probably means i_size > 15 or 16 bits worth */
  184.       free(i_womp);    /* at this point it doesn't matter if i_womp was */
  185.       return FALSE;    /*   undersized. */
  186. --- 139,145 ----
  187.       if ((ifd = open(filename, 0)) < 0)
  188.       fatal2("Can't open file %s\n", filename);
  189.   #ifndef lint
  190. !     if ((i_size=(unsigned)read(ifd, i_womp, (int)i_size)) == (unsigned)-1) {
  191.       Close(ifd);    /* probably means i_size > 15 or 16 bits worth */
  192.       free(i_womp);    /* at this point it doesn't matter if i_womp was */
  193.       return FALSE;    /*   undersized. */
  194. ***************
  195. *** 149,157 ****
  196.       if (*s == '\n')
  197.           iline++;
  198.       }
  199. - #ifdef lint
  200.       i_ptr = Null(char**);
  201. ! #else
  202.       i_ptr = (char **)malloc((MEM)((iline + 2) * sizeof(char *)));
  203.   #endif
  204.       if (i_ptr == Null(char **)) {    /* shucks, it was a near thing */
  205. --- 157,167 ----
  206.       if (*s == '\n')
  207.           iline++;
  208.       }
  209.       i_ptr = Null(char**);
  210. ! #ifndef lint
  211. ! #ifdef TURBOC20
  212. !     if (iline+2<MAXMEMBLK/sizeof(char *))
  213. ! #endif
  214.       i_ptr = (char **)malloc((MEM)((iline + 2) * sizeof(char *)));
  215.   #endif
  216.       if (i_ptr == Null(char **)) {    /* shucks, it was a near thing */
  217. ***************
  218. *** 210,215 ****
  219. --- 220,228 ----
  220.       fatal2("Can't open file %s\n", filename);
  221.       if ((tifd = creat(TMPINNAME, 0666)) < 0)
  222.       fatal2("Can't open file %s\n", TMPINNAME);
  223. + #ifdef TURBOC20
  224. +     setmode(tifd, O_BINARY);
  225. + #endif
  226.       while (fgets(buf, sizeof buf, ifp) != Nullch) {
  227.       if (revision != Nullch && !found_revision && rev_in_string(buf))
  228.           found_revision = TRUE;
  229. ***************
  230. *** 245,257 ****
  231.       fatal1("Can't seem to get enough memory.\n");
  232.       for (i=1; ; i++) {
  233.       if (! (i % lines_per_buf))    /* new block */
  234. !         if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
  235.           fatal1("patch: can't write temp file.\n");
  236.       if (fgets(tibuf[0] + maxlen * (i%lines_per_buf), maxlen + 1, ifp)
  237.         == Nullch) {
  238.           input_lines = i - 1;
  239.           if (i % lines_per_buf)
  240. !         if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
  241.               fatal1("patch: can't write temp file.\n");
  242.           break;
  243.       }
  244. --- 258,270 ----
  245.       fatal1("Can't seem to get enough memory.\n");
  246.       for (i=1; ; i++) {
  247.       if (! (i % lines_per_buf))    /* new block */
  248. !         if (write(tifd, tibuf[0], BUFFERSIZE) == -1)
  249.           fatal1("patch: can't write temp file.\n");
  250.       if (fgets(tibuf[0] + maxlen * (i%lines_per_buf), maxlen + 1, ifp)
  251.         == Nullch) {
  252.           input_lines = i - 1;
  253.           if (i % lines_per_buf)
  254. !         if (write(tifd, tibuf[0], BUFFERSIZE) == -1)
  255.               fatal1("patch: can't write temp file.\n");
  256.           break;
  257.       }
  258. ***************
  259. *** 258,264 ****
  260. --- 271,281 ----
  261.       }
  262.       Fclose(ifp);
  263.       Close(tifd);
  264. + #ifdef TURBOC20
  265. +     if ((tifd = open(TMPINNAME, O_BINARY)) < 0) {
  266. + #else
  267.       if ((tifd = open(TMPINNAME, 0)) < 0) {
  268. + #endif
  269.       fatal2("Can't reopen file %s\n", TMPINNAME);
  270.       }
  271.   }
  272. ***************
  273. *** 287,293 ****
  274.   #ifndef lint        /* complains of long accuracy */
  275.           Lseek(tifd, (long)baseline / lines_per_buf * BUFFERSIZE, 0);
  276.   #endif
  277. !         if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0)
  278.           fatal2("Error reading tmp file %s.\n", TMPINNAME);
  279.       }
  280.       return tibuf[whichbuf] + (tireclen*offline);
  281. --- 304,310 ----
  282.   #ifndef lint        /* complains of long accuracy */
  283.           Lseek(tifd, (long)baseline / lines_per_buf * BUFFERSIZE, 0);
  284.   #endif
  285. !         if (read(tifd, tibuf[whichbuf], BUFFERSIZE) == -1)
  286.           fatal2("Error reading tmp file %s.\n", TMPINNAME);
  287.       }
  288.       return tibuf[whichbuf] + (tireclen*offline);
  289. *** ../patch/pch.c    Thu May 24 14:21:38 1990
  290. --- pch.c    Thu May 31 10:40:00 1990
  291. ***************
  292. *** 1,6 ****
  293. ! /* $Header: pch.c,v 2.0.1.7 88/06/03 15:13:28 lwall Locked $
  294.    *
  295.    * $Log:    pch.c,v $
  296.    * Revision 2.0.1.7  88/06/03  15:13:28  lwall
  297.    * patch10: Can now find patches in shar scripts.
  298.    * patch10: Hunks that swapped and then swapped back could core dump.
  299. --- 1,10 ----
  300. ! /* $Header: pch.c,v 2.0.1.7 90/05/30 11:30:00 mward $
  301.    *
  302.    * $Log:    pch.c,v $
  303. +  * Revision 2.0.1.8  90/05/30  11:30:00  mward
  304. +  * replace do_ed_script with stub
  305. +  * modify calls to read, write to detect error on return value of -1
  306. +  * 
  307.    * Revision 2.0.1.7  88/06/03  15:13:28  lwall
  308.    * patch10: Can now find patches in shar scripts.
  309.    * patch10: Hunks that swapped and then swapped back could core dump.
  310. ***************
  311. *** 1058,1063 ****
  312. --- 1062,1077 ----
  313.       return p_hunk_beg;
  314.   }
  315.  
  316. + #ifdef TURBOC20 
  317. + /* Ignore an ed script. */
  318. + void
  319. + do_ed_script()
  320. + {
  321. +     say1("Sorry, can't do ed scripts yet!\n");
  322. +     say1("Use ed to do this one yourself!\n");
  323. + }
  324. + #else
  325.   /* Apply an ed script by feeding ed itself. */
  326.   
  327.   void
  328. ***************
  329. *** 1121,1123 ****
  330. --- 1134,1137 ----
  331.       chmod(outname, filemode);
  332.       set_signals(1);
  333.   }
  334. + #endif
  335. *** ../patch/util.c    Thu May 24 14:21:46 1990
  336. --- util.c    Thu May 31 10:40:14 1990
  337. ***************
  338. *** 1,3 ****
  339. --- 1,15 ----
  340. + /* $Header: pch.c,v 2.0.1 90/05/30 11:30:00 mward $
  341. +  *
  342. +  * $Log:    pch.c,v $
  343. +  * Revision 2.0.1  90/05/30  11:30:00  mward
  344. +  * modify calls to read, write to detect error on return of value -1
  345. +  * added TURBOC20 ifdef stuff:
  346. +  *    no inodes: modify move_file same file detect accordingly
  347. +  *    no links:  modify move_file link calls to copy_file calls
  348. +  *    no SIGHUP: modify signal routines accordingly
  349. +  *
  350. +  */
  351.   #include "EXTERN.h"
  352.   #include "common.h"
  353.   #include "INTERN.h"
  354. ***************
  355. *** 24,31 ****
  356.       fromfd = open(from, 0);
  357.       if (fromfd < 0)
  358.           fatal2("patch: internal error, can't reopen %s\n", from);
  359. !     while ((i=read(fromfd, buf, sizeof buf)) > 0)
  360. !         if (write(1, buf, i) != 1)
  361.           fatal1("patch: write failed\n");
  362.       Close(fromfd);
  363.       return 0;
  364. --- 36,43 ----
  365.       fromfd = open(from, 0);
  366.       if (fromfd < 0)
  367.           fatal2("patch: internal error, can't reopen %s\n", from);
  368. !     while ((i=read(fromfd, buf, sizeof buf))!=-1 && i!=0)
  369. !         if (write(1, buf, i) == -1)
  370.           fatal1("patch: write failed\n");
  371.       Close(fromfd);
  372.       return 0;
  373. ***************
  374. *** 39,46 ****
  375.           Strcat(bakname, origext?origext:ORIGEXT);
  376.       }
  377.       if (stat(to, &filestat) >= 0) {    /* output file exists */
  378. !     dev_t to_device = filestat.st_dev;
  379. !     ino_t to_inode  = filestat.st_ino;
  380.       char *simplename = bakname;
  381.       
  382.       for (s=bakname; *s; s++) {
  383. --- 51,65 ----
  384.           Strcat(bakname, origext?origext:ORIGEXT);
  385.       }
  386.       if (stat(to, &filestat) >= 0) {    /* output file exists */
  387. ! #ifdef TURBOC20
  388. !     short to_device = filestat.st_dev;
  389. !     short to_mode = filestat.st_mode;
  390. !     long  to_size  = filestat.st_size;
  391. !     long  to_time  = filestat.st_mtime;
  392. ! #else
  393. !      dev_t to_device = filestat.st_dev;
  394. !      ino_t to_inode  = filestat.st_ino;
  395. ! #endif
  396.       char *simplename = bakname;
  397.       
  398.       for (s=bakname; *s; s++) {
  399. ***************
  400. *** 49,55 ****
  401.       }
  402.       /* find a backup name that is not the same file */
  403.       while (stat(bakname, &filestat) >= 0 &&
  404. !         to_device == filestat.st_dev && to_inode == filestat.st_ino) {
  405.           for (s=simplename; *s && !islower(*s); s++) ;
  406.           if (*s)
  407.           *s = toupper(*s);
  408. --- 68,82 ----
  409.       }
  410.       /* find a backup name that is not the same file */
  411.       while (stat(bakname, &filestat) >= 0 &&
  412. !         to_device == filestat.st_dev &&
  413. ! #ifdef TURBOC20
  414. !         to_mode == filestat.st_mode &&
  415. !                 to_size == filestat.st_size &&
  416. !                 to_time == filestat.st_mtime
  417. ! #else
  418. !                 to_inode == filestat.st_ino
  419. ! #endif                
  420. !               ) {
  421.           for (s=simplename; *s && !islower(*s); s++) ;
  422.           if (*s)
  423.           *s = toupper(*s);
  424. ***************
  425. *** 61,71 ****
  426. --- 88,102 ----
  427.       if (debug & 4)
  428.           say3("Moving %s to %s.\n", to, bakname);
  429.   #endif
  430. + #ifdef TURBOC20
  431. +     copy_file(to, bakname);
  432. + #else        
  433.       if (link(to, bakname) < 0) {
  434.           say3("patch: can't backup %s, output is in %s\n",
  435.           to, from);
  436.           return -1;
  437.       }
  438. + #endif
  439.       while (unlink(to) >= 0) ;
  440.       }
  441.   #ifdef DEBUGGING
  442. ***************
  443. *** 72,77 ****
  444. --- 103,111 ----
  445.       if (debug & 4)
  446.       say3("Moving %s to %s.\n", from, to);
  447.   #endif
  448. + #ifdef TURBOC20
  449. +     copy_file(from, to);
  450. + #else
  451.       if (link(from, to) < 0) {        /* different file system? */
  452.       Reg4 int tofd;
  453.       
  454. ***************
  455. *** 84,95 ****
  456.       fromfd = open(from, 0);
  457.       if (fromfd < 0)
  458.           fatal2("patch: internal error, can't reopen %s\n", from);
  459. !     while ((i=read(fromfd, buf, sizeof buf)) > 0)
  460. !         if (write(tofd, buf, i) != i)
  461.           fatal1("patch: write failed\n");
  462.       Close(fromfd);
  463.       Close(tofd);
  464.       }
  465.       Unlink(from);
  466.       return 0;
  467.   }
  468. --- 118,130 ----
  469.       fromfd = open(from, 0);
  470.       if (fromfd < 0)
  471.           fatal2("patch: internal error, can't reopen %s\n", from);
  472. !     while ((i=read(fromfd, buf, sizeof buf))!=-1 && i!=0)
  473. !         if (write(tofd, buf, i) == -1)
  474.           fatal1("patch: write failed\n");
  475.       Close(fromfd);
  476.       Close(tofd);
  477.       }
  478. + #endif
  479.       Unlink(from);
  480.       return 0;
  481.   }
  482. ***************
  483. *** 110,117 ****
  484.       fromfd = open(from, 0);
  485.       if (fromfd < 0)
  486.       fatal2("patch: internal error, can't reopen %s\n", from);
  487. !     while ((i=read(fromfd, buf, sizeof buf)) > 0)
  488. !     if (write(tofd, buf, i) != i)
  489.           fatal2("patch: write (%s) failed\n", to);
  490.       Close(fromfd);
  491.       Close(tofd);
  492. --- 145,152 ----
  493.       fromfd = open(from, 0);
  494.       if (fromfd < 0)
  495.       fatal2("patch: internal error, can't reopen %s\n", from);
  496. !     while ((i=read(fromfd, buf, sizeof buf))!=-1 && i!=0)
  497. !     if (write(tofd, buf, i) == -1)
  498.           fatal2("patch: write (%s) failed\n", to);
  499.       Close(fromfd);
  500.       Close(tofd);
  501. ***************
  502. *** 233,245 ****
  503. --- 268,289 ----
  504.   {
  505.       void my_exit();
  506.   #ifndef lint
  507. + #ifdef TURBOC20
  508.   #ifdef VOIDSIG
  509. +     static void (*intval)();
  510. + #else
  511. +     static int (*intval)();
  512. + #endif
  513. + #else
  514. + #ifdef VOIDSIG
  515.       static void (*hupval)(),(*intval)();
  516.   #else
  517.       static int (*hupval)(),(*intval)();
  518.   #endif
  519. + #endif
  520.   
  521.       if (!reset) {
  522. + #ifndef TURBOC20
  523.       hupval = signal(SIGHUP, SIG_IGN);
  524.       if (hupval != SIG_IGN)
  525.   #ifdef VOIDSIG
  526. ***************
  527. *** 247,252 ****
  528. --- 291,298 ----
  529.   #else
  530.           hupval = (int(*)())my_exit;
  531.   #endif
  532. + #endif
  533.       intval = signal(SIGINT, SIG_IGN);
  534.       if (intval != SIG_IGN)
  535.   #ifdef VOIDSIG
  536. ***************
  537. *** 255,261 ****
  538. --- 301,309 ----
  539.           intval = (int(*)())my_exit;
  540.   #endif
  541.       }
  542. + #ifndef TURBOC20
  543.       Signal(SIGHUP, hupval);
  544. + #endif
  545.       Signal(SIGINT, intval);
  546.   #endif
  547.   }
  548. ***************
  549. *** 266,272 ****
  550. --- 314,322 ----
  551.   ignore_signals()
  552.   {
  553.   #ifndef lint
  554. + #ifndef TURBOC20
  555.       Signal(SIGHUP, SIG_IGN);
  556. + #endif
  557.       Signal(SIGINT, SIG_IGN);
  558.   #endif
  559.   }
  560.