home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / bugs / 240 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  31.3 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 01 of 02
  5. Message-ID: <DJM.92Sep15160709@nutrimat.gnu.ai.mit.edu>
  6. Date: 15 Sep 92 20:07:09 GMT
  7. Sender: news@ai.mit.edu
  8. Organization: Free Software Foundation
  9. Lines: 1079
  10.  
  11. Apparently there was some corruption the first time.
  12. Trying again:
  13.  
  14. Prereq: "12u7"
  15. diff -C2 -N patch-2.0.12u7/patchlevel.h patch-2.0.12u8/patchlevel.h
  16. *** patch-2.0.12u7/patchlevel.h    Mon Jul  6 15:42:09 1992
  17. --- patch-2.0.12u8/patchlevel.h    Tue Sep 15 00:36:28 1992
  18. ***************
  19. *** 1 ****
  20. ! #define PATCHLEVEL "12u7"
  21. --- 1 ----
  22. ! #define PATCHLEVEL "12u8"
  23. diff -C2 -N patch-2.0.12u7/ChangeLog patch-2.0.12u8/ChangeLog
  24. *** patch-2.0.12u7/ChangeLog    Mon Jul  6 15:42:24 1992
  25. --- patch-2.0.12u8/ChangeLog    Tue Sep 15 00:36:32 1992
  26. ***************
  27. *** 1,3 ****
  28. --- 1,98 ----
  29. + Tue Sep 15 00:36:15 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  30. +     * patchlevel.h: PATCHLEVEL 12u8.
  31. + Mon Sep 14 22:01:23 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  32. +     * Makefile.SH: Add uninstall target.  Simplify install target.
  33. +     * util.c (fatal, pfatal): Add some asterisks to make fatal
  34. +     messages stand out more.
  35. + Tue Aug 25 22:13:36 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  36. +     * patch.c (main, get_some_switches), common.h, inp.c (plan_a,
  37. +     plan_b), pch.c (there_is_another_aptch): Add -t option,
  38. +     similar to -f.
  39. + Mon Jul 27 11:27:07 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  40. +     * inp.c (plan_a, util.c (fetchname): Use a macro to simplify code.
  41. +     * common.h: Define SCCSDIFF and RCSDIFF.
  42. +     * inp.c (plan_a): Use them to make sure it's safe to check out
  43. +     the default RCS or SCCS version.
  44. +     From Paul Eggert.
  45. + Wed Jul 22 14:37:08 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  46. +     * patch.man: Use the standard comment syntax -- '\" -- instead
  47. +     of '''.
  48. + Tue Jul 21 15:26:01 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  49. +     * Configure: Add /etc /usr/lib /lib to pth.
  50. + Mon Jul 20 14:10:32 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  51. +     * util.h: Declare basename.
  52. +     * inp.c (plan_a), util.c (fetchname): Use it to isolate the
  53. +     leading path when testing for RCS and SCCS files.
  54. + Sat Jul 11 18:03:26 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  55. +     * Configure: Use the user's PATH and build pth from it.
  56. + Fri Jul 10 16:03:23 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  57. +     * Configure: Change cc -S to cc -c and tr '[ - ]' '[\012-\012]'
  58. +     to tr ' ' '\012' for AIX 3.2.
  59. +     From chip@tct.com (Chip Salzenberg).
  60. +     * util.c (makedirs): Only make the directories that don't exist.
  61. +     From chip@tct.com (Chip Salzenberg).
  62. + Wed Jul  8 01:21:15 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  63. +     * util.c (fatal, pfatal): Print "patch: " before message.
  64. +     * pch.c, inp.c, patch.c, util.c: Remove "patch: " from the
  65. +     callers that had it.
  66. +     * util.c (pfatal): New function.
  67. +     * util.h: Declare it and pfatal[1-4] macros.
  68. +     * various files: Use it instead of fatal where appropriate.
  69. +     * Configure: Make /usr/local/man/man1 the first choice for the
  70. +     man pages.
  71. +     * patch.c (main): Open ofp after checking for ed script.
  72. +     Close ofp and rejfp before trying plan B.
  73. +     From epang@sfu.ca (Eugene Pang).
  74. +     * backupfile.h: Declare get_version.
  75. +     * Move decls of rindex and popen to common.h.
  76. +     * common.h (myuid): New variable.
  77. +     * patch.c (main): Initialize it.
  78. +     * inp.c (myuid): Function removed.
  79. +     (plan_a): Use the variable, not the function.
  80. +     * patch.c: Reinstate -E option.
  81. + Tue Jul  7 23:19:28 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  82. +     * inp.c (myuid): New function.
  83. +     (plan_a): Call it.  Optimize stat calls.  Be smarter about
  84. +     detecting checked out RCS and SCCS files.
  85. +     From Paul Eggert (eggert@twinsun.com).
  86. +     * inp.c, util.c, patch.c: Don't bother checking for stat() > 0.
  87.   Mon Jul  6 13:01:52 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  88. +     * version.c (version): Don't print the RCS stuff, since we're
  89. +     not updating it regularly.
  90. +     * patch.c (get_some_switches): Make the usage message more accurate.
  91.   
  92.       * patchlevel.h: PATCHLEVEL 12u7.
  93. diff -C2 -N patch-2.0.12u7/Configure patch-2.0.12u8/Configure
  94. *** patch-2.0.12u7/Configure    Sat Mar 14 22:05:34 1992
  95. --- patch-2.0.12u8/Configure    Wed Jul 22 14:51:32 1992
  96. ***************
  97. *** 16,20 ****
  98.   
  99.   : sanity checks
  100. ! PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin'
  101.   export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  102.   
  103. --- 16,22 ----
  104.   
  105.   : sanity checks
  106. ! : the user has a better chance than we do of setting a reasonable PATH
  107. ! : but add some directories we need that are probably not there
  108. ! PATH=.:${PATH}:/etc:/usr/lib:/lib
  109.   export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  110.   
  111. ***************
  112. *** 147,151 ****
  113.   attrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
  114.   attrlist="$attrlist mc68k m68k __STDC__"
  115. ! pth="/bin /usr/bin /usr/ccs/bin /usr/ucb /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /lib"
  116.   d_newshome="../../NeWS"
  117.   defvoidused=7
  118. --- 149,153 ----
  119.   attrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
  120.   attrlist="$attrlist mc68k m68k __STDC__"
  121. ! pth=`echo $PATH | tr : ' '`
  122.   d_newshome="../../NeWS"
  123.   defvoidused=7
  124. ***************
  125. *** 742,746 ****
  126.   }
  127.   EOCP
  128. !     if cc -S -DTRY=7 try.c >.out 2>&1 ; then
  129.       voidflags=7
  130.       echo "It appears to support void fully."
  131. --- 744,749 ----
  132.   }
  133.   EOCP
  134. !     : Argh -- AIX 3.2 does not have cc -S!
  135. !     if cc -c -DTRY=7 try.c >.out 2>&1 ; then
  136.       voidflags=7
  137.       echo "It appears to support void fully."
  138. ***************
  139. *** 751,757 ****
  140.       else
  141.       echo "Hmm, you compiler has some difficulty with void.  Checking further..."
  142. !     if cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
  143.           echo "It supports 1..."
  144. !         if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
  145.           voidflags=3
  146.           echo "And it supports 2 but not 4."
  147. --- 754,760 ----
  148.       else
  149.       echo "Hmm, you compiler has some difficulty with void.  Checking further..."
  150. !     if cc -c -DTRY=1 try.c >/dev/null 2>&1 ; then
  151.           echo "It supports 1..."
  152. !         if cc -c -DTRY=3 try.c >/dev/null 2>&1 ; then
  153.           voidflags=3
  154.           echo "And it supports 2 but not 4."
  155. ***************
  156. *** 758,762 ****
  157.           else
  158.           echo "It doesn't support 2..."
  159. !         if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
  160.               voidflags=5
  161.               echo "But it supports 4."
  162. --- 761,765 ----
  163.           else
  164.           echo "It doesn't support 2..."
  165. !         if cc -c -DTRY=3 try.c >/dev/null 2>&1 ; then
  166.               voidflags=5
  167.               echo "But it supports 4."
  168. ***************
  169. *** 869,873 ****
  170.   : get C preprocessor symbols handy
  171.   echo " "
  172. ! echo $attrlist | $tr '[ - ]' '[\012-\012]' >Cppsym.know
  173.   $cat <<EOSS >Cppsym
  174.   $startsh
  175. --- 872,877 ----
  176.   : get C preprocessor symbols handy
  177.   echo " "
  178. ! : AIX 3.2 rejects tr '[ - ]' because the range endpoints are the same.
  179. ! echo $attrlist | $tr ' ' '\012' >Cppsym.know
  180.   $cat <<EOSS >Cppsym
  181.   $startsh
  182. ***************
  183. *** 896,900 ****
  184.   0) exit 1;;
  185.   esac
  186. ! echo \$* | $tr '[ - ]' '[\012-\012]' | $sed -e 's/\(.*\)/\\
  187.   #ifdef \1\\
  188.   exit 0; _ _ _ _\1\\     \1\\
  189. --- 900,904 ----
  190.   0) exit 1;;
  191.   esac
  192. ! echo \$* | $tr ' ' '\012' | $sed -e 's/\(.*\)/\\
  193.   #ifdef \1\\
  194.   exit 0; _ _ _ _\1\\     \1\\
  195. ***************
  196. *** 1032,1036 ****
  197.   case "$mansrc" in
  198.   '')
  199. !     dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
  200.       ;;
  201.   *)  dflt="$mansrc"
  202. --- 1036,1040 ----
  203.   case "$mansrc" in
  204.   '')
  205. !     dflt=`loc . /usr/man/man1 /usr/local/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1`
  206.       ;;
  207.   *)  dflt="$mansrc"
  208. diff -C2 -N patch-2.0.12u7/Makefile.SH patch-2.0.12u8/Makefile.SH
  209. *** patch-2.0.12u7/Makefile.SH    Mon Jul  6 14:28:10 1992
  210. --- patch-2.0.12u8/Makefile.SH    Mon Jul  6 14:28:10 1992
  211. --- patch-2.0.12u8/Makefile.SH    Mon Sep 14 22:39:38 1992
  212. ***************
  213. *** 66,78 ****
  214.   install: patch
  215.       export PATH || exit 1
  216. !     - mv $(bin)/patch $(bin)/patch.old
  217. !     - if test `pwd` != $(bin); then cp $(public) $(bin); fi
  218. !     cd $(bin); chmod 755 $(public)
  219. !     - if test `pwd` != $(mansrc); then \
  220. ! for page in $(manpages); do \
  221. ! rm -f $(mansrc)/../cat$(manext)/`basename $$page .man`.$(manext); \
  222. ! cp $$page $(mansrc)/`basename $$page .man`.$(manext); \
  223. ! done; \
  224. ! fi
  225.   
  226.   clean:
  227. --- 66,77 ----
  228.   install: patch
  229.       export PATH || exit 1
  230. !     -mv $(bin)/patch $(bin)/patch.old
  231. !     cp patch $(bin)/patch
  232. !     chmod 755 $(bin)/patch
  233. !     -cp patch.man $(mansrc)/patch.$(manext)
  234. ! uninstall:
  235. !     rm -f $(bin)/patch $(mansrc)/patch.$(manext)
  236. !     test ! -f $(bin)/patch.old || mv $(bin)/patch.old $(bin)/patch
  237.   
  238.   clean:
  239. ***************
  240. *** 93,97 ****
  241.   
  242.   dist: $(DISTFILES)
  243. !     echo patch-2.0.`sed -e '/PATCHLEVEL/!d' -e 's/[^0-9u.]*\([0-9u.]*\).*/\1/' -e q patchlevel.h` > .fname
  244.       rm -rf `cat .fname`
  245.       mkdir `cat .fname`
  246. --- 92,96 ----
  247.   
  248.   dist: $(DISTFILES)
  249. !     echo patch-2.0.`sed -e '/PATCHLEVEL/!d' -e 's/[^0-9]*\([0-9a-z.]*\).*/\1/' -e q patchlevel.h` > .fname
  250.       rm -rf `cat .fname`
  251.       mkdir `cat .fname`
  252. diff -C2 -N patch-2.0.12u7/README patch-2.0.12u8/README
  253. *** patch-2.0.12u7/README    Sat Jul  4 08:54:17 1992
  254. --- patch-2.0.12u8/README    Tue Sep 15 01:18:33 1992
  255. ***************
  256. *** 3,11 ****
  257.   support the unified context diff format that GNU diff can produce, and
  258.   to support making GNU Emacs-style backup files.  They also include
  259. ! fixes for some bugs.  The FSF is distributing this version of patch
  260. ! independently because as of this writing, Larry Wall has not released
  261. ! a new version of patch since mid-1988.  I have heard that he has been
  262. ! too busy working on other things, like Perl.
  263.   
  264.   Here is a wish list of some projects to improve patch:
  265.   
  266. --- 3,21 ----
  267.   support the unified context diff format that GNU diff can produce, and
  268.   to support making GNU Emacs-style backup files.  They also include
  269. ! fixes for some bugs.
  270.   
  271. + There are two GNU variants of patch: this one, which retains Larry
  272. + Wall's interactive Configure script and has patchlevels starting with
  273. + `12u'; and another one that has a GNU-style non-interactive configure
  274. + script and accepts long-named options, and has patchlevels starting
  275. + with `12g'.  Unlike the 12g variant, the 12u variant contains no
  276. + copylefted code, for the paranoid.  The two variants are otherwise the
  277. + same.  They should be available from the same places.
  278. + The FSF is distributing this version of patch independently because as
  279. + of this writing, Larry Wall has not released a new version of patch
  280. + since mid-1988.  I have heard that he has been too busy working on
  281. + other things, like Perl.
  282.   Here is a wish list of some projects to improve patch:
  283.   
  284. ***************
  285. *** 56,60 ****
  286.   
  287.   2)  Glance through config.h to make sure system dependencies are correct.
  288. !     Most of them should have been taken care of by running the Configure script.
  289.   
  290.       If you have any additional changes to make to the C definitions, they
  291. --- 66,71 ----
  292.   
  293.   2)  Glance through config.h to make sure system dependencies are correct.
  294. !     Most of them should have been taken care of by running the
  295. !     Configure script. 
  296.   
  297.       If you have any additional changes to make to the C definitions, they
  298. ***************
  299. *** 83,100 ****
  300.       I've probably changed my copy since the version you have.
  301.   
  302. !     Watch for patch patches in net.sources.bugs.  Patches will generally be
  303. !     in a form usable by the patch program.  If you are just now bringing up
  304. !     patch and aren't sure how many patches there are, write to me and I'll
  305. !     send any you don't have.  Your current patch level is shown in patchlevel.h.
  306. ! NEW FEATURES IN THIS RELEASE
  307. ! (Correct) support for 4.3bsd-style context diffs.
  308. ! Files can be created from scratch.
  309. ! You can specify a fuzz-factor for context matching.
  310. ! You can force patch to ask no questions.
  311. ! You can specify how much of the leading pathname to strip off filenames.
  312. ! Uses a Configure script for greater portability.
  313. ! You are now asked if you want to apply a reversed patch.
  314. ! No limit (apart from memory) on the size of hunks.
  315. --- 94,98 ----
  316.       I've probably changed my copy since the version you have.
  317.   
  318. !     Watch for patch patches in comp.sources.bugs.  Patches will generally be
  319. !     in a form usable by the patch program.  Your current patch level
  320. !     is shown in patchlevel.h.
  321. diff -C2 -N patch-2.0.12u7/backupfile.c patch-2.0.12u8/backupfile.c
  322. *** patch-2.0.12u7/backupfile.c    Wed Apr 29 10:19:40 1992
  323. --- patch-2.0.12u8/backupfile.c    Wed Jul  8 18:48:29 1992
  324. ***************
  325. *** 19,22 ****
  326. --- 19,23 ----
  327.   char *index ();
  328.   char *rindex ();
  329. + char *malloc ();
  330.   
  331.   #ifdef DIRENT
  332. ***************
  333. *** 41,46 ****
  334.   #endif /* !USG */
  335.   #endif /* !DIRENT */
  336. - char *malloc ();
  337.   
  338.   #ifndef isascii
  339. --- 42,45 ----
  340. diff -C2 -N patch-2.0.12u7/backupfile.h patch-2.0.12u8/backupfile.h
  341. *** patch-2.0.12u7/backupfile.h    Sat Mar 14 12:31:52 1992
  342. --- patch-2.0.12u8/backupfile.h    Wed Jul  8 18:49:27 1992
  343. ***************
  344. *** 31,35 ****
  345. --- 31,37 ----
  346.   #ifdef __STDC__
  347.   char *find_backup_file_name (char *file);
  348. + enum backup_type get_version (char *version);
  349.   #else
  350.   char *find_backup_file_name ();
  351. + enum backup_type get_version ();
  352.   #endif
  353. diff -C2 -N patch-2.0.12u7/common.h patch-2.0.12u8/common.h
  354. *** patch-2.0.12u7/common.h    Fri Jul  3 23:48:36 1992
  355. --- patch-2.0.12u8/common.h    Tue Aug 25 22:29:31 1992
  356. ***************
  357. *** 50,59 ****
  358.   
  359.   /* AIX predefines these.  */
  360. ! #ifndef TRUE
  361. ! #define TRUE (1)
  362.   #endif
  363. ! #ifndef FALSE
  364. ! #define FALSE (0)
  365.   #endif
  366.   
  367.   #define MAXHUNKSIZE 100000        /* is this enough lines? */
  368. --- 50,61 ----
  369.   
  370.   /* AIX predefines these.  */
  371. ! #ifdef TRUE
  372. ! #undef TRUE
  373.   #endif
  374. ! #ifdef FALSE
  375. ! #undef FALSE
  376.   #endif
  377. + #define TRUE (1)
  378. + #define FALSE (0)
  379.   
  380.   #define MAXHUNKSIZE 100000        /* is this enough lines? */
  381. ***************
  382. *** 61,68 ****
  383. --- 63,74 ----
  384.   #define MAXLINELEN 1024
  385.   #define BUFFERSIZE 1024
  386.   #define SCCSPREFIX "s."
  387.   #define GET "get -e %s"
  388. + #define SCCSDIFF "get -p %s | diff - %s >/dev/null"
  389.   #define RCSSUFFIX ",v"
  390.   #define CHECKOUT "co -l %s"
  391. + #define RCSDIFF "rcsdiff %s > /dev/null"
  392.   
  393.   #ifdef FLEXFILENAMES
  394. ***************
  395. *** 108,111 ****
  396. --- 114,119 ----
  397.   EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  398.   
  399. + EXT int myuid;                /* cache getuid return value */
  400.   EXT bool using_plan_a INIT(TRUE);    /* try to keep everything in memory */
  401.   EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
  402. ***************
  403. *** 135,138 ****
  404. --- 143,147 ----
  405.   EXT LINENUM maxfuzz INIT(2);
  406.   EXT bool force INIT(FALSE);
  407. + EXT bool batch INIT(FALSE);
  408.   EXT bool verbose INIT(TRUE);
  409.   EXT bool reverse INIT(FALSE);
  410. ***************
  411. *** 157,168 ****
  412.   EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  413.   
  414.   char *malloc();
  415.   char *realloc();
  416.   char *strcpy();
  417.   char *strcat();
  418. ! long atol();
  419.   long lseek();
  420.   char *mktemp();
  421. ! #if 0
  422.   #ifdef CHARSPRINTF
  423.   char *sprintf();
  424. --- 166,185 ----
  425.   EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  426.   
  427. + #include <errno.h>
  428. + #ifndef errno
  429. + extern int errno;
  430. + #endif
  431. + FILE *popen();
  432.   char *malloc();
  433.   char *realloc();
  434. + long atol();
  435. + char *getenv();
  436.   char *strcpy();
  437.   char *strcat();
  438. ! char *rindex();
  439.   long lseek();
  440.   char *mktemp();
  441. ! #if 0                /* This can cause a prototype conflict.  */
  442.   #ifdef CHARSPRINTF
  443.   char *sprintf();
  444. ***************
  445. *** 171,175 ****
  446.   #endif
  447.   #endif
  448. - char *getenv();
  449.   
  450.   #if !defined(S_ISDIR) && defined(S_IFDIR)
  451. --- 188,191 ----
  452. diff -C2 -N patch-2.0.12u7/inp.c patch-2.0.12u8/inp.c
  453. *** patch-2.0.12u7/inp.c    Mon Jul  6 13:05:31 1992
  454. --- patch-2.0.12u8/inp.c    Tue Aug 25 22:27:57 1992
  455. ***************
  456. *** 77,85 ****
  457.   char *filename;
  458.   {
  459. !     int ifd;
  460.       Reg1 char *s;
  461.       Reg2 LINENUM iline;
  462.   
  463. !     if (ok_to_create_file && stat(filename, &filestat) < 0) {
  464.       if (verbose)
  465.           say2("(Creating file %s...)\n",filename);
  466. --- 77,87 ----
  467.   char *filename;
  468.   {
  469. !     int ifd, statfailed;
  470.       Reg1 char *s;
  471.       Reg2 LINENUM iline;
  472. +     char lbuf[MAXLINELEN];
  473.   
  474. !     statfailed = stat(filename, &filestat);
  475. !     if (statfailed && ok_to_create_file) {
  476.       if (verbose)
  477.           say2("(Creating file %s...)\n",filename);
  478. ***************
  479. *** 86,113 ****
  480.       makedirs(filename, TRUE);
  481.       close(creat(filename, 0666));
  482.       }
  483. !     /* For read-only files, look for RCS or SCCS copies to check out.
  484. !        co or get will fail if someone else has already locked the file.  */
  485. !     if (stat(filename, &filestat) < 0 || access(filename, 2) < 0) {
  486. !     Sprintf(buf, "RCS/%s%s", filename, RCSSUFFIX);
  487. !     if (stat(buf, &filestat) >= 0 || stat(buf+4, &filestat) >= 0) {
  488.           Sprintf(buf, CHECKOUT, filename);
  489. !         if (verbose)
  490. !         say2("Attempting to check out %s from RCS.\n", filename);
  491. !         if (system(buf) || stat(filename, &filestat))
  492. !         fatal2("Can't check out %s.\n", filename);
  493. !     }
  494. !     else {
  495. !         Sprintf(buf+20, "SCCS/%s%s", SCCSPREFIX, filename);
  496. !         if (stat(s=buf+20, &filestat) >= 0 ||
  497. !           stat(s=buf+25, &filestat) >= 0) {
  498. !         Sprintf(buf, GET, s);
  499.           if (verbose)
  500. !             say2("Attempting to get %s from SCCS.\n", filename);
  501. !         if (system(buf) || stat(filename, &filestat))
  502. !             fatal2("Can't get %s.\n", filename);
  503.           }
  504. !         else if (stat(filename, &filestat) < 0)
  505. !         fatal2("Can't find %s.\n", filename);
  506.       }
  507.       }
  508. --- 88,147 ----
  509.       makedirs(filename, TRUE);
  510.       close(creat(filename, 0666));
  511. +     statfailed = stat(filename, &filestat);
  512.       }
  513. !     /* For nonexistent or read-only files, look for RCS or SCCS versions.  */
  514. !     if (statfailed
  515. !     /* No one can write to it.  */
  516. !     || (filestat.st_mode & 0222) == 0
  517. !     /* I can't write to it.  */
  518. !     || ((filestat.st_mode & 0022) == 0 && filestat.st_uid != myuid)) {
  519. !     struct stat cstat;
  520. !     char *cs = Nullch;
  521. !     char *filebase;
  522. !     int pathlen;
  523. !     filebase = basename(filename);
  524. !     pathlen = filebase - filename;
  525. !     /* Put any leading path into `s'.
  526. !        Leave room in lbuf for the diff command.  */
  527. !     s = lbuf + 20;
  528. !     strncpy(s, filename, pathlen);
  529. ! #define try(f, a1, a2) (Sprintf(s + pathlen, f, a1, a2), stat(s, &cstat) == 0)
  530. !     if (   try("RCS/%s%s", filebase, RCSSUFFIX)
  531. !         || try("RCS/%s"  , filebase,         0)
  532. !         || try(    "%s%s", filebase, RCSSUFFIX)) {
  533.           Sprintf(buf, CHECKOUT, filename);
  534. !         Sprintf(lbuf, RCSDIFF, filename);
  535. !         cs = "RCS";
  536. !     } else if (   try("SCCS/%s%s", SCCSPREFIX, filebase)
  537. !            || try(     "%s%s", SCCSPREFIX, filebase)) {
  538. !         Sprintf(buf, GET, s);
  539. !         Sprintf(lbuf, SCCSDIFF, s, filename);
  540. !         cs = "SCCS";
  541. !     } else if (statfailed)
  542. !         fatal2("can't find %s\n", filename);
  543. !     /* else we can't write to it but it's not under a version
  544. !        control system, so just proceed.  */
  545. !     if (cs) {
  546. !         if (!statfailed) {
  547. !         if ((filestat.st_mode & 0222) != 0)
  548. !             /* The owner can write to it.  */
  549. !             fatal3("file %s seems to be locked by somebody else under %s\n",
  550. !                filename, cs);
  551. !         /* It might be checked out unlocked.  See if it's safe to
  552. !            check out the default version locked.  */
  553.           if (verbose)
  554. !             say3("Comparing file %s to default %s version...\n",
  555. !              filename, cs);
  556. !         if (system(lbuf))
  557. !             fatal3("can't check out file %s: differs from default %s version\n",
  558. !                filename, cs);
  559.           }
  560. !         if (verbose)
  561. !         say3("Checking out file %s from %s...\n", filename, cs);
  562. !         if (system(buf) || stat(filename, &filestat))
  563. !         fatal3("can't check out file %s from %s\n", filename, cs);
  564.       }
  565.       }
  566. ***************
  567. *** 114,118 ****
  568.       filemode = filestat.st_mode;
  569.       if (!S_ISREG(filemode))
  570. !     fatal2("%s is not a normal file--can't patch.\n", filename);
  571.       i_size = filestat.st_size;
  572.       if (out_of_mem) {
  573. --- 148,152 ----
  574.       filemode = filestat.st_mode;
  575.       if (!S_ISREG(filemode))
  576. !     fatal2("%s is not a normal file--can't patch\n", filename);
  577.       i_size = filestat.st_size;
  578.       if (out_of_mem) {
  579. ***************
  580. *** 130,134 ****
  581.       return FALSE;
  582.       if ((ifd = open(filename, 0)) < 0)
  583. !     fatal2("Can't open file %s\n", filename);
  584.   #ifndef lint
  585.       if (read(ifd, i_womp, (int)i_size) != i_size) {
  586. --- 164,168 ----
  587.       return FALSE;
  588.       if ((ifd = open(filename, 0)) < 0)
  589. !     pfatal2("can't open file %s", filename);
  590.   #ifndef lint
  591.       if (read(ifd, i_womp, (int)i_size) != i_size) {
  592. ***************
  593. *** 180,183 ****
  594. --- 214,221 ----
  595.               revision);
  596.           }
  597. +         else if (batch) {
  598. +         fatal2(
  599. + "this file doesn't appear to be the %s version--aborting.\n", revision);
  600. +         }
  601.           else {
  602.           ask2(
  603. ***************
  604. *** 185,189 ****
  605.               revision);
  606.           if (*buf != 'y')
  607. !         fatal1("Aborted.\n");
  608.           }
  609.       }
  610. --- 223,227 ----
  611.               revision);
  612.           if (*buf != 'y')
  613. !         fatal1("aborted\n");
  614.           }
  615.       }
  616. ***************
  617. *** 208,214 ****
  618.       using_plan_a = FALSE;
  619.       if ((ifp = fopen(filename, "r")) == Nullfp)
  620. !     fatal2("Can't open file %s\n", filename);
  621.       if ((tifd = creat(TMPINNAME, 0666)) < 0)
  622. !     fatal2("Can't open file %s\n", TMPINNAME);
  623.       while (fgets(buf, sizeof buf, ifp) != Nullch) {
  624.       if (revision != Nullch && !found_revision && rev_in_string(buf))
  625. --- 246,252 ----
  626.       using_plan_a = FALSE;
  627.       if ((ifp = fopen(filename, "r")) == Nullfp)
  628. !     pfatal2("can't open file %s", filename);
  629.       if ((tifd = creat(TMPINNAME, 0666)) < 0)
  630. !     pfatal2("can't open file %s", TMPINNAME);
  631.       while (fgets(buf, sizeof buf, ifp) != Nullch) {
  632.       if (revision != Nullch && !found_revision && rev_in_string(buf))
  633. ***************
  634. *** 225,228 ****
  635. --- 263,270 ----
  636.               revision);
  637.           }
  638. +         else if (batch) {
  639. +         fatal2(
  640. + "this file doesn't appear to be the %s version--aborting.\n", revision);
  641. +         }
  642.           else {
  643.           ask2(
  644. ***************
  645. *** 230,234 ****
  646.               revision);
  647.           if (*buf != 'y')
  648. !             fatal1("Aborted.\n");
  649.           }
  650.       }
  651. --- 272,276 ----
  652.               revision);
  653.           if (*buf != 'y')
  654. !             fatal1("aborted\n");
  655.           }
  656.       }
  657. ***************
  658. *** 243,251 ****
  659.       tibuf[1] = malloc((MEM)(BUFFERSIZE + 1));
  660.       if (tibuf[1] == Nullch)
  661. !     fatal1("Can't seem to get enough memory.\n");
  662.       for (i=1; ; i++) {
  663.       if (! (i % lines_per_buf))    /* new block */
  664.           if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
  665. !         fatal1("patch: can't write temp file.\n");
  666.       if (fgets(tibuf[0] + maxlen * (i%lines_per_buf), maxlen + 1, ifp)
  667.         == Nullch) {
  668. --- 285,293 ----
  669.       tibuf[1] = malloc((MEM)(BUFFERSIZE + 1));
  670.       if (tibuf[1] == Nullch)
  671. !     fatal1("out of memory\n");
  672.       for (i=1; ; i++) {
  673.       if (! (i % lines_per_buf))    /* new block */
  674.           if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
  675. !         pfatal1("can't write temp file");
  676.       if (fgets(tibuf[0] + maxlen * (i%lines_per_buf), maxlen + 1, ifp)
  677.         == Nullch) {
  678. ***************
  679. *** 253,257 ****
  680.           if (i % lines_per_buf)
  681.           if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
  682. !             fatal1("patch: can't write temp file.\n");
  683.           break;
  684.       }
  685. --- 295,299 ----
  686.           if (i % lines_per_buf)
  687.           if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE)
  688. !             pfatal1("can't write temp file");
  689.           break;
  690.       }
  691. ***************
  692. *** 260,264 ****
  693.       Close(tifd);
  694.       if ((tifd = open(TMPINNAME, 0)) < 0) {
  695. !     fatal2("Can't reopen file %s\n", TMPINNAME);
  696.       }
  697.   }
  698. --- 302,306 ----
  699.       Close(tifd);
  700.       if ((tifd = open(TMPINNAME, 0)) < 0) {
  701. !     pfatal2("can't reopen file %s", TMPINNAME);
  702.       }
  703.   }
  704. ***************
  705. *** 289,293 ****
  706.   #endif
  707.           if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0)
  708. !         fatal2("Error reading tmp file %s.\n", TMPINNAME);
  709.       }
  710.       return tibuf[whichbuf] + (tireclen*offline);
  711. --- 331,335 ----
  712.   #endif
  713.           if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0)
  714. !         pfatal2("error reading tmp file %s", TMPINNAME);
  715.       }
  716.       return tibuf[whichbuf] + (tireclen*offline);
  717. ***************
  718. *** 317,319 ****
  719.       return FALSE;
  720.   }
  721. --- 359,360 ----
  722. diff -C2 -N patch-2.0.12u7/patch.c patch-2.0.12u8/patch.c
  723. *** patch-2.0.12u7/patch.c    Sat Jul  4 02:33:40 1992
  724. --- patch-2.0.12u8/patch.c    Tue Aug 25 22:30:28 1992
  725. ***************
  726. *** 117,120 ****
  727. --- 117,123 ----
  728.   void my_exit();
  729.   
  730. + /* TRUE if -E was specified on command line.  */
  731. + static int remove_empty_files = FALSE;
  732.   /* TRUE if -R was specified on command line.  */
  733.   static int reverse_flag_specified = FALSE;
  734. ***************
  735. *** 122,125 ****
  736. --- 125,129 ----
  737.   /* Apply a set of diffs as appropriate. */
  738.   
  739. + int
  740.   main(argc,argv)
  741.   int argc;
  742. ***************
  743. *** 139,142 ****
  744. --- 143,148 ----
  745.       filearg[i] = Nullch;
  746.   
  747. +     myuid = getuid();
  748.       /* Cons up the names of the temporary files.  */
  749.       {
  750. ***************
  751. *** 172,178 ****
  752.       }
  753.   
  754. -     /* parse switches */
  755. -     Argc = argc;
  756. -     Argv = argv;
  757.       {
  758.         char *v;
  759. --- 178,181 ----
  760. ***************
  761. *** 188,191 ****
  762. --- 191,198 ----
  763.   #endif
  764.       }
  765. +     /* parse switches */
  766. +     Argc = argc;
  767. +     Argv = argv;
  768.       get_some_switches();
  769.       
  770. ***************
  771. *** 202,209 ****
  772.           outname = savestr(filearg[0]);
  773.       
  774. -     /* initialize the patched file */
  775. -     if (!skip_rest_of_patch)
  776. -         init_output(TMPOUTNAME);
  777. -     
  778.       /* for ed script just up and do it and exit */
  779.       if (diff_type == ED_DIFF) {
  780. --- 209,212 ----
  781. ***************
  782. *** 212,215 ****
  783. --- 215,222 ----
  784.       }
  785.       
  786. +     /* initialize the patched file */
  787. +     if (!skip_rest_of_patch)
  788. +         init_output(TMPOUTNAME);
  789. +     
  790.       /* initialize reject file */
  791.       init_reject(TMPREJNAME);
  792. ***************
  793. *** 247,251 ****
  794.               if (where == Nulline) {        /* didn't find it swapped */
  795.                   if (!pch_swap())         /* put it back to normal */
  796. !                 fatal1("Lost hunk on alloc error!\n");
  797.                   reverse = !reverse;
  798.               }
  799. --- 254,258 ----
  800.               if (where == Nulline) {        /* didn't find it swapped */
  801.                   if (!pch_swap())         /* put it back to normal */
  802. !                 fatal1("lost hunk on alloc error!\n");
  803.                   reverse = !reverse;
  804.               }
  805. ***************
  806. *** 252,256 ****
  807.               else if (noreverse) {
  808.                   if (!pch_swap())         /* put it back to normal */
  809. !                 fatal1("Lost hunk on alloc error!\n");
  810.                   reverse = !reverse;
  811.                   say1(
  812. --- 259,263 ----
  813.               else if (noreverse) {
  814.                   if (!pch_swap())         /* put it back to normal */
  815. !                 fatal1("lost hunk on alloc error!\n");
  816.                   reverse = !reverse;
  817.                   say1(
  818. ***************
  819. *** 258,261 ****
  820. --- 265,275 ----
  821.                   skip_rest_of_patch = TRUE;
  822.               }
  823. +             else if (batch) {
  824. +                 if (verbose)
  825. +                 say3(
  826. + "%seversed (or previously applied) patch detected!  %s -R.",
  827. +                 reverse ? "R" : "Unr",
  828. +                 reverse ? "Assuming" : "Ignoring");
  829. +             }
  830.               else {
  831.                   ask3(
  832. ***************
  833. *** 270,274 ****
  834.                   reverse = !reverse;
  835.                   if (!pch_swap())  /* put it back to normal */
  836. !                     fatal1("Lost hunk on alloc error!\n");
  837.                   }
  838.               }
  839. --- 284,288 ----
  840.                   reverse = !reverse;
  841.                   if (!pch_swap())  /* put it back to normal */
  842. !                     fatal1("lost hunk on alloc error!\n");
  843.                   }
  844.               }
  845. ***************
  846. *** 314,317 ****
  847. --- 328,337 ----
  848.           Argv = Argv_last;
  849.           say1("\n\nRan out of memory using Plan A--trying again...\n\n");
  850. +         if (ofp)
  851. +             Fclose(ofp);
  852. +         ofp = Nullfp;
  853. +         if (rejfp)
  854. +             Fclose(rejfp);
  855. +         rejfp = Nullfp;
  856.           continue;
  857.       }
  858. ***************
  859. *** 337,341 ****
  860.           chmod(outname, filemode);
  861.   
  862. !         if (stat(realout, &statbuf) >= 0 && statbuf.st_size == 0) {
  863.           if (verbose)
  864.               say2("Removing %s (empty after patching).\n", realout);
  865. --- 357,362 ----
  866.           chmod(outname, filemode);
  867.   
  868. !         if (remove_empty_files && stat(realout, &statbuf) == 0
  869. !         && statbuf.st_size == 0) {
  870.           if (verbose)
  871.               say2("Removing %s (empty after patching).\n", realout);
  872. ***************
  873. *** 351,355 ****
  874.   #ifndef FLEXFILENAMES
  875.           {
  876. -             char *rindex();
  877.               char *s = rindex(rejname,'/');
  878.   
  879. --- 372,375 ----
  880. ***************
  881. *** 417,421 ****
  882.   
  883.       if (filec >= 2)
  884. !     fatal1("You may not change to a different patch file.\n");
  885.   }
  886.   
  887. --- 437,441 ----
  888.   
  889.       if (filec >= 2)
  890. !     fatal1("you may not change to a different patch file\n");
  891.   }
  892.   
  893. ***************
  894. *** 424,428 ****
  895.   {
  896.       if (!--Argc)
  897. !     fatal2("patch: missing argument after `%s'\n", *Argv);
  898.       return *++Argv;
  899.   }
  900. --- 444,448 ----
  901.   {
  902.       if (!--Argc)
  903. !     fatal2("missing argument after `%s'\n", *Argv);
  904.       return *++Argv;
  905.   }
  906. ***************
  907. *** 447,451 ****
  908.       if (*s != '-' || !s[1]) {
  909.           if (filec == MAXFILEC)
  910. !         fatal1("patch: Too many file arguments.\n");
  911.           filearg[filec++] = savestr(s);
  912.       }
  913. --- 467,471 ----
  914.       if (*s != '-' || !s[1]) {
  915.           if (filec == MAXFILEC)
  916. !         fatal1("too many file arguments\n");
  917.           filearg[filec++] = savestr(s);
  918.       }
  919. ***************
  920. *** 465,469 ****
  921.               s = nextarg();
  922.           if (chdir(s) < 0)
  923. !             fatal2("Can't cd to %s.\n", s);
  924.           break;
  925.           case 'D':
  926. --- 485,489 ----
  927.               s = nextarg();
  928.           if (chdir(s) < 0)
  929. !             pfatal2("can't cd to %s", s);
  930.           break;
  931.           case 'D':
  932. ***************
  933. *** 472,476 ****
  934.               s = nextarg();
  935.           if (!isalpha(*s) && '_' != *s)
  936. !             fatal1("Argument to -D not an identifier.\n");
  937.           Sprintf(if_defined, "#ifdef %s\n", s);
  938.           Sprintf(not_defined, "#ifndef %s\n", s);
  939. --- 492,496 ----
  940.               s = nextarg();
  941.           if (!isalpha(*s) && '_' != *s)
  942. !             fatal1("argument to -D is not an identifier\n");
  943.           Sprintf(if_defined, "#ifdef %s\n", s);
  944.           Sprintf(not_defined, "#ifndef %s\n", s);
  945. ***************
  946. *** 480,483 ****
  947. --- 500,506 ----
  948.           diff_type = ED_DIFF;
  949.           break;
  950. +         case 'E':
  951. +         remove_empty_files = TRUE;
  952. +         break;
  953.           case 'f':
  954.           force = TRUE;
  955. ***************
  956. *** 518,521 ****
  957. --- 541,547 ----
  958.           skip_rest_of_patch = TRUE;
  959.           break;
  960. +         case 't':
  961. +         batch = TRUE;
  962. +         break;
  963.           case 'u':
  964.           diff_type = UNI_DIFF;
  965. ***************
  966. *** 537,544 ****
  967.           fprintf(stderr, "patch: unrecognized option `%s'\n", Argv[0]);
  968.           fprintf(stderr, "\
  969. ! Usage: patch [-ceflnNRsSuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\
  970.          [-D symbol] [-Fmax-fuzz] [-o out-file] [-p[strip-count]]\n\
  971. !        [-r rej-name] [-V {numbered,existing,simple}] [origfile] [patchfile]\n\
  972. !        [[+] [options] [origfile]...]\n");
  973.           my_exit(1);
  974.           }
  975. --- 563,571 ----
  976.           fprintf(stderr, "patch: unrecognized option `%s'\n", Argv[0]);
  977.           fprintf(stderr, "\
  978. ! Usage: patch [options] [origfile [patchfile]] [+ [options] [origfile]]...\n\
  979. ! Options:\n\
  980. !        [-ceEflnNRsStuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\
  981.          [-D symbol] [-Fmax-fuzz] [-o out-file] [-p[strip-count]]\n\
  982. !        [-r rej-name] [-V {numbered,existing,simple}]\n");
  983.           my_exit(1);
  984.           }
  985. ***************
  986. *** 633,638 ****
  987.           break;
  988.       default:
  989. !         say1("Fatal internal error in abort_hunk().\n"); 
  990. !         abort();
  991.       }
  992.       }
  993. --- 660,664 ----
  994.           break;
  995.       default:
  996. !         fatal1("fatal internal error in abort_hunk\n"); 
  997.       }
  998.       }
  999. ***************
  1000. *** 767,771 ****
  1001.       ofp = fopen(name, "w");
  1002.       if (ofp == Nullfp)
  1003. !     fatal2("patch: can't create %s.\n", name);
  1004.   }
  1005.   
  1006. --- 793,797 ----
  1007.       ofp = fopen(name, "w");
  1008.       if (ofp == Nullfp)
  1009. !     pfatal2("can't create %s", name);
  1010.   }
  1011.   
  1012. ***************
  1013. *** 778,782 ****
  1014.       rejfp = fopen(name, "w");
  1015.       if (rejfp == Nullfp)
  1016. !     fatal2("patch: can't create %s.\n", name);
  1017.   }
  1018.   
  1019. --- 804,808 ----
  1020.       rejfp = fopen(name, "w");
  1021.       if (rejfp == Nullfp)
  1022. !     pfatal2("can't create %s", name);
  1023.   }
  1024.   
  1025. ***************
  1026. *** 790,794 ****
  1027.   
  1028.       if (R_last_frozen_line > lastline)
  1029. !     fatal1("patch: misordered hunks! output will be garbled.\n");
  1030.       while (R_last_frozen_line < lastline) {
  1031.       dump_line(++R_last_frozen_line);
  1032. --- 816,820 ----
  1033.   
  1034.       if (R_last_frozen_line > lastline)
  1035. !     fatal1("misordered hunks! output would be garbled\n");
  1036.       while (R_last_frozen_line < lastline) {
  1037.       dump_line(++R_last_frozen_line);
  1038.