TurboC2.0 Patches to add TMP env var and better usage msg Prereq: 1 *** ../tcpatch/tcpatlev.h Wed Jul 18 10:37:44 1990 --- tcpatlev.h Wed Jul 18 10:38:10 1990 *************** *** 1,1 **** ! #define TCPATCHLEVEL 1 --- 1,1 ---- ! #define TCPATCHLEVEL 2 *** ../tcpatch/readme Wed Jul 18 09:54:12 1990 --- readme Wed Jul 18 09:53:56 1990 *************** *** 81,83 **** --- 81,92 ---- temp files go in directory /tmp ed scripts disabled + + *** OFFICIAL PATCHLEVEL 12, TurboC2.0 PATCHLEVEL 2 + + From: ward@sneezy.cs.wisc.edu (Mike Ward) + Date: 31 May 90 + + improved (more descriptive) usage message + temp files go in directory specified by TMP env var (or current dir if no TMP) + ed scripts still disabled *** ../tcpatch/common.h Thu May 31 12:34:31 1990 --- common.h Thu May 31 12:47:03 1990 ************** *** 128,137 EXT char *origext INIT(Nullch); EXT char *origprae INIT(Nullch); ! EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX"); ! EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */ ! EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX"); ! EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX"); EXT bool toutkeep INIT(FALSE); EXT bool trejkeep INIT(FALSE); --- 128,137 ----- EXT char *origext INIT(Nullch); EXT char *origprae INIT(Nullch); ! EXT char *TMPOUTNAME INIT("/tmp/patchoXXXXXX"); ! EXT char *TMPINNAME INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */ ! EXT char *TMPREJNAME INIT("/tmp/patchrXXXXXX"); ! EXT char *TMPPATNAME INIT("/tmp/patchpXXXXXX"); EXT bool toutkeep INIT(FALSE); EXT bool trejkeep INIT(FALSE); *** ../tcpatch/tcpatch.c Thu May 31 12:34:31 1990 --- patch.c Thu May 31 12:47:03 1990 *************** *** 1,5 **** char rcsid[] = ! "$Header: patch.c,v 2.0.1.6 88/06/22 20:46:39 lwall Locked $"; /* patch - a program to apply diffs to original files * --- 1,5 ---- char rcsid[] = ! "$Header: patch.c,v 2.0.1.7 90/05/30 11:30:00 mward $"; /* patch - a program to apply diffs to original files * *************** *** 9,14 **** --- 9,18 ---- * money off of it, or pretend that you wrote it. * * $Log: patch.c,v $ + * Revision 2.0.1.7 90/05/30 11:30:00 mward + * Added usage message vars and routines: use_msg, progname, usage, fname + * Check environment for TMP and init temp file names + * * Revision 2.0.1.6 88/06/22 20:46:39 lwall * patch12: rindex() wasn't declared * *************** *** 97,102 **** --- 101,108 ---- /* procedures */ + char *fname(); + void usage(); void reinitialize_almost_everything(); void get_some_switches(); LINENUM locate_hunk(); *************** *** 112,117 **** --- 118,195 ---- void re_input(); void my_exit(); + + char *progname; + + char *use_msg[] = { + "purpose: apply diff file(s) to original(s) to generate updated file(s)\n", + "usage: %s [options] orig patchfile [+ [options] orig]\n", + " %s set max fuzz factor to (default 2, context diffs only)\n", + " -h display help message (this text)\n", + " -l loose (non \\n whitespace) pattern matching\n", + " -n interpret patchfile as a normal diff\n", + " -N ignore patches that are reversed or already applied\n", + " -o arg use arg as output file name\n", + " -p set path strip count to (default 937,# /'s to strip)\n", + " -r arg use arg as the reject file name\n", + " -R interpret patch as if orig and new were reversed at diff gen\n", + " -s silent operation - no messages\n", + " -S skip current patch, but continue\n", + " -v version - print revision header and patch level\n", + " -x set internal debugging flags to \n", + "examples\n", + " %s sets the maximum fuzz factor. This switch only applies to context diffs, and causes .I patch --- 186,194 ---- ask any questions. It does not suppress commentary, however. Use ! .B -s for that. ! .TP -F sets the maximum fuzz factor. This switch only applies to context diffs, and causes .I patch *************** *** 269,276 **** Note that a larger fuzz factor increases the odds of a faulty patch. The default fuzz factor is 2, and it may not be set to more than the number of lines of context in the context diff, ordinarily 3. ! .TP 5 ! .B \-l causes the pattern matching to be done loosely, in case the tabs and spaces have been munged in your input file. Any sequence of whitespace in the pattern line will match any sequence --- 196,202 ---- Note that a larger fuzz factor increases the odds of a faulty patch. The default fuzz factor is 2, and it may not be set to more than the number of lines of context in the context diff, ordinarily 3. ! .TP -l causes the pattern matching to be done loosely, in case the tabs and spaces have been munged in your input file. Any sequence of whitespace in the pattern line will match any sequence *************** *** 277,299 **** in the input file. Normal characters must still match exactly. Each line of the context must still match a line in the input file. ! .TP 5 ! .B \-n forces .I patch to interpret the patch file as a normal diff. ! .TP 5 ! .B \-N causes .I patch to ignore patches that it thinks are reversed or already applied. See also ! .B \-R . ! .TP 5 ! .B \-o causes the next argument to be interpreted as the output file name. ! .TP 5 ! .B \-p sets the pathname strip count, which controls how pathnames found in the patch file are treated, in case the you keep your files in a different directory than the person who sent --- 203,221 ---- in the input file. Normal characters must still match exactly. Each line of the context must still match a line in the input file. ! .TP -n forces .I patch to interpret the patch file as a normal diff. ! .TP -N causes .I patch to ignore patches that it thinks are reversed or already applied. See also ! .B -R . ! .TP -o causes the next argument to be interpreted as the output file name. ! .TP -p sets the pathname strip count, which controls how pathnames found in the patch file are treated, in case the you keep your files in a different directory than the person who sent *************** *** 306,338 **** /u/howard/src/blurfl/blurfl.c .sp setting ! .B \-p or ! .B \-p0 gives the entire pathname unmodified, ! .B \-p1 gives .sp u/howard/src/blurfl/blurfl.c .sp without the leading slash, ! .B \-p4 gives .sp blurfl/blurfl.c .sp and not specifying ! .B \-p at all just gives you "blurfl.c". Whatever you end up with is looked for either in the current directory, or the directory specified by the ! .B \-d switch. ! .TP 5 ! .B \-r causes the next argument to be interpreted as the reject file name. ! .TP 5 ! .B \-R tells .I patch that this patch was created with the old and new files swapped. --- 228,258 ---- /u/howard/src/blurfl/blurfl.c .sp setting ! .B -p or ! .B -p0 gives the entire pathname unmodified, ! .B -p1 gives .sp u/howard/src/blurfl/blurfl.c .sp without the leading slash, ! .B -p4 gives .sp blurfl/blurfl.c .sp and not specifying ! .B -p at all just gives you "blurfl.c". Whatever you end up with is looked for either in the current directory, or the directory specified by the ! .B -d switch. ! .TP -r causes the next argument to be interpreted as the reject file name. ! .TP -R tells .I patch that this patch was created with the old and new files swapped. *************** *** 342,348 **** will attempt to swap each hunk around before applying it. Rejects will come out in the swapped format. The ! .B \-R switch will not work with ed diff scripts because there is too little information to reconstruct the reverse operation. .Sp --- 262,268 ---- will attempt to swap each hunk around before applying it. Rejects will come out in the swapped format. The ! .B -R switch will not work with ed diff scripts because there is too little information to reconstruct the reverse operation. .Sp *************** *** 350,356 **** .I patch will reverse the hunk to see if it can be applied that way. If it can, you will be asked if you want to have the ! .B \-R switch set. If it can't, the patch will continue to be applied normally. (Note: this method cannot detect a reversed patch if it is a normal diff --- 270,276 ---- .I patch will reverse the hunk to see if it can be applied that way. If it can, you will be asked if you want to have the ! .B -R switch set. If it can't, the patch will continue to be applied normally. (Note: this method cannot detect a reversed patch if it is a normal diff *************** *** 360,372 **** Luckily, most patches add or change lines rather than delete them, so most reversed normal diffs will begin with a delete, which will fail, triggering the heuristic.) ! .TP 5 ! .B \-s makes .I patch do its work silently, unless an error occurs. ! .TP 5 ! .B \-S causes .I patch to ignore this patch from the patch file, but continue on looking --- 280,290 ---- Luckily, most patches add or change lines rather than delete them, so most reversed normal diffs will begin with a delete, which will fail, triggering the heuristic.) ! .TP -s makes .I patch do its work silently, unless an error occurs. ! .TP -S causes .I patch to ignore this patch from the patch file, but continue on looking *************** *** 376,396 **** patch -S + -S + sets internal debugging flags, and is of interest only to .I patch patchers. .SH AUTHOR Larry Wall .SH ENVIRONMENT ! No environment variables are used by ! .IR patch . .SH FILES /tmp/patch* .SH SEE ALSO --- 294,319 ---- patch -S + -S + sets internal debugging flags, and is of interest only to .I patch patchers. + .OD .SH AUTHOR Larry Wall .SH ENVIRONMENT ! .IN 8 ! .TP TMP ! The location for temporary files created by ! .I patch. ! This string specifies the directory where ! .I patch ! puts any tempoorary files, and can (but need not) contain a terminating slash. ! .OD .SH FILES /tmp/patch* .SH SEE ALSO *************** *** 407,413 **** context diff header, or with an Index: line. If you are patching something in a subdirectory, be sure to tell the patch user to specify a ! .B \-p switch as needed. Third, you can create a file by sending out a diff that compares a null file to the file you want to create. --- 330,336 ---- context diff header, or with an Index: line. If you are patching something in a subdirectory, be sure to tell the patch user to specify a ! .B -p switch as needed. Third, you can create a file by sending out a diff that compares a null file to the file you want to create. *************** *** 423,429 **** .I patch couldn't parse your patch file. .PP ! The message \*(L"Hmm...\*(R" indicates that there is unprocessed text in the patch file and that .I patch is attempting to intuit whether there is a patch in that text and, if so, --- 346,352 ---- .I patch couldn't parse your patch file. .PP ! The message "Hmm..." indicates that there is unprocessed text in the patch file and that .I patch is attempting to intuit whether there is a patch in that text and, if so, *************** *** 436,443 **** .SH CAVEATS .I Patch cannot tell if the line numbers are off in an ed script, and can only detect ! bad line numbers in a normal diff when it finds a \*(L"change\*(R" or ! a \*(L"delete\*(R" command. A context diff using fuzz factor 3 may have the same problem. Until a suitable interactive interface is added, you should probably do a context diff in these cases to see if the changes made sense. --- 359,366 ---- .SH CAVEATS .I Patch cannot tell if the line numbers are off in an ed script, and can only detect ! bad line numbers in a normal diff when it finds a "change" or ! a "delete" command. A context diff using fuzz factor 3 may have the same problem. Until a suitable interactive interface is added, you should probably do a context diff in these cases to see if the changes made sense. *************** *** 464,467 **** .I patch will think it is a reversed patch, and offer to un-apply the patch. This could be construed as a feature. - .rn }` '' --- 387,389 ----