home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / bugs / 241 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  24.2 KB

  1. Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life!djm
  2. From: djm@gnu.ai.mit.edu (David J. MacKenzie)
  3. Newsgroups: comp.sources.bugs
  4. Subject: REPOST: patch 12u8 to patch, part 02 of 02
  5. Message-ID: <DJM.92Sep15160742@nutrimat.gnu.ai.mit.edu>
  6. Date: 15 Sep 92 20:07:42 GMT
  7. Sender: news@ai.mit.edu
  8. Organization: Free Software Foundation
  9. Lines: 899
  10.  
  11. diff -C2 -N patch-2.0.12u7/patch.man patch-2.0.12u8/patch.man
  12. *** patch-2.0.12u7/patch.man    Sat Jul  4 04:47:57 1992
  13. --- patch-2.0.12u8/patch.man    Tue Aug 25 22:32:41 1992
  14. ***************
  15. *** 1,38 ****
  16.   .\" -*- nroff -*-
  17.   .rn '' }`
  18. ! ''' $Header: patch.man,v 2.0.1.2 88/06/22 20:47:18 lwall Locked $
  19. ! ''' 
  20. ! ''' $Log:    patch.man,v $
  21. ! ''' Revision 2.0.1.2  88/06/22  20:47:18  lwall
  22. ! ''' patch12: now avoids Bell System Logo
  23. ! ''' 
  24. ! ''' Revision 2.0.1.1  88/06/03  15:12:51  lwall
  25. ! ''' patch10: -B switch was contributed.
  26. ! ''' 
  27. ! ''' Revision 2.0  86/09/17  15:39:09  lwall
  28. ! ''' Baseline for netwide release.
  29. ! ''' 
  30. ! ''' Revision 1.4  86/08/01  19:23:22  lwall
  31. ! ''' Documented -v, -p, -F.
  32. ! ''' Added notes to patch senders.
  33. ! ''' 
  34. ! ''' Revision 1.3  85/03/26  15:11:06  lwall
  35. ! ''' Frozen.
  36. ! ''' 
  37. ! ''' Revision 1.2.1.4  85/03/12  16:14:27  lwall
  38. ! ''' Documented -p.
  39. ! ''' 
  40. ! ''' Revision 1.2.1.3  85/03/12  16:09:41  lwall
  41. ! ''' Documented -D.
  42. ! ''' 
  43. ! ''' Revision 1.2.1.2  84/12/05  11:06:55  lwall
  44. ! ''' Added -l switch, and noted bistability bug.
  45. ! ''' 
  46. ! ''' Revision 1.2.1.1  84/12/04  17:23:39  lwall
  47. ! ''' Branch for sdcrdcf changes.
  48. ! ''' 
  49. ! ''' Revision 1.2  84/12/04  17:22:02  lwall
  50. ! ''' Baseline version.
  51. ! ''' 
  52.   .de Sh
  53.   .br
  54. --- 1,38 ----
  55.   .\" -*- nroff -*-
  56.   .rn '' }`
  57. ! '\" $Header: patch.man,v 2.0.1.2 88/06/22 20:47:18 lwall Locked $
  58. ! '\" 
  59. ! '\" $Log:    patch.man,v $
  60. ! '\" Revision 2.0.1.2  88/06/22  20:47:18  lwall
  61. ! '\" patch12: now avoids Bell System Logo
  62. ! '\" 
  63. ! '\" Revision 2.0.1.1  88/06/03  15:12:51  lwall
  64. ! '\" patch10: -B switch was contributed.
  65. ! '\" 
  66. ! '\" Revision 2.0  86/09/17  15:39:09  lwall
  67. ! '\" Baseline for netwide release.
  68. ! '\" 
  69. ! '\" Revision 1.4  86/08/01  19:23:22  lwall
  70. ! '\" Documented -v, -p, -F.
  71. ! '\" Added notes to patch senders.
  72. ! '\" 
  73. ! '\" Revision 1.3  85/03/26  15:11:06  lwall
  74. ! '\" Frozen.
  75. ! '\" 
  76. ! '\" Revision 1.2.1.4  85/03/12  16:14:27  lwall
  77. ! '\" Documented -p.
  78. ! '\" 
  79. ! '\" Revision 1.2.1.3  85/03/12  16:09:41  lwall
  80. ! '\" Documented -D.
  81. ! '\" 
  82. ! '\" Revision 1.2.1.2  84/12/05  11:06:55  lwall
  83. ! '\" Added -l switch, and noted bistability bug.
  84. ! '\" 
  85. ! '\" Revision 1.2.1.1  84/12/04  17:23:39  lwall
  86. ! '\" Branch for sdcrdcf changes.
  87. ! '\" 
  88. ! '\" Revision 1.2  84/12/04  17:22:02  lwall
  89. ! '\" Baseline version.
  90. ! '\" 
  91.   .de Sh
  92.   .br
  93. ***************
  94. *** 46,54 ****
  95.   .if n .sp
  96.   ..
  97. ! '''
  98. ! '''     Set up \*(-- to give an unbreakable dash;
  99. ! '''     string Tr holds user defined translation string.
  100. ! '''     Bell System Logo is used as a dummy character.
  101. ! '''
  102.   .ie n \{\
  103.   .tr \(*W-\*(Tr
  104. --- 46,56 ----
  105.   .if n .sp
  106.   ..
  107. ! '\"
  108. ! '\"     Set up \*(-- to give an unbreakable dash;
  109. ! '\"     string Tr holds user defined translation string.
  110. ! '\"     Bell System Logo is used as a dummy character.
  111. ! '\"
  112. ! '\" Shut up a groff -ww warning.
  113. ! .if \n(.g .if !dTr .ds Tr
  114.   .ie n \{\
  115.   .tr \(*W-\*(Tr
  116. ***************
  117. *** 71,78 ****
  118.   .TH PATCH 1 LOCAL
  119.   .SH NAME
  120. ! patch - a program for applying a diff file to an original
  121.   .SH SYNOPSIS
  122.   .B patch
  123. ! [options] orig patchfile [+ [options] orig]
  124.   .sp
  125.   but usually just
  126. --- 73,80 ----
  127.   .TH PATCH 1 LOCAL
  128.   .SH NAME
  129. ! patch - apply a diff file to an original
  130.   .SH SYNOPSIS
  131.   .B patch
  132. ! [options] [origfile [patchfile]] [+ [options] [origfile]]...
  133.   .sp
  134.   but usually just
  135. ***************
  136. *** 108,114 ****
  137.   backup file that does not already exist.
  138.   .PP
  139. - .I patch
  140. - removes output files that are empty after being patched.
  141. - .PP
  142.   You may also specify where you want the output to go with a
  143.   .B -o
  144. --- 110,113 ----
  145. ***************
  146. *** 274,277 ****
  147. --- 273,281 ----
  148.   to interpret the patch file as an ed script.
  149.   .TP 5
  150. + .B \-E
  151. + causes
  152. + .I patch
  153. + to remove output files that are empty after the patches have been applied.
  154. + .TP 5
  155.   .B \-f
  156.   forces
  157. ***************
  158. *** 278,286 ****
  159.   .I patch
  160.   to assume that the user knows exactly what he or she is doing, and to not
  161. ! ask any questions.
  162. ! It does not suppress commentary, however.
  163. ! Use
  164.   .B \-s
  165.   for that.
  166.   .TP 5
  167.   .B \-F<number>
  168. --- 282,301 ----
  169.   .I patch
  170.   to assume that the user knows exactly what he or she is doing, and to not
  171. ! ask any questions.  It assumes the following: skip patches for which a
  172. ! file to patch can't be found; patch files even though they have the
  173. ! wrong version for the ``Prereq:'' line in the patch; and assume that
  174. ! patches are not reversed even if they look like they are.
  175. ! This option does not suppress commentary; use
  176.   .B \-s
  177.   for that.
  178. + .TP 5
  179. + .B \-t
  180. + similar to
  181. + .BR \-f ,
  182. + in that it suppresses questions, but makes some different assumptions:
  183. + skip patches for which a file to patch can't be found (the same as \fB\-f\fP);
  184. + skip patches for which the file has the wrong version for the ``Prereq:'' line
  185. + in the patch; and assume that patches are reversed if they look like
  186. + they are.
  187.   .TP 5
  188.   .B \-F<number>
  189. diff -C2 -N patch-2.0.12u7/pch.c patch-2.0.12u8/pch.c
  190. *** patch-2.0.12u7/pch.c    Tue Dec  3 11:27:06 1991
  191. --- patch-2.0.12u8/pch.c    Tue Aug 25 22:28:23 1992
  192. ***************
  193. *** 86,90 ****
  194.       pfp = fopen(TMPPATNAME, "w");
  195.       if (pfp == Nullfp)
  196. !         fatal2("patch: can't create %s.\n", TMPPATNAME);
  197.       while (fgets(buf, sizeof buf, stdin) != Nullch)
  198.           fputs(buf, pfp);
  199. --- 86,90 ----
  200.       pfp = fopen(TMPPATNAME, "w");
  201.       if (pfp == Nullfp)
  202. !         pfatal2("can't create %s", TMPPATNAME);
  203.       while (fgets(buf, sizeof buf, stdin) != Nullch)
  204.           fputs(buf, pfp);
  205. ***************
  206. *** 94,98 ****
  207.       pfp = fopen(filename, "r");
  208.       if (pfp == Nullfp)
  209. !     fatal2("patch file %s not found\n", filename);
  210.       Fstat(fileno(pfp), &filestat);
  211.       p_filesize = filestat.st_size;
  212. --- 94,98 ----
  213.       pfp = fopen(filename, "r");
  214.       if (pfp == Nullfp)
  215. !     pfatal2("patch file %s not found", filename);
  216.       Fstat(fileno(pfp), &filestat);
  217.       p_filesize = filestat.st_size;
  218. ***************
  219. *** 136,140 ****
  220.       return;
  221.       if (!using_plan_a)
  222. !     fatal1("patch: out of memory (grow_hunkmax)\n");
  223.       out_of_mem = TRUE;        /* whatever is null will be allocated again */
  224.                   /* from within plan_a(), of all places */
  225. --- 136,140 ----
  226.       return;
  227.       if (!using_plan_a)
  228. !     fatal1("out of memory\n");
  229.       out_of_mem = TRUE;        /* whatever is null will be allocated again */
  230.                   /* from within plan_a(), of all places */
  231. ***************
  232. *** 175,179 ****
  233.       skip_to(p_start,p_sline);
  234.       while (filearg[0] == Nullch) {
  235. !     if (force) {
  236.           say1("No file to patch.  Skipping...\n");
  237.           filearg[0] = savestr(bestguess);
  238. --- 175,179 ----
  239.       skip_to(p_start,p_sline);
  240.       while (filearg[0] == Nullch) {
  241. !     if (force || batch) {
  242.           say1("No file to patch.  Skipping...\n");
  243.           filearg[0] = savestr(bestguess);
  244. ***************
  245. *** 427,431 ****
  246.   malformed ()
  247.   {
  248. !     fatal3("Malformed patch at line %ld: %s", p_input_line, buf);
  249.           /* about as informative as "Syntax error" in C */
  250.   }
  251. --- 427,431 ----
  252.   malformed ()
  253.   {
  254. !     fatal3("malformed patch at line %ld: %s", p_input_line, buf);
  255.           /* about as informative as "Syntax error" in C */
  256.   }
  257. ***************
  258. *** 488,492 ****
  259.               goto hunk_done;
  260.               }
  261. !             fatal1("Unexpected end of file in patch.\n");
  262.           }
  263.           }
  264. --- 488,492 ----
  265.               goto hunk_done;
  266.               }
  267. !             fatal1("unexpected end of file in patch\n");
  268.           }
  269.           }
  270. ***************
  271. *** 507,511 ****
  272.               }
  273.               else
  274. !             fatal2("Unexpected end of hunk at line %ld.\n",
  275.                   p_input_line);
  276.           }
  277. --- 507,511 ----
  278.               }
  279.               else
  280. !             fatal2("unexpected end of hunk at line %ld\n",
  281.                   p_input_line);
  282.           }
  283. ***************
  284. *** 515,519 ****
  285.               goto hunk_done;
  286.               }
  287. !             fatal3("Unexpected *** at line %ld: %s", p_input_line, buf);
  288.           }
  289.           context = 0;
  290. --- 515,519 ----
  291.               goto hunk_done;
  292.               }
  293. !             fatal3("unexpected *** at line %ld: %s", p_input_line, buf);
  294.           }
  295.           context = 0;
  296. ***************
  297. *** 567,571 ****
  298.                   }
  299.                   fatal3(
  300. ! "Duplicate \"---\" at line %ld--check line numbers at line %ld.\n",
  301.                       p_input_line, p_hunk_beg + repl_beginning);
  302.                   }
  303. --- 567,571 ----
  304.                   }
  305.                   fatal3(
  306. ! "duplicate \"---\" at line %ld--check line numbers at line %ld\n",
  307.                       p_input_line, p_hunk_beg + repl_beginning);
  308.                   }
  309. ***************
  310. *** 572,576 ****
  311.                   else {
  312.                   fatal4(
  313. ! "%s \"---\" at line %ld--check line numbers at line %ld.\n",
  314.                       (p_end <= p_ptrn_lines
  315.                       ? "Premature"
  316. --- 572,576 ----
  317.                   else {
  318.                   fatal4(
  319. ! "%s \"---\" at line %ld--check line numbers at line %ld\n",
  320.                       (p_end <= p_ptrn_lines
  321.                       ? "Premature"
  322. ***************
  323. *** 608,612 ****
  324.               p_max = p_repl_lines + p_end;
  325.               if (p_max > MAXHUNKSIZE)
  326. !             fatal4("Hunk too large (%ld lines) at line %ld: %s",
  327.                     p_max, p_input_line, buf);
  328.               while (p_max >= hunkmax)
  329. --- 608,612 ----
  330.               p_max = p_repl_lines + p_end;
  331.               if (p_max > MAXHUNKSIZE)
  332. !             fatal4("hunk too large (%ld lines) at line %ld: %s",
  333.                     p_max, p_input_line, buf);
  334.               while (p_max >= hunkmax)
  335. ***************
  336. *** 690,694 ****
  337.       hunk_done:
  338.       if (p_end >=0 && !repl_beginning)
  339. !         fatal2("No --- found in patch at line %ld\n", pch_hunk_beg());
  340.   
  341.       if (repl_missing) {
  342. --- 690,694 ----
  343.       hunk_done:
  344.       if (p_end >=0 && !repl_beginning)
  345. !         fatal2("no --- found in patch at line %ld\n", pch_hunk_beg());
  346.   
  347.       if (repl_missing) {
  348. ***************
  349. *** 720,724 ****
  350.           filldst++;
  351.           }
  352. ! /*        repl_beginning--;        /* this doesn't need to be fixed */
  353.           p_end--;
  354.           p_first++;            /* do append rather than insert */
  355. --- 720,726 ----
  356.           filldst++;
  357.           }
  358. ! #if 0
  359. !         repl_beginning--;        /* this doesn't need to be fixed */
  360. ! #endif
  361.           p_end--;
  362.           p_first++;            /* do append rather than insert */
  363. ***************
  364. *** 745,749 ****
  365.               fillsrc++;
  366.           if (fillsrc > p_end)
  367. !             fatal2("Replacement text or line numbers mangled in hunk at line %ld\n",
  368.               p_hunk_beg);
  369.           p_line[filldst] = p_line[fillsrc];
  370. --- 747,751 ----
  371.               fillsrc++;
  372.           if (fillsrc > p_end)
  373. !             fatal2("replacement text or line numbers mangled in hunk at line %ld\n",
  374.               p_hunk_beg);
  375.           p_line[filldst] = p_line[fillsrc];
  376. ***************
  377. *** 833,837 ****
  378.               Strcpy(buf, " \n");  /* assume blank lines got chopped */
  379.           else {
  380. !             fatal1("Unexpected end of file in patch.\n");
  381.           }
  382.           }
  383. --- 835,839 ----
  384.               Strcpy(buf, " \n");  /* assume blank lines got chopped */
  385.           else {
  386. !             fatal1("unexpected end of file in patch\n");
  387.           }
  388.           }
  389. ***************
  390. *** 941,945 ****
  391.       p_end = p_ptrn_lines + 1 + max - min + 1;
  392.       if (p_end > MAXHUNKSIZE)
  393. !         fatal4("Hunk too large (%ld lines) at line %ld: %s",
  394.             p_end, p_input_line, buf);
  395.       while (p_end >= hunkmax)
  396. --- 943,947 ----
  397.       p_end = p_ptrn_lines + 1 + max - min + 1;
  398.       if (p_end > MAXHUNKSIZE)
  399. !         fatal4("hunk too large (%ld lines) at line %ld: %s",
  400.             p_end, p_input_line, buf);
  401.       while (p_end >= hunkmax)
  402. ***************
  403. *** 958,965 ****
  404.           p_input_line++;
  405.           if (ret == Nullch)
  406. !         fatal2("Unexpected end of file in patch at line %ld.\n",
  407.             p_input_line);
  408.           if (*buf != '<')
  409. !         fatal2("< expected at line %ld of patch.\n", p_input_line);
  410.           p_line[i] = savestr(buf+2);
  411.           if (out_of_mem) {
  412. --- 960,967 ----
  413.           p_input_line++;
  414.           if (ret == Nullch)
  415. !         fatal2("unexpected end of file in patch at line %ld\n",
  416.             p_input_line);
  417.           if (*buf != '<')
  418. !         fatal2("< expected at line %ld of patch\n", p_input_line);
  419.           p_line[i] = savestr(buf+2);
  420.           if (out_of_mem) {
  421. ***************
  422. *** 974,981 ****
  423.           p_input_line++;
  424.           if (ret == Nullch)
  425. !         fatal2("Unexpected end of file in patch at line %ld.\n",
  426.               p_input_line);
  427.           if (*buf != '-')
  428. !         fatal2("--- expected at line %ld of patch.\n", p_input_line);
  429.       }
  430.       Sprintf(buf, "--- %ld,%ld\n", min, max);
  431. --- 976,983 ----
  432.           p_input_line++;
  433.           if (ret == Nullch)
  434. !         fatal2("unexpected end of file in patch at line %ld\n",
  435.               p_input_line);
  436.           if (*buf != '-')
  437. !         fatal2("--- expected at line %ld of patch\n", p_input_line);
  438.       }
  439.       Sprintf(buf, "--- %ld,%ld\n", min, max);
  440. ***************
  441. *** 990,997 ****
  442.           p_input_line++;
  443.           if (ret == Nullch)
  444. !         fatal2("Unexpected end of file in patch at line %ld.\n",
  445.               p_input_line);
  446.           if (*buf != '>')
  447. !         fatal2("> expected at line %ld of patch.\n", p_input_line);
  448.           p_line[i] = savestr(buf+2);
  449.           if (out_of_mem) {
  450. --- 992,999 ----
  451.           p_input_line++;
  452.           if (ret == Nullch)
  453. !         fatal2("unexpected end of file in patch at line %ld\n",
  454.               p_input_line);
  455.           if (*buf != '>')
  456. !         fatal2("> expected at line %ld of patch\n", p_input_line);
  457.           p_line[i] = savestr(buf+2);
  458.           if (out_of_mem) {
  459. ***************
  460. *** 1249,1253 ****
  461.       Reg3 bool this_line_is_command = FALSE;
  462.       Reg4 FILE *pipefp;
  463. -     FILE *popen();
  464.   
  465.       if (!skip_rest_of_patch) {
  466. --- 1251,1254 ----
  467. diff -C2 -N patch-2.0.12u7/util.c patch-2.0.12u8/util.c
  468. *** patch-2.0.12u7/util.c    Mon Jul  6 15:25:27 1992
  469. --- patch-2.0.12u8/util.c    Mon Sep 14 22:04:46 1992
  470. ***************
  471. *** 5,8 ****
  472. --- 5,23 ----
  473.   #include "backupfile.h"
  474.   
  475. + void my_exit();
  476. + static char *
  477. + private_strerror (errnum)
  478. +      int errnum;
  479. + {
  480. +   extern char *sys_errlist[];
  481. +   extern int sys_nerr;
  482. +   if (errnum > 0 && errnum <= sys_nerr)
  483. +     return sys_errlist[errnum];
  484. +   return "Unknown system error";
  485. + }
  486. + #define strerror private_strerror
  487.   /* Rename a file, copying it if necessary. */
  488.   
  489. ***************
  490. *** 25,32 ****
  491.       fromfd = open(from, 0);
  492.       if (fromfd < 0)
  493. !         fatal2("patch: internal error, can't reopen %s\n", from);
  494.       while ((i=read(fromfd, buf, sizeof buf)) > 0)
  495.           if (write(1, buf, i) != 1)
  496. !         fatal1("patch: write failed\n");
  497.       Close(fromfd);
  498.       return 0;
  499. --- 40,47 ----
  500.       fromfd = open(from, 0);
  501.       if (fromfd < 0)
  502. !         pfatal2("internal error, can't reopen %s", from);
  503.       while ((i=read(fromfd, buf, sizeof buf)) > 0)
  504.           if (write(1, buf, i) != 1)
  505. !         pfatal1("write failed");
  506.       Close(fromfd);
  507.       return 0;
  508. ***************
  509. *** 40,44 ****
  510.       char *backupname = find_backup_file_name(to);
  511.       if (backupname == (char *) 0)
  512. !         fatal1("Can't seem to get enough memory.\n");
  513.       Strcpy(bakname, backupname);
  514.       free(backupname);
  515. --- 55,59 ----
  516.       char *backupname = find_backup_file_name(to);
  517.       if (backupname == (char *) 0)
  518. !         fatal1("out of memory\n");
  519.       Strcpy(bakname, backupname);
  520.       free(backupname);
  521. ***************
  522. *** 49,53 ****
  523.       }
  524.   
  525. !     if (stat(to, &filestat) >= 0) {    /* output file exists */
  526.       dev_t to_device = filestat.st_dev;
  527.       ino_t to_inode  = filestat.st_ino;
  528. --- 64,68 ----
  529.       }
  530.   
  531. !     if (stat(to, &filestat) == 0) {    /* output file exists */
  532.       dev_t to_device = filestat.st_dev;
  533.       ino_t to_inode  = filestat.st_ino;
  534. ***************
  535. *** 61,65 ****
  536.          Change the first lowercase char into uppercase;
  537.          if that isn't sufficient, chop off the first char and try again.  */
  538. !     while (stat(bakname, &filestat) >= 0 &&
  539.           to_device == filestat.st_dev && to_inode == filestat.st_ino) {
  540.           /* Skip initial non-lowercase chars.  */
  541. --- 76,80 ----
  542.          Change the first lowercase char into uppercase;
  543.          if that isn't sufficient, chop off the first char and try again.  */
  544. !     while (stat(bakname, &filestat) == 0 &&
  545.           to_device == filestat.st_dev && to_inode == filestat.st_ino) {
  546.           /* Skip initial non-lowercase chars.  */
  547. ***************
  548. *** 84,88 ****
  549.           bakfd = creat(bakname, 0666);
  550.           if (bakfd < 0) {
  551. !         say3("patch: can't backup %s, output is in %s.\n", to, from);
  552.           return -1;
  553.           }
  554. --- 99,104 ----
  555.           bakfd = creat(bakname, 0666);
  556.           if (bakfd < 0) {
  557. !         say4("Can't backup %s, output is in %s: %s\n", to, from,
  558. !              strerror(errno));
  559.           return -1;
  560.           }
  561. ***************
  562. *** 89,96 ****
  563.           tofd = open(to, 0);
  564.           if (tofd < 0)
  565. !         fatal2("patch: internal error, can't open %s\n", to);
  566.           while ((i=read(tofd, buf, sizeof buf)) > 0)
  567.           if (write(bakfd, buf, i) != i)
  568. !             fatal1("patch: write failed\n");
  569.           Close(tofd);
  570.           Close(bakfd);
  571. --- 105,112 ----
  572.           tofd = open(to, 0);
  573.           if (tofd < 0)
  574. !         pfatal2("internal error, can't open %s", to);
  575.           while ((i=read(tofd, buf, sizeof buf)) > 0)
  576.           if (write(bakfd, buf, i) != i)
  577. !             pfatal1("write failed");
  578.           Close(tofd);
  579.           Close(bakfd);
  580. ***************
  581. *** 107,112 ****
  582.       tofd = creat(to, 0666);
  583.       if (tofd < 0) {
  584. !         say3("patch: can't create %s, output is in %s.\n",
  585. !           to, from);
  586.           return -1;
  587.       }
  588. --- 123,128 ----
  589.       tofd = creat(to, 0666);
  590.       if (tofd < 0) {
  591. !         say4("Can't create %s, output is in %s: %s\n",
  592. !           to, from, strerror(errno));
  593.           return -1;
  594.       }
  595. ***************
  596. *** 113,120 ****
  597.       fromfd = open(from, 0);
  598.       if (fromfd < 0)
  599. !         fatal2("patch: internal error, can't reopen %s\n", from);
  600.       while ((i=read(fromfd, buf, sizeof buf)) > 0)
  601.           if (write(tofd, buf, i) != i)
  602. !         fatal1("patch: write failed\n");
  603.       Close(fromfd);
  604.       Close(tofd);
  605. --- 129,136 ----
  606.       fromfd = open(from, 0);
  607.       if (fromfd < 0)
  608. !         pfatal2("internal error, can't reopen %s", from);
  609.       while ((i=read(fromfd, buf, sizeof buf)) > 0)
  610.           if (write(tofd, buf, i) != i)
  611. !         pfatal1("write failed");
  612.       Close(fromfd);
  613.       Close(tofd);
  614. ***************
  615. *** 136,146 ****
  616.       tofd = creat(to, 0666);
  617.       if (tofd < 0)
  618. !     fatal2("patch: can't create %s.\n", to);
  619.       fromfd = open(from, 0);
  620.       if (fromfd < 0)
  621. !     fatal2("patch: internal error, can't reopen %s\n", from);
  622.       while ((i=read(fromfd, buf, sizeof buf)) > 0)
  623.       if (write(tofd, buf, i) != i)
  624. !         fatal2("patch: write (%s) failed\n", to);
  625.       Close(fromfd);
  626.       Close(tofd);
  627. --- 152,162 ----
  628.       tofd = creat(to, 0666);
  629.       if (tofd < 0)
  630. !     pfatal2("can't create %s", to);
  631.       fromfd = open(from, 0);
  632.       if (fromfd < 0)
  633. ;
  634.       fromfd = open(from, 0);
  635.       if (fromfd < 0)
  636. !     pfatal2("internal error, can't reopen %s", from);
  637.       while ((i=read(fromfd, buf, sizeof buf)) > 0)
  638.       if (write(tofd, buf, i) != i)
  639. !         pfatal2("write to %s failed", to);
  640.       Close(fromfd);
  641.       Close(tofd);
  642. ***************
  643. *** 165,169 ****
  644.           out_of_mem = TRUE;
  645.       else
  646. !         fatal1("patch: out of memory (savestr)\n");
  647.       }
  648.       else {
  649. --- 181,185 ----
  650.           out_of_mem = TRUE;
  651.       else
  652. !         fatal1("out of memory\n");
  653.       }
  654.       else {
  655. ***************
  656. *** 181,184 ****
  657. --- 197,202 ----
  658.   fatal(pat) char *pat; { ; }
  659.   /*VARARGS ARGSUSED*/
  660. + pfatal(pat) char *pat; { ; }
  661. + /*VARARGS ARGSUSED*/
  662.   ask(pat) char *pat; { ; }
  663.   
  664. ***************
  665. *** 203,209 ****
  666.   long arg1,arg2,arg3;
  667.   {
  668. !     void my_exit();
  669.   
  670. !     say(pat, arg1, arg2, arg3);
  671.       my_exit(1);
  672.   }
  673. --- 221,241 ----
  674.   long arg1,arg2,arg3;
  675.   {
  676. !     fprintf(stderr, "patch: **** ");
  677. !     fprintf(stderr, pat, arg1, arg2, arg3);
  678. !     my_exit(1);
  679. ! }
  680. ! /* Say something from patch, something from the system, then silence . . . */
  681. ! void                /* very void */
  682. ! pfatal(pat,arg1,arg2,arg3)
  683. ! char *pat;
  684. ! long arg1,arg2,arg3;
  685. ! {
  686. !     int errnum = errno;
  687.   
  688. !     fprintf(stderr, "patch: **** ");
  689. !     fprintf(stderr, pat, arg1, arg2, arg3);
  690. !     fprintf(stderr, ": %s\n", strerror(errnum));
  691.       my_exit(1);
  692.   }
  693. ***************
  694. *** 261,265 ****
  695.   int reset;
  696.   {
  697. -     void my_exit();
  698.   #ifndef lint
  699.   #ifdef VOIDSIG
  700. --- 293,296 ----
  701. ***************
  702. *** 301,305 ****
  703.   }
  704.   
  705. ! /* Make sure we'll have the directories to create a file. */
  706.   
  707.   void
  708. --- 332,337 ----
  709.   }
  710.   
  711. ! /* Make sure we'll have the directories to create a file.
  712. !    If `striplast' is TRUE, ignore the last element of `filename'.  */
  713.   
  714.   void
  715. ***************
  716. *** 310,317 ****
  717.       char tmpbuf[256];
  718.       Reg2 char *s = tmpbuf;
  719. !     char *dirv[20];
  720.       Reg3 int i;
  721. !     Reg4 int dirvp = 0;
  722.   
  723.       while (*filename) {
  724.       if (*filename == '/') {
  725. --- 342,351 ----
  726.       char tmpbuf[256];
  727.       Reg2 char *s = tmpbuf;
  728. !     char *dirv[20];        /* Point to the NULs between elements.  */
  729.       Reg3 int i;
  730. !     Reg4 int dirvp = 0;        /* Number of finished entries in dirv. */
  731.   
  732. +     /* Copy `filename' into `tmpbuf' with a NUL instead of a slash
  733. +        between the directories.  */
  734.       while (*filename) {
  735.       if (*filename == '/') {
  736. ***************
  737. *** 330,342 ****
  738.       if (dirvp < 0)
  739.       return;
  740.       strcpy(buf, "mkdir");
  741.       s = buf;
  742.       for (i=0; i<=dirvp; i++) {
  743. !     while (*s) s++;
  744. !     *s++ = ' ';
  745. !     strcpy(s, tmpbuf);
  746.       *dirv[i] = '/';
  747.       }
  748. !     system(buf);
  749.   }
  750.   
  751. --- 364,382 ----
  752.       if (dirvp < 0)
  753.       return;
  754.       strcpy(buf, "mkdir");
  755.       s = buf;
  756.       for (i=0; i<=dirvp; i++) {
  757. !     struct stat sbuf;
  758. !     if (stat(tmpbuf, &sbuf) && errno == ENOENT) {
  759. !         while (*s) s++;
  760. !         *s++ = ' ';
  761. !         strcpy(s, tmpbuf);
  762. !     }
  763.       *dirv[i] = '/';
  764.       }
  765. !     if (s != buf)
  766. !     system(buf);
  767.   }
  768.   
  769. ***************
  770. *** 380,384 ****
  771.       if (strip_leading == 957 && name != fullname && *fullname != '/') {
  772.       name[-1] = '\0';
  773. !     if (stat(fullname, &filestat) >= 0 && S_ISDIR (filestat.st_mode)) {
  774.           name[-1] = '/';
  775.           name=fullname;
  776. --- 420,424 ----
  777.       if (strip_leading == 957 && name != fullname && *fullname != '/') {
  778.       name[-1] = '\0';
  779. !     if (stat(fullname, &filestat) == 0 && S_ISDIR (filestat.st_mode)) {
  780.           name[-1] = '/';
  781.           name=fullname;
  782. ***************
  783. *** 389,402 ****
  784.       free(fullname);
  785.   
  786. !     if (stat(name, &filestat) < 0 && !assume_exists) {
  787. !         Sprintf(tmpbuf, "RCS/%s%s", name, RCSSUFFIX);
  788. !     if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+4, &filestat) < 0) {
  789. !         Sprintf(tmpbuf, "SCCS/%s%s", SCCSPREFIX, name);
  790. !         if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+5, &filestat) < 0) {
  791. !         free(name);
  792. !         name = Nullch;
  793. !         }
  794. !     }
  795.       }
  796.       return name;
  797.   }
  798. --- 429,450 ----
  799.       free(fullname);
  800.   
  801. !     if (stat(name, &filestat) && !assume_exists) {
  802. !     char *filebase = basename(name);
  803. !     int pathlen = filebase - name;
  804. !     /* Put any leading path into `tmpbuf'.  */
  805. !     strncpy(tmpbuf, name, pathlen);
  806. ! #define try(f, a1, a2) (Sprintf(tmpbuf + pathlen, f, a1, a2), stat(tmpbuf, &filestat) == 0)
  807. !     if (   try("RCS/%s%s", filebase, RCSSUFFIX)
  808. !         || try("RCS/%s"  , filebase,         0)
  809. !         || try(    "%s%s", filebase, RCSSUFFIX)
  810. !         || try("SCCS/%s%s", SCCSPREFIX, filebase)
  811. !         || try(     "%s%s", SCCSPREFIX, filebase))
  812. !       return name;
  813. !     free(name);
  814. !     name = Nullch;
  815.       }
  816.       return name;
  817.   }
  818. diff -C2 -N patch-2.0.12u7/util.h patch-2.0.12u8/util.h
  819. *** patch-2.0.12u7/util.h    Wed Aug 15 01:13:39 1990
  820. --- patch-2.0.12u8/util.h    Mon Jul 20 14:20:24 1992
  821. ***************
  822. *** 23,26 ****
  823. --- 23,30 ----
  824.   #define fatal3 fatal
  825.   #define fatal4 fatal
  826. + #define pfatal1 pfatal
  827. + #define pfatal2 pfatal
  828. + #define pfatal3 pfatal
  829. + #define pfatal4 pfatal
  830.   
  831.   #else /* hope they allow multi-line macro actual arguments */
  832. ***************
  833. *** 40,43 ****
  834. --- 44,51 ----
  835.   #define fatal3(a,b,c) fatal(a, (b)==(b), (c)==(c), 0)
  836.   #define fatal4(a,b,c,d) fatal(a, (b)==(b), (c)==(c), (d)==(d))
  837. + #define pfatal1(a) pfatal(a, 0, 0, 0)
  838. + #define pfatal2(a,b) pfatal(a, (b)==(b), 0, 0)
  839. + #define pfatal3(a,b,c) pfatal(a, (b)==(b), (c)==(c), 0)
  840. + #define pfatal4(a,b,c,d) pfatal(a, (b)==(b), (c)==(c), (d)==(d))
  841.   
  842.   #else /* lint */
  843. ***************
  844. *** 55,58 ****
  845. --- 63,70 ----
  846.   #define fatal3(a,b,c) fatal(a, b, c, Nullch)
  847.   #define fatal4 fatal
  848. + #define pfatal1(a) pfatal(a, Nullch, Nullch, Nullch)
  849. + #define pfatal2(a,b) pfatal(a, b, Nullch, Nullch)
  850. + #define pfatal3(a,b,c) pfatal(a, b, c, Nullch)
  851. + #define pfatal4 pfatal
  852.   
  853.   #endif /* lint */
  854. ***************
  855. *** 68,71 ****
  856. --- 80,84 ----
  857.   void say();
  858.   void fatal();
  859. + void pfatal();
  860.   void ask();
  861.   char *savestr();
  862. ***************
  863. *** 73,74 ****
  864. --- 86,88 ----
  865.   void ignore_signals();
  866.   void makedirs();
  867. + char *basename();
  868. diff -C2 -N patch-2.0.12u7/version.c patch-2.0.12u8/version.c
  869. *** patch-2.0.12u7/version.c    Sat Mar 14 14:44:29 1992
  870. --- patch-2.0.12u8/version.c    Wed Jul  8 19:17:26 1992
  871. ***************
  872. *** 14,17 ****
  873. --- 14,19 ----
  874.   #include "version.h"
  875.   
  876. + void my_exit();
  877.   /* Print out the version number and die. */
  878.   
  879. ***************
  880. *** 19,30 ****
  881.   version()
  882.   {
  883. !     void my_exit();
  884. !     extern char rcsid[];
  885. ! #ifdef lint
  886. !     rcsid[0] = rcsid[0];
  887. ! #else
  888. !     fprintf(stderr, "%s\nPatch level: %s\n", rcsid, PATCHLEVEL);
  889.       my_exit(0);
  890. - #endif
  891.   }
  892. --- 21,25 ----
  893.   version()
  894.   {
  895. !     fprintf(stderr, "Patch version 2.0, patch level %s\n", PATCHLEVEL);
  896.       my_exit(0);
  897.   }
  898.