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

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