diff options
author | peter <peter@FreeBSD.org> | 1998-01-26 03:09:57 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1998-01-26 03:09:57 +0000 |
commit | e6e45661e44f15cb8c5c6f063080509bd910b98d (patch) | |
tree | a9812ba7ade0fde6f62c1626b45d522ba104c314 /contrib/cvs/src/patch.c | |
parent | 571cfa0005d94d99d1341bf8ab02be04d4df5f9f (diff) | |
download | FreeBSD-src-e6e45661e44f15cb8c5c6f063080509bd910b98d.zip FreeBSD-src-e6e45661e44f15cb8c5c6f063080509bd910b98d.tar.gz |
Import cvs-1.9.23 as at 19980123. There are a number of really nice
things fixed in here, including the '-ko' vs. -A problem with
remote cvs which caused all files with -ko to be resent each time
(which is damn painful over a modem, I can tell you). It also found a
heap of stray empty directories that should have been pruned with the -P
flag to cvs update but were not for some reason.
It also has the fully integrated rcs and diff, so no more fork/exec
overheads for rcs,ci,patch,diff,etc. This means that it parses the control
data in the rcs files only once rather than twice or more.
If the 'cvs diff' vs. Index thing is going to be fixed for future patch
compatability, this is the place to do it.
Diffstat (limited to 'contrib/cvs/src/patch.c')
-rw-r--r-- | contrib/cvs/src/patch.c | 105 |
1 files changed, 73 insertions, 32 deletions
diff --git a/contrib/cvs/src/patch.c b/contrib/cvs/src/patch.c index 194999b..9d091c3 100644 --- a/contrib/cvs/src/patch.c +++ b/contrib/cvs/src/patch.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.4 kit. + * specified in the README file that comes with the CVS source distribution. * * Patch * @@ -54,6 +54,7 @@ static const char *const patch_usage[] = "\t-D date\tDate.\n", "\t-r rev\tRevision - symbolic or numeric.\n", "\t-V vers\tUse RCS Version \"vers\" for keyword expansion.\n", + "(Specify the --help global option for a list of other help options)\n", NULL }; @@ -385,6 +386,7 @@ patch_fileproc (callerdat, finfo) size_t line2_chars_allocated; char *cp1, *cp2; FILE *fp; + int line_length; line1 = NULL; line1_chars_allocated = 0; @@ -461,23 +463,39 @@ patch_fileproc (callerdat, finfo) if (patch_short) { - (void) printf ("File %s ", finfo->fullname); + cvs_output ("File ", 0); + cvs_output (finfo->fullname, 0); if (vers_tag == NULL) - (void) printf ("is new; current revision %s\n", vers_head); + { + cvs_output (" is new; current revision ", 0); + cvs_output (vers_head, 0); + cvs_output ("\n", 1); + } else if (vers_head == NULL) { - (void) printf ("is removed; not included in "); + cvs_output (" is removed; not included in ", 0); if (rev2 != NULL) - (void) printf ("release tag %s", rev2); + { + cvs_output ("release tag ", 0); + cvs_output (rev2, 0); + } else if (date2 != NULL) - (void) printf ("release date %s", date2); + { + cvs_output ("release date ", 0); + cvs_output (date2, 0); + } else - (void) printf ("current release"); - (void) printf ("\n"); + cvs_output ("current release", 0); + cvs_output ("\n", 1); } else - (void) printf ("changed from revision %s to %s\n", - vers_tag, vers_head); + { + cvs_output (" changed from revision ", 0); + cvs_output (vers_tag, 0); + cvs_output (" to ", 0); + cvs_output (vers_head, 0); + cvs_output ("\n", 1); + } ret = 0; goto out2; } @@ -542,11 +560,8 @@ patch_fileproc (callerdat, finfo) and therefore should be on the server, not the client. */ (void) utime (tmpfile2, &t); } - run_setup ("%s -%c", DIFF, unidiff ? 'u' : 'c'); - run_arg (tmpfile1); - run_arg (tmpfile2); - switch (run_exec (RUN_TTY, tmpfile3, RUN_TTY, RUN_REALLY)) + switch (diff_exec (tmpfile1, tmpfile2, unidiff ? "-u" : "-c", tmpfile3)) { case -1: /* fork/wait failure */ error (1, errno, "fork for diff failed on %s", rcs); @@ -561,9 +576,9 @@ patch_fileproc (callerdat, finfo) */ /* Output an "Index:" line for patch to use */ - (void) fflush (stdout); - (void) printf ("Index: %s\n", finfo->fullname); - (void) fflush (stdout); + cvs_output ("Index: ", 0); + cvs_output (finfo->fullname, 0); + cvs_output ("\n", 1); fp = open_file (tmpfile3, "r"); if (getline (&line1, &line1_chars_allocated, fp) < 0 || @@ -628,25 +643,49 @@ patch_fileproc (callerdat, finfo) (void) sprintf (file2, "%s:%s", finfo->fullname, vers_head ? vers_head : "removed"); - /* Note that this prints "diff" not DIFF. The format of a diff - does not depend on the name of the program which happens to - have produced it. */ + /* Note that the string "diff" is specified by POSIX (for -c) + and is part of the diff output format, not the name of a + program. */ if (unidiff) { - (void) printf ("diff -u %s %s\n", file1, file2); - (void) printf ("--- %s%s+++ ", file1, cp1); + cvs_output ("diff -u ", 0); + cvs_output (file1, 0); + cvs_output (" ", 1); + cvs_output (file2, 0); + cvs_output ("\n", 1); + + cvs_output ("--- ", 0); + cvs_output (file1, 0); + cvs_output (cp1, 0); + cvs_output ("+++ ", 0); } else { - (void) printf ("diff -c %s %s\n", file1, file2); - (void) printf ("*** %s%s--- ", file1, cp1); + cvs_output ("diff -c ", 0); + cvs_output (file1, 0); + cvs_output (" ", 1); + cvs_output (file2, 0); + cvs_output ("\n", 1); + + cvs_output ("*** ", 0); + cvs_output (file1, 0); + cvs_output (cp1, 0); + cvs_output ("--- ", 0); } - (void) printf ("%s%s", finfo->fullname, cp2); + cvs_output (finfo->fullname, 0); + cvs_output (cp2, 0); + /* spew the rest of the diff out */ - while (getline (&line1, &line1_chars_allocated, fp) >= 0) - (void) fputs (line1, stdout); - (void) fclose (fp); + while ((line_length + = getline (&line1, &line1_chars_allocated, fp)) + >= 0) + cvs_output (line1, 0); + if (line_length < 0 && !feof (fp)) + error (0, errno, "cannot read %s", tmpfile3); + + if (fclose (fp) < 0) + error (0, errno, "cannot close %s", tmpfile3); free (file1); free (file2); break; @@ -658,10 +697,12 @@ patch_fileproc (callerdat, finfo) free (line1); if (line2) free (line2); - /* FIXME: should be checking for errors. */ - (void) CVS_UNLINK (tmpfile1); - (void) CVS_UNLINK (tmpfile2); - (void) CVS_UNLINK (tmpfile3); + if (CVS_UNLINK (tmpfile1) < 0) + error (0, errno, "cannot unlink %s", tmpfile1); + if (CVS_UNLINK (tmpfile2) < 0) + error (0, errno, "cannot unlink %s", tmpfile2); + if (CVS_UNLINK (tmpfile3) < 0) + error (0, errno, "cannot unlink %s", tmpfile3); free (tmpfile1); free (tmpfile2); free (tmpfile3); |